From d7942e13658b026d7fb8f293da0f60cb1e4d4b04 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Sun, 10 Dec 2023 00:50:10 -0300 Subject: [PATCH] button --- code/controllers/subsystem/communications.dm | 2 +- .../game/machinery/computer/communications.dm | 23 ++++++++++ .../tgui/interfaces/CommunicationsConsole.js | 42 +++++++++++++------ 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/code/controllers/subsystem/communications.dm b/code/controllers/subsystem/communications.dm index 58a88890dd..29803878dd 100644 --- a/code/controllers/subsystem/communications.dm +++ b/code/controllers/subsystem/communications.dm @@ -62,7 +62,7 @@ SUBSYSTEM_DEF(communications) COOLDOWN_START(src, emergency_meeting_cooldown, COMMUNICATION_COOLDOWN_MEETING) message_admins("[ADMIN_LOOKUPFLW(user)] has called an emergency meeting.") -/datum/controller/subsystem/communications/proc/send_message(datum/comm_message/sending,print = TRUE,unique = FALSE) +/datum/controller/subsystem/communications/proc/send_message(datum/comm_message/sending, print = FALSE, unique = FALSE) for(var/obj/machinery/computer/communications/C in GLOB.machines) if(!(C.stat & (BROKEN|NOPOWER)) && is_station_level(C.z)) if(unique) diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index f1ed801af1..39b45a9caf 100755 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -41,6 +41,9 @@ /// The last lines used for changing the status display var/static/last_status_display + /// Cooldown between printing announcement papers + COOLDOWN_DECLARE(report_print_cooldown) + /obj/machinery/computer/communications/Initialize(mapload) . = ..() GLOB.shuttle_caller_list += src @@ -162,6 +165,14 @@ deadchat_broadcast(" has changed the security level to [params["newSecurityLevel"]] with [src] at [span_name("[get_area_name(usr, TRUE)]")].", span_name("[usr.real_name]"), usr, message_type=DEADCHAT_ANNOUNCEMENT) alert_level_tick += 1 + if ("printMessage") + if (!authenticated(usr)) + return + var/message_index = text2num(params["message"]) + if (!message_index) + return + var/datum/comm_message/message = LAZYACCESS(messages, message_index) + print_report(message.content, message.title) if ("deleteMessage") if (!authenticated(usr)) return @@ -438,6 +449,7 @@ data["shuttleLastCalled"] = format_text(SSshuttle.emergencyLastCallLoc.name) if (STATE_MESSAGES) data["messages"] = list() + data["printerCooldown"] = report_print_cooldown if (messages) for (var/_message in messages) @@ -587,6 +599,17 @@ /obj/machinery/computer/communications/proc/add_message(datum/comm_message/new_message) LAZYADD(messages, new_message) +/obj/machinery/computer/communications/proc/print_report(message, title) + if(!COOLDOWN_FINISHED(src, report_print_cooldown)) + say("Printer on cooldown!") + return + COOLDOWN_START(src, report_print_cooldown, 30 SECONDS) + var/obj/item/paper/P = new /obj/item/paper(loc) + P.name = "paper - '[title]'" + P.info = message + P.update_appearance() + playsound(src, 'sound/effects/printer.ogg', 50, FALSE) + /datum/comm_message var/title var/content diff --git a/tgui/packages/tgui/interfaces/CommunicationsConsole.js b/tgui/packages/tgui/interfaces/CommunicationsConsole.js index b8b4eb8e85..c384a5694b 100644 --- a/tgui/packages/tgui/interfaces/CommunicationsConsole.js +++ b/tgui/packages/tgui/interfaces/CommunicationsConsole.js @@ -620,6 +620,7 @@ const PageMain = (props, context) => { const PageMessages = (props, context) => { const { act, data } = useBackend(context); const messages = data.messages || []; + const { printerCooldown } = data; const children = []; @@ -646,10 +647,15 @@ const PageMessages = (props, context) => { content={answer} color={message.answered === answerIndex + 1 ? "good" : undefined} key={answerIndex} - onClick={message.answered ? undefined : () => act("answerMessage", { - message: parseInt(messageIndex, 10) + 1, - answer: answerIndex + 1, - })} + onClick={ + message.answered + ? undefined + : () => + act("answerMessage", { + message: parseInt(messageIndex, 10) + 1, + answer: answerIndex + 1, + }) + } /> ))} @@ -665,14 +671,24 @@ const PageMessages = (props, context) => { title={message.title} key={messageIndex} buttons={( - act("deleteMessage", { - message: messageIndex + 1, - })} - /> + <> +