Skip to content

Commit

Permalink
virtual phone compat
Browse files Browse the repository at this point in the history
our GM's virtual phone stuff was just different enough from PvP's implementation to cause issues
  • Loading branch information
Doubleumc committed Aug 2, 2024
1 parent 62c9ff4 commit 7edba34
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
8 changes: 4 additions & 4 deletions code/__DEFINES/equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,10 @@ var/global/list/uniform_categories = list(
#define PHONE_UPP_SOLDIER "Soldier"
#define PHONE_IO "IO"

#define PHONE_DO_NOT_DISTURB_FORCED 2
#define PHONE_DO_NOT_DISTURB_ON 1
#define PHONE_DO_NOT_DISTURB_OFF 0
#define PHONE_DO_NOT_DISTURB_FORBIDDEN -1
#define PHONE_DND_FORCED 2
#define PHONE_DND_ON 1
#define PHONE_DND_OFF 0
#define PHONE_DND_FORBIDDEN -1

#define PHONE_ON_BASE_UNIT_ICON_STATE "[initial(icon_state)]"
#define PHONE_OFF_BASE_UNIT_ICON_STATE "[initial(icon_state)]_ear"
Expand Down
35 changes: 20 additions & 15 deletions code/datums/components/phone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
var/datum/component/phone/calling_phone

/// Whether or not the phone is receiving calls or not. Varies between on/off or forcibly on/off.
var/do_not_disturb = PHONE_DO_NOT_DISTURB_OFF
var/do_not_disturb = PHONE_DND_OFF

/// The Phone_ID of the last person to call this telephone.
var/last_caller

/// The ID of our timer to cancel an attempted call and "go to voicemail"
var/timeout_timer_id
Expand Down Expand Up @@ -247,10 +250,10 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
if(phone_handset.loc)
return FALSE

if(do_not_disturb == PHONE_DO_NOT_DISTURB_ON)
if(do_not_disturb == PHONE_DND_ON)
return FALSE

if(do_not_disturb == PHONE_DO_NOT_DISTURB_FORCED)
if(do_not_disturb == PHONE_DND_FORCED)
return FALSE

return TRUE
Expand Down Expand Up @@ -296,6 +299,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
/// What we do when our phone is receiving a call, called from incoming_call's call_phone()
/datum/component/phone/proc/getting_call(datum/component/phone/incoming_call)
calling_phone = incoming_call
last_caller = incoming_call.phone_id
SEND_SIGNAL(holder, COMSIG_ATOM_PHONE_RINGING)
ringing_loop.start()

Expand Down Expand Up @@ -405,13 +409,13 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
hearing_mob.hear_radio(message, "says", message_language, part_a = "<span class='purple'><span class='name'>", part_b = "</span><span class='message'> ", vname = name_override, speaker = speaker, command = loudness, no_paygrade = TRUE)

/// Toggles do not disturb on or off, does not handle forced or unable do_not_disturb variables
/datum/component/phone/proc/toggle_do_not_disturb(mob/user)
/datum/component/phone/proc/toggle_dnd(mob/user)
switch(do_not_disturb)
if(PHONE_DO_NOT_DISTURB_ON)
do_not_disturb = PHONE_DO_NOT_DISTURB_OFF
if(PHONE_DND_ON)
do_not_disturb = PHONE_DND_OFF
to_chat(user, SPAN_NOTICE("Do Not Disturb has been disabled. You can now receive calls."))
if(PHONE_DO_NOT_DISTURB_OFF)
do_not_disturb = PHONE_DO_NOT_DISTURB_ON
if(PHONE_DND_OFF)
do_not_disturb = PHONE_DND_ON
to_chat(user, SPAN_WARNING("Do Not Disturb has been enabled. No calls will be received."))
else
return FALSE
Expand Down Expand Up @@ -440,21 +444,22 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
call_phone(ui.user, params["phone_id"])
return TRUE

if("toggle_do_not_disturb")
toggle_do_not_disturb(ui.user)
if("toggle_dnd")
toggle_dnd(ui.user)
return TRUE

/datum/component/phone/ui_data(mob/user)
var/list/data = list()

data["do_not_disturb"] = do_not_disturb
data["availability"] = do_not_disturb
data["last_caller"] = last_caller

return data

/datum/component/phone/ui_static_data(mob/user)
. = list()

.["available_phones"] = get_phones() - list(phone_id)
.["available_transmitters"] = get_phones() - list(phone_id)
var/list/phones = list()
for(var/datum/component/phone/cycled_phone as anything in GLOB.phones)
phones += list(list(
Expand All @@ -464,7 +469,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
"phone_icon" = cycled_phone.phone_icon
))

.["phones"] = phones
.["transmitters"] = phones

/datum/component/phone/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
Expand Down Expand Up @@ -526,10 +531,10 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone)
if(calling_phone)
return FALSE

