From 7ecdd6475feaf7fbf8e184782e23953a285c4b12 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Mon, 25 Nov 2024 21:40:33 +0000 Subject: [PATCH 01/16] fax machine priority f --- code/game/machinery/fax_machine.dm | 81 +++++++++++++------- tgui/packages/tgui/interfaces/FaxMachine.jsx | 14 ++++ 2 files changed, 68 insertions(+), 27 deletions(-) diff --git a/code/game/machinery/fax_machine.dm b/code/game/machinery/fax_machine.dm index 4b5df130c96d..ad829997340a 100644 --- a/code/game/machinery/fax_machine.dm +++ b/code/game/machinery/fax_machine.dm @@ -68,6 +68,10 @@ GLOBAL_LIST_EMPTY(all_faxcodes) var/machine_id_tag /// Whether or not the ID tag can be changed by proc. var/fixed_id_tag = FALSE + /// Whether or not the next fax to be sent is a priority one. + var/is_priority_fax = FALSE + /// If this machine can send priority faxes. + var/can_send_priority = FALSE /obj/structure/machinery/faxmachine/Initialize(mapload, ...) . = ..() @@ -274,43 +278,54 @@ GLOBAL_LIST_EMPTY(all_faxcodes) data["nextfaxtime"] = send_cooldown data["faxcooldown"] = fax_cooldown + data["can_send_priority"] = can_send_priority + data["is_priority_fax"] = is_priority_fax + + return data /obj/structure/machinery/faxmachine/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() if(.) return + var/mob/user = ui.user switch(action) + if("toggle_priority") + is_priority_fax = !is_priority_fax + to_chat(user, SPAN_NOTICE("Priority Alert is now [is_priority_fax ? "Enabled" : "Disabled"].")) + . = TRUE + if("send") if(!original_fax) - to_chat(ui.user, SPAN_NOTICE("No paper loaded.")) + to_chat(user, SPAN_NOTICE("No paper loaded.")) return if(istype(original_fax, /obj/item/paper_bundle)) var/obj/item/paper_bundle/bundle = original_fax if(bundle.amount > 5) - to_chat(ui.user, SPAN_NOTICE("\The [src] is jammed!")) + to_chat(user, SPAN_NOTICE("\The [src] is jammed!")) return copy_fax_paper() - outgoing_fax_message(ui.user) + outgoing_fax_message(user, is_priority_fax) + is_priority_fax = FALSE COOLDOWN_START(src, send_cooldown, fax_cooldown) - to_chat(ui.user, "Message transmitted successfully.") + to_chat(user, "Message transmitted successfully.") . = TRUE if("ejectpaper") if(!original_fax) - to_chat(ui.user, SPAN_NOTICE("No paper loaded.")) - if(!ishuman(ui.user)) - to_chat(ui.user, SPAN_NOTICE("You can't do that.")) + to_chat(user, SPAN_NOTICE("No paper loaded.")) + if(!ishuman(user)) + to_chat(user, SPAN_NOTICE("You can't do that.")) return - original_fax.forceMove(ui.user.loc) - ui.user.put_in_hands(original_fax) - to_chat(ui.user, SPAN_NOTICE("You take \the [original_fax.name] out of \the [src].")) + original_fax.forceMove(user.loc) + user.put_in_hands(original_fax) + to_chat(user, SPAN_NOTICE("You take \the [original_fax.name] out of \the [src].")) original_fax = null fax_paper_copy = null photo_list = null @@ -318,31 +333,31 @@ GLOBAL_LIST_EMPTY(all_faxcodes) if("insertpaper") var/jammed = FALSE - var/obj/item/I = ui.user.get_active_hand() + var/obj/item/I = user.get_active_hand() if(istype(I, /obj/item/paper_bundle)) var/obj/item/paper_bundle/bundle = I if(bundle.amount > 5) jammed = TRUE // Repeating code? This is not ideal. Why not put this functionality inside of a proc? if(istype(I, /obj/item/paper) || istype(I, /obj/item/paper_bundle) || istype(I, /obj/item/photo)) - ui.user.drop_inv_item_to_loc(I, src) + user.drop_inv_item_to_loc(I, src) original_fax = I if(!jammed) - to_chat(ui.user, SPAN_NOTICE("You put \the [original_fax.name] into \the [src].")) + to_chat(user, SPAN_NOTICE("You put \the [original_fax.name] into \the [src].")) else - to_chat(ui.user, SPAN_NOTICE("\The [src] jammed! It can only accept up to five papers at once.")) + to_chat(user, SPAN_NOTICE("\The [src] jammed! It can only accept up to five papers at once.")) playsound(src, "sound/machines/terminal_insert_disc.ogg", 50, TRUE) flick("[initial(icon_state)]send", src) . = TRUE if("ejectid") - if(!scan || !ishuman(ui.user)) - to_chat(ui.user, SPAN_WARNING("You can't do that.")) + if(!scan || !ishuman(user)) + to_chat(user, SPAN_WARNING("You can't do that.")) return - to_chat(ui.user, SPAN_NOTICE("You take \the [scan] out of \the [src].")) - scan.forceMove(ui.user.loc) - if(!ui.user.get_active_hand()) - ui.user.put_in_hands(scan) + to_chat(user, SPAN_NOTICE("You take \the [scan] out of \the [src].")) + scan.forceMove(user.loc) + if(!user.get_active_hand()) + user.put_in_hands(scan) scan = null else scan.forceMove(src.loc) @@ -353,11 +368,11 @@ GLOBAL_LIST_EMPTY(all_faxcodes) if("select") var/last_target_department = target_department - target_department = tgui_input_list(ui.user, "Which department?", "Choose a department", GLOB.all_fax_departments) + target_department = tgui_input_list(user, "Which department?", "Choose a department", GLOB.all_fax_departments) if(!target_department) target_department = last_target_department if(target_department == DEPARTMENT_TARGET) - var/new_target_machine_id = tgui_input_list(ui.user, "Which machine?", "Choose a machine code", GLOB.all_faxcodes) + var/new_target_machine_id = tgui_input_list(user, "Which machine?", "Choose a machine code", GLOB.all_faxcodes) if(!new_target_machine_id) target_department = last_target_department else @@ -375,7 +390,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) authenticated = FALSE . = TRUE - add_fingerprint(ui.user) + add_fingerprint(user) /obj/structure/machinery/faxmachine/vv_get_dropdown() . = ..() @@ -422,7 +437,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) photo_list += list("tmp_photo[content].png" = (faxed_photo.img)) fax_paper_copy.info += "" -/obj/structure/machinery/faxmachine/proc/outgoing_fax_message(mob/user) +/obj/structure/machinery/faxmachine/proc/outgoing_fax_message(mob/user, sending_priority) var/datum/fax/faxcontents = new(fax_paper_copy.info, photo_list, fax_paper_copy.name) @@ -472,7 +487,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) var/msg_ghost = SPAN_NOTICE("[the_target_department]: ") msg_ghost += "Receiving fax via secure connection ... view message" - send_fax(faxcontents) + send_fax(faxcontents, sending_priority) announce_fax(msg_admin, msg_ghost) @@ -500,7 +515,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) C << 'sound/effects/incoming-fax.ogg' -/obj/structure/machinery/faxmachine/proc/send_fax(datum/fax/faxcontents) +/obj/structure/machinery/faxmachine/proc/send_fax(datum/fax/faxcontents, sending_priority) var/list/target_machines = list() for(var/obj/structure/machinery/faxmachine/pos_target in GLOB.all_faxmachines) if(target_department == DEPARTMENT_TARGET) @@ -517,6 +532,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) flick("[initial(icon_state)]receive", target) + playsound(target.loc, "sound/machines/fax.ogg", 15) // give the sprite some time to flick spawn(30) var/obj/item/paper/P = new(target.loc,faxcontents.photo_list) @@ -564,7 +580,10 @@ GLOBAL_LIST_EMPTY(all_faxcodes) else P.stamps += "
This paper has been sent by [machine_id_tag]." P.overlays += stampoverlay - playsound(target.loc, "sound/items/polaroid1.ogg", 15, 1) + if(sending_priority) + playsound(target.loc, "sound/machines/twobeep.ogg", 45) + target.langchat_speech("beeps with a priority message", get_mobs_in_view(GLOB.world_view_size, target), GLOB.all_languages, skip_language_check = TRUE, animation_style = LANGCHAT_FAST_POP, additional_styles = list("langchat_small", "emote")) + target.visible_message("[SPAN_BOLD(target)] beeps with a priority message.") qdel(faxcontents) /obj/structure/machinery/faxmachine/cmb @@ -584,6 +603,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) department = DEPARTMENT_WY target_department = "W-Y Liaison" network = FAX_NET_WY_HC + can_send_priority = TRUE /obj/structure/machinery/faxmachine/uscm name = "\improper USCM Military Fax Machine" @@ -596,11 +616,13 @@ GLOBAL_LIST_EMPTY(all_faxcodes) /obj/structure/machinery/faxmachine/uscm/command/capt department = "Commanding Officer" + can_send_priority = TRUE /obj/structure/machinery/faxmachine/uscm/command/highcom department = DEPARTMENT_HC target_department = "Commanding Officer" network = FAX_NET_USCM_HC + can_send_priority = TRUE /obj/structure/machinery/faxmachine/uscm/brig name = "\improper USCM Provost Fax Machine" @@ -614,6 +636,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) department = DEPARTMENT_PROVOST target_department = "Brig" network = FAX_NET_USCM_HC + can_send_priority = TRUE /obj/structure/machinery/faxmachine/upp name = "\improper UPP Military Fax Machine" @@ -625,6 +648,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) department = DEPARTMENT_UPP network = FAX_NET_UPP_HC target_department = "UPP Local Operations" + can_send_priority = TRUE /obj/structure/machinery/faxmachine/clf name = "\improper Hacked General Purpose Fax Machine" @@ -636,6 +660,7 @@ GLOBAL_LIST_EMPTY(all_faxcodes) department = DEPARTMENT_CLF network = FAX_NET_CLF_HC target_department = "CLF Local Operations" + can_send_priority = TRUE /obj/structure/machinery/faxmachine/twe name = "\improper TWE Military Fax Machine" @@ -647,11 +672,13 @@ GLOBAL_LIST_EMPTY(all_faxcodes) department = DEPARTMENT_TWE network = FAX_NET_TWE_HC target_department = "TWE Local Operations" + can_send_priority = TRUE /obj/structure/machinery/faxmachine/press/highcom department = DEPARTMENT_PRESS network = FAX_NET_PRESS_HC target_department = "General Public" + can_send_priority = TRUE ///The deployed fax machine backpack /obj/structure/machinery/faxmachine/backpack diff --git a/tgui/packages/tgui/interfaces/FaxMachine.jsx b/tgui/packages/tgui/interfaces/FaxMachine.jsx index 8cb881a5da00..41dfac18a90d 100644 --- a/tgui/packages/tgui/interfaces/FaxMachine.jsx +++ b/tgui/packages/tgui/interfaces/FaxMachine.jsx @@ -93,6 +93,8 @@ const FaxSelect = (props) => { worldtime, nextfaxtime, faxcooldown, + can_send_priority, + is_priority_fax, } = data; const timeLeft = nextfaxtime - worldtime; @@ -143,6 +145,18 @@ const FaxSelect = (props) => { )} + {!!can_send_priority && ( + + @@ -116,7 +115,72 @@ const FaxSelect = (props) => { {'Currently sending to : ' + target_department + '.'} + + + + + + + + ); +}; + +const ConfirmSend = (props) => { + const { act, data } = useBackend(); + const { + paper, + paper_name, + authenticated, + worldtime, + nextfaxtime, + can_send_priority, + is_priority_fax, + } = data; + + const timeLeft = nextfaxtime - worldtime; + + return ( +
@@ -152,7 +216,7 @@ const FaxSelect = (props) => { fluid onClick={() => act('toggle_priority')} color={is_priority_fax ? 'green' : 'red'} - disabled={!paper || !can_send_priority} + disabled={!paper || !can_send_priority || !authenticated} tooltip="Toggle priority alert." /> From 7a1f70c2134ea3513bbbdeabc1835494ea1ed481 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Wed, 18 Dec 2024 18:07:18 +0000 Subject: [PATCH 08/16] Fixes Specific Code sending. --- code/game/machinery/fax_machine.dm | 58 +++++++++++++------- maps/map_files/USS_Almayer/USS_Almayer.dmm | 2 +- tgui/packages/tgui/interfaces/FaxMachine.jsx | 11 ++-- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/code/game/machinery/fax_machine.dm b/code/game/machinery/fax_machine.dm index 1a01736bebc6..be3baecbb54c 100644 --- a/code/game/machinery/fax_machine.dm +++ b/code/game/machinery/fax_machine.dm @@ -1,7 +1,6 @@ /datum/fax_network var/list/all_departments = list() var/list/all_faxcodes = list() - var/list/all_machines = list() GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) @@ -85,7 +84,6 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) /obj/structure/machinery/faxmachine/Initialize(mapload, ...) . = ..() - GLOB.fax_network.all_machines += src generate_id_tag() update_departments() if(!(identity_name in GLOB.fax_network.all_departments[department])) @@ -138,11 +136,10 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) identity_name = sub_name ? "[sub_name], [machine_id_tag]" : machine_id_tag if(machine_id_tag == network) return TRUE - GLOB.fax_network.all_faxcodes += id_tag_final + GLOB.fax_network.all_faxcodes[id_tag_final] = src return TRUE /obj/structure/machinery/faxmachine/Destroy() - GLOB.fax_network.all_machines -= src GLOB.fax_network.all_faxcodes -= machine_id_tag . = ..() @@ -222,9 +219,6 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) /obj/structure/machinery/faxmachine/proc/update_departments() if(!(FAX_DEPARTMENT_SPECIFIC_CODE in GLOB.fax_network.all_departments)) GLOB.fax_network.all_departments[FAX_DEPARTMENT_SPECIFIC_CODE] = list() - if(!("[department]" in GLOB.fax_network.all_departments)) //Initialize departments. This will work with multiple fax machines. - GLOB.fax_network.all_departments[department] = list() - GLOB.fax_network.all_departments[department][identity_name] = src if(!(FAX_DEPARTMENT_WY in GLOB.fax_network.all_departments)) GLOB.fax_network.all_departments[FAX_DEPARTMENT_WY] = list() if(!(FAX_DEPARTMENT_HC in GLOB.fax_network.all_departments)) @@ -241,6 +235,9 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) GLOB.fax_network.all_departments[FAX_DEPARTMENT_UPP] = list() if(!(FAX_DEPARTMENT_CLF in GLOB.fax_network.all_departments)) GLOB.fax_network.all_departments[FAX_DEPARTMENT_CLF] = list() + if(!("[department]" in GLOB.fax_network.all_departments)) //Initialize departments. This will work with multiple fax machines. + GLOB.fax_network.all_departments[department] = list() + GLOB.fax_network.all_departments[department][identity_name] = src // TGUI SHIT \\ @@ -279,15 +276,17 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) data["target_department"] = target_department data["target_machine"] = target_machine + data["sending_to_specific"] = FALSE if(target_department == FAX_DEPARTMENT_SPECIFIC_CODE) - data["target_department"] = target_machine_id + data["target_department"] = "Specific ID - [target_machine_id]" + data["sending_to_specific"] = TRUE if(target_department in FAX_HIGHCOM_DEPARTMENTS) data["highcom_dept"] = TRUE else data["highcom_dept"] = FALSE - data["awake_responder"] = is_FAX_DEPARTMENT_responder_awake(target_department) + data["awake_responder"] = is_department_responder_awake(target_department) data["worldtime"] = world.time data["nextfaxtime"] = send_cooldown @@ -330,10 +329,16 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) to_chat(user, SPAN_NOTICE("No paper loaded.")) return - if(single_sending && (target_machine == "Undefined")) + if(single_sending && (target_machine == "Undefined") && !(target_department == FAX_DEPARTMENT_SPECIFIC_CODE)) to_chat(user, SPAN_WARNING("No target machine selected!")) return + if(single_sending) + var/the_target_machine = GLOB.fax_network.all_departments[target_department][target_machine] + if(the_target_machine == src) + to_chat(user, SPAN_WARNING("You cannot send a fax to your own machine!")) + return + if(istype(original_fax, /obj/item/paper_bundle)) var/obj/item/paper_bundle/bundle = original_fax if(bundle.amount > 5) @@ -412,6 +417,9 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) var/new_target_machine_id = tgui_input_list(user, "Which machine?", "Choose a machine code", GLOB.fax_network.all_faxcodes) if(!new_target_machine_id) target_department = last_target_department + else if(new_target_machine_id == machine_id_tag) + to_chat(user, SPAN_WARNING("You cannot send a fax to your own machine!")) + target_department = last_target_department else target_machine_id = new_target_machine_id single_sending = TRUE @@ -563,16 +571,20 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) /obj/structure/machinery/faxmachine/proc/send_fax(datum/fax/faxcontents, sending_priority) var/list/receiving_machines = list() - if(!single_sending || target_department == FAX_DEPARTMENT_SPECIFIC_CODE) - for(var/obj/structure/machinery/faxmachine/pos_target in GLOB.fax_network.all_machines) - if(target_department == FAX_DEPARTMENT_SPECIFIC_CODE) - if(pos_target != src && pos_target.machine_id_tag == target_machine_id) - receiving_machines += pos_target - else - if(pos_target != src && pos_target.department == target_department) - receiving_machines += pos_target + if(target_department == FAX_DEPARTMENT_SPECIFIC_CODE) + var/the_target_machine = GLOB.fax_network.all_faxcodes[target_machine_id] + if(the_target_machine == src) + return + receiving_machines += the_target_machine + else if(!single_sending || (target_department in FAX_HIGHCOM_DEPARTMENTS)) + for(var/obj/structure/machinery/faxmachine/pos_target in GLOB.fax_network.all_departments[target_department]) + if(pos_target != src && pos_target.machine_id_tag == target_machine_id) + receiving_machines += pos_target else - receiving_machines += GLOB.fax_network.all_departments[target_department][target_machine] + var/the_target_machine = GLOB.fax_network.all_departments[target_department][target_machine] + if(the_target_machine == src) + return + receiving_machines += the_target_machine for(var/obj/structure/machinery/faxmachine/target in receiving_machines) if(!faxcontents) @@ -648,6 +660,10 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) /obj/structure/machinery/faxmachine/corporate/liaison department = "W-Y Liaison" +/obj/structure/machinery/faxmachine/corporate/liaison/almayer + department = "USS Almayer" + sub_name = "W-Y Liaison" + /obj/structure/machinery/faxmachine/corporate/highcom department = FAX_DEPARTMENT_WY target_department = "W-Y Liaison" @@ -765,7 +781,7 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) if(portable_id_tag) machine_id_tag = portable_id_tag fixed_id_tag = TRUE - GLOB.fax_network.all_faxcodes += machine_id_tag + GLOB.fax_network.all_faxcodes[machine_id_tag] = src ///The wearable and deployable part of the fax machine backpack /obj/item/device/fax_backpack @@ -862,7 +878,7 @@ GLOBAL_DATUM_INIT(fax_network, /datum/fax_network, new) src.fax_id_tag = fax_id_tag -/obj/structure/machinery/faxmachine/proc/is_FAX_DEPARTMENT_responder_awake(target_department) +/obj/structure/machinery/faxmachine/proc/is_department_responder_awake(target_department) if(!(target_department in FAX_HIGHCOM_DEPARTMENTS)) return FALSE var/target_job = JOB_FAX_RESPONDER diff --git a/maps/map_files/USS_Almayer/USS_Almayer.dmm b/maps/map_files/USS_Almayer/USS_Almayer.dmm index 0f6580172509..0f9008806992 100644 --- a/maps/map_files/USS_Almayer/USS_Almayer.dmm +++ b/maps/map_files/USS_Almayer/USS_Almayer.dmm @@ -25951,7 +25951,7 @@ /obj/structure/sign/safety/terminal{ pixel_x = -17 }, -/obj/structure/machinery/faxmachine/corporate/liaison, +/obj/structure/machinery/faxmachine/corporate/liaison/almayer, /obj/item/paper/liaison_brief{ pixel_y = 8; pixel_x = -4 diff --git a/tgui/packages/tgui/interfaces/FaxMachine.jsx b/tgui/packages/tgui/interfaces/FaxMachine.jsx index fc1417d0fa0c..93784d08cadf 100644 --- a/tgui/packages/tgui/interfaces/FaxMachine.jsx +++ b/tgui/packages/tgui/interfaces/FaxMachine.jsx @@ -95,6 +95,7 @@ const FaxSelect = (props) => { is_single_sending, target_machine, highcom_dept, + sending_to_specific, } = data; return ( @@ -125,7 +126,7 @@ const FaxSelect = (props) => { !paper || !!highcom_dept || !authenticated || - target_department === 'Specific Machine Code' + !!sending_to_specific } tooltip="Toggle sending to a specific machine in the department." /> @@ -137,9 +138,7 @@ const FaxSelect = (props) => {