diff --git a/code/__DEFINES/dcs/signals/atom/signals_atom.dm b/code/__DEFINES/dcs/signals/atom/signals_atom.dm index 8d699b0b2e..01e1533189 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_atom.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_atom.dm @@ -47,13 +47,16 @@ #define COMSIG_ATOM_VV_MODIFY_TRANSFORM "atom_vv_modify_transform" /// From /mob/living/carbon/human/UnarmedAttack() -#define COMSIG_ATOM_HUMAN_ATTACK_HAND "atom_human_attack_hand" +#define COMSIG_ATOM_BEFORE_HUMAN_ATTACK_HAND "atom_before_human_attack_hand" #define COMPONENT_CANCEL_ATTACK_HAND (1<<0) /// From /mob/proc/click_adjacent() #define COMSIG_ATOM_MOB_ATTACKBY "atom_mob_attackby" #define COMPONENT_CANCEL_ATTACKBY (1<<0) +/// From /atom/proc/attack_hand() +#define COMSIG_ATOM_ATTACK_HAND "atom_attack_hand" + /// From /datum/component/phone/proc/picked_up_call() and /datum/component/phone/proc/post_call_phone() #define COMSIG_ATOM_PHONE_PICKED_UP "atom_phone_picked_up" /// From /datum/component/phone/proc/recall_handset() diff --git a/code/_onclick/human.dm b/code/_onclick/human.dm index c7abc023a6..0bfba04070 100644 --- a/code/_onclick/human.dm +++ b/code/_onclick/human.dm @@ -80,7 +80,7 @@ to_chat(src, SPAN_NOTICE("You try to move your [temp.display_name], but cannot!")) return - if(SEND_SIGNAL(A, COMSIG_ATOM_HUMAN_ATTACK_HAND, src, click_parameters) & COMPONENT_CANCEL_HUMAN_ATTACK_HAND) + if(SEND_SIGNAL(A, COMSIG_ATOM_BEFORE_HUMAN_ATTACK_HAND, src, click_parameters) & COMPONENT_CANCEL_HUMAN_ATTACK_HAND) return A.attack_hand(src, click_parameters) @@ -89,6 +89,7 @@ return HANDLE_CLICK_PASS_THRU /atom/proc/attack_hand(mob/user) + SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_HAND, user) return /mob/living/carbon/human/MouseDrop_T(atom/dropping, mob/user) diff --git a/code/datums/components/phone.dm b/code/datums/components/phone.dm index f9375e27ae..5a069678c4 100644 --- a/code/datums/components/phone.dm +++ b/code/datums/components/phone.dm @@ -91,7 +91,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) RegisterSignal(phone_handset, COMSIG_PARENT_PREQDELETED, PROC_REF(override_delete)) RegisterSignal(src.holder, COMSIG_ATOM_MOB_ATTACKBY, PROC_REF(item_used_on_phone)) - RegisterSignal(src.holder, COMSIG_ATOM_HUMAN_ATTACK_HAND, PROC_REF(use_phone)) + RegisterSignal(src.holder, COMSIG_ATOM_BEFORE_HUMAN_ATTACK_HAND, PROC_REF(use_phone)) if(istype(src.holder, /obj/item)) RegisterSignal(src.holder, COMSIG_ITEM_PICKUP, PROC_REF(holder_picked_up)) @@ -322,7 +322,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) SEND_SIGNAL(holder, COMSIG_ATOM_PHONE_STOPPED_RINGING) - ringing_loop.stop() + ringing_loop?.stop() handle_reset_call_message(timeout, recursed) @@ -358,7 +358,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) /// Handles any messages that our handset 'hears' and passes to us. Passes the message to this phone and any connected phone via handle_hear() /datum/component/phone/proc/handle_speak(message, datum/language/message_language, mob/speaker, direct_talking = TRUE) - if(message_language.flags & SIGNLANG) + if(message_language?.flags & SIGNLANG) return if(!calling_phone) @@ -434,12 +434,14 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) switch(action) if("call_phone") + if(calling_phone) + return TRUE call_phone(ui.user, params["phone_id"]) - . = TRUE + return TRUE if("toggle_do_not_disturb") toggle_do_not_disturb(ui.user) - . = TRUE + return TRUE /datum/component/phone/ui_data(mob/user) var/list/data = list() @@ -496,10 +498,17 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) return FALSE src.virtual_user = virtual_user + RegisterSignal(src.holder, COMSIG_ATOM_ATTACK_HAND, PROC_REF(use_phone)) + return TRUE +/datum/component/phone/virtual/use_phone(atom/phone, mob/living/carbon/human/user, click_parameters) + INVOKE_ASYNC(src, PROC_REF(tgui_interact), user) + /datum/component/phone/virtual/picked_up_call(mob/living/carbon/human/user) - to_chat(user, SPAN_PURPLE("[icon2html(src, user)] Picked up a call from [calling_phone.phone_id].")) + to_chat(user, SPAN_PURPLE("[icon2html(holder, user)] Picked up a call from [calling_phone.phone_id].")) + + RegisterSignal(virtual_user.mob, COMSIG_DEAD_SPEAK, PROC_REF(handle_virtual_speak)) /datum/component/phone/virtual/other_phone_picked_up_call() if(!calling_phone) @@ -509,6 +518,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) deltimer(timeout_timer_id) timeout_timer_id = null + RegisterSignal(virtual_user.mob, COMSIG_DEAD_SPEAK, PROC_REF(handle_virtual_speak)) to_chat(virtual_user, SPAN_PURPLE("[icon2html(calling_phone.holder, virtual_user)] [calling_phone.phone_id] has picked up.")) /datum/component/phone/virtual/phone_available() @@ -523,6 +533,10 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) return TRUE +/datum/component/phone/virtual/reset_call(timeout = FALSE, recursed = FALSE) + . = ..() + UnregisterSignal(virtual_user.mob, COMSIG_DEAD_SPEAK) + /datum/component/phone/virtual/handle_reset_call_message(timeout = FALSE, recursed = FALSE) if(recursed) to_chat(virtual_user, SPAN_PURPLE("[icon2html(holder, virtual_user)] [calling_phone.phone_id] has hung up on you.")) @@ -534,6 +548,14 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) /datum/component/phone/virtual/getting_call(datum/component/phone/incoming_call) calling_phone = incoming_call SEND_SIGNAL(holder, COMSIG_ATOM_PHONE_RINGING) + playsound_client(virtual_user, 'sound/machines/telephone/telephone_ring.ogg', vol = 50) + addtimer(CALLBACK(src, PROC_REF(delayed_client_sound)), (10 SECONDS)) + +/datum/component/phone/virtual/proc/delayed_client_sound() + if(!calling_phone || !calling_phone.timeout_timer_id) + return + + playsound_client(virtual_user, 'sound/machines/telephone/telephone_ring.ogg', vol = 50) /datum/component/phone/virtual/post_call_phone(mob/user, calling_phone_id) to_chat(user, SPAN_PURPLE("[icon2html(holder, user)] Dialing [calling_phone_id]..")) @@ -545,7 +567,7 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) reset_call() // I don't think this will be possible given like... we don't have a handset but just in case return -/datum/component/phone/virtual/handle_hear(message, datum/language/message_language, mob/speaker) +/datum/component/phone/virtual/handle_hear(message, datum/language/message_language, mob/speaker, direct_talking) if(!calling_phone) return @@ -559,12 +581,51 @@ GLOBAL_LIST_EMPTY_TYPED(phones, /datum/component/phone) virtual_user.mob.hear_radio(message, "says", message_language, part_a = "", part_b = " ", vname = name_override, speaker = speaker, command = 3, no_paygrade = TRUE) +/// Used to fake the other side of our phone connection as a virtual user +/datum/component/phone/virtual/proc/handle_virtual_speak(mob/speaker, message) + SIGNAL_HANDLER + + if(!calling_phone) + return + + handle_hear(message, null, speaker, TRUE) + + log_say("TELEPHONE: [key_name(speaker)] on Phone '[phone_id]' to '[calling_phone.phone_id]' said '[message]'") + + for(var/mob/dead/observer/cycled_observer in GLOB.player_list) + if((cycled_observer.client) && (cycled_observer.client.prefs) && (cycled_observer.client.prefs.toggles_chat & CHAT_GHOSTRADIO)) + var/ghost_message = "Game Master on '[phone_id]' to '[calling_phone.phone_id]': \"[message]\"" + cycled_observer.show_message(ghost_message, SHOW_MESSAGE_AUDIBLE) + + calling_phone.handle_hear(message, null, speaker, TRUE) + + return COMPONENT_OVERRIDE_DEAD_SPEAK + // TGUI section /datum/component/phone/virtual/ui_status(mob/user, datum/ui_state/state) return UI_INTERACTIVE +/datum/component/phone/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + + switch(action) + if("hang_up") + reset_call() + return TRUE + if("pick_up") + if(!calling_phone) + return + picked_up_call(ui.user) + calling_phone.other_phone_picked_up_call() + return TRUE + /datum/component/phone/virtual/ui_data(mob/user) . = ..() .["virtual_phone"] = TRUE + .["being_called"] = calling_phone?.timeout_timer_id ? TRUE : FALSE + .["active_call"] = calling_phone ? TRUE : FALSE + .["calling_phone_id"] = "[calling_phone?.phone_id]" diff --git a/code/modules/admin/game_master/game_master.dm b/code/modules/admin/game_master/game_master.dm index 860c506918..d97fe8aedb 100644 --- a/code/modules/admin/game_master/game_master.dm +++ b/code/modules/admin/game_master/game_master.dm @@ -78,7 +78,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) /// Communication stuff - var/atom/game_master_phone + var/atom/movable/game_master_phone /// End Communication stuff @@ -92,8 +92,8 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) current_submenus = list() - game_master_phone = new() - game_master_phone.AddComponent(/datum/component/phone/virtual, "Game Master", "white", "Company Command", null, PHONE_DO_NOT_DISTURB_FORCED, list(), list(FACTION_MARINE, FACTION_COLONIST, FACTION_WY), null, using_client) + 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) using_client.click_intercept = src @@ -176,6 +176,9 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) return //Communication Section + if("use_game_master_phone") + game_master_phone.attack_hand(ui.user) + if("set_communication_clarity") var/new_clarity = text2num(params["clarity"]) if(!isnum(new_clarity)) diff --git a/tgui/packages/tgui/interfaces/GameMaster.js b/tgui/packages/tgui/interfaces/GameMaster.js index 815e37dd05..13b12f5cbc 100644 --- a/tgui/packages/tgui/interfaces/GameMaster.js +++ b/tgui/packages/tgui/interfaces/GameMaster.js @@ -81,7 +81,7 @@ export const GameMaster = (props, context) => {