if(do_not_disturb == PHONE_DO_NOT_DISTURB_ON)
if(do_not_disturb == PHONE_DND_ON)
return FALSE

if(do_not_disturb == PHONE_DO_NOT_DISTURB_FORCED)
if(do_not_disturb == PHONE_DND_FORCED)
return FALSE

return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/game_master/game_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100)
current_submenus = list()

game_master_phone = new(null)
game_master_phone.AddComponent(/datum/component/phone/virtual, "Game Master", "white", "Company Command", null, PHONE_DO_NOT_DISTURB_ON, list(FACTION_MARINE, FACTION_COLONIST, FACTION_WY), list(FACTION_MARINE, FACTION_COLONIST, FACTION_WY), null, using_client)
game_master_phone.AddComponent(/datum/component/phone/virtual, "Game Master", "white", "Company Command", null, PHONE_DND_ON, list(FACTION_MARINE, FACTION_COLONIST, FACTION_WY), list(FACTION_MARINE, FACTION_COLONIST, FACTION_WY), null, using_client)

game_master_client.click_intercept = src

Expand Down
8 changes: 4 additions & 4 deletions code/modules/cm_phone/phone_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var/phone_icon

/// Whether or not the phone is receiving calls or not. Varies between on/off or forcibly on/off.
var/do_not_disturb = PHONE_DO_NOT_DISTURB_OFF
var/do_not_disturb = PHONE_DND_OFF

var/list/networks_receive = list(FACTION_MARINE)
var/list/networks_transmit = list(FACTION_MARINE)
Expand Down Expand Up @@ -45,10 +45,10 @@
icon_state = PHONE_ON_BASE_UNIT_ICON_STATE

/obj/structure/phone_base/hidden
do_not_disturb = PHONE_DO_NOT_DISTURB_FORCED
do_not_disturb = PHONE_DND_FORCED

/obj/structure/phone_base/no_dnd
do_not_disturb = PHONE_DO_NOT_DISTURB_FORBIDDEN
do_not_disturb = PHONE_DND_FORBIDDEN

//rotary desk phones (need a touch tone handset at some point)
/obj/structure/phone_base/rotary
Expand All @@ -57,7 +57,7 @@
desc = "The finger plate is a little stiff."

/obj/structure/phone_base/rotary/no_dnd
do_not_disturb = PHONE_DO_NOT_DISTURB_FORBIDDEN
do_not_disturb = PHONE_DND_FORBIDDEN

/obj/structure/phone_base/touchtone
name = "touch-tone telephone"
Expand Down
13 changes: 7 additions & 6 deletions tgui/packages/tgui/interfaces/PhoneMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const GeneralPanel = (props) => {
);

const categories = [];
for (let i = 0; i < phones.length; i++) {
let data = phones[i];
for (let i = 0; i < transmitters.length; i++) {
let data = transmitters[i];
if (categories.includes(data.phone_category)) continue;

categories.push(data.phone_category);
Expand All @@ -38,14 +38,14 @@ const GeneralPanel = (props) => {
let dnd_tooltip = 'Do Not Disturb is DISABLED';
let dnd_locked = 'No';
let dnd_icon = 'volume-high';
if (do_not_disturb === 1) {
if (availability === 1) {
dnd_tooltip = 'Do Not Disturb is ENABLED';
dnd_icon = 'volume-xmark';
} else if (do_not_disturb >= 2) {
} else if (availability >= 2) {
dnd_tooltip = 'Do Not Disturb is ENABLED (LOCKED)';
dnd_locked = 'Yes';
dnd_icon = 'volume-xmark';
} else if (do_not_disturb < 0) {
} else if (availability < 0) {
dnd_tooltip = 'Do Not Disturb is DISABLED (LOCKED)';
dnd_locked = 'Yes';
}
Expand Down Expand Up @@ -77,7 +77,7 @@ const GeneralPanel = (props) => {
<Stack.Item grow>
<Section fill scrollable>
<Tabs vertical>
{phones.map((val) => {
{transmitters.map((val) => {
if (
val.phone_category !== currentCategory ||
!val.phone_id.toLowerCase().match(currentSearch)
Expand Down Expand Up @@ -122,6 +122,7 @@ const GeneralPanel = (props) => {
</Button>
</Stack.Item>
)}
{!!last_caller && <Stack.Item>Last Caller: {last_caller}</Stack.Item>}
<Stack.Item>
<Button
color="red"
Expand Down

0 comments on commit 7edba34

Please sign in to comment.