This commit is contained in:
SandPoot
2023-12-10 00:50:10 -03:00
parent aec4c46564
commit d7942e1365
3 changed files with 53 additions and 14 deletions
+1 -1
View File
@@ -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)
@@ -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
@@ -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,
})
}
/>
))}
</Box>
@@ -665,14 +671,24 @@ const PageMessages = (props, context) => {
title={message.title}
key={messageIndex}
buttons={(
<Button.Confirm
icon="trash"
content="Delete"
color="red"
onClick={() => act("deleteMessage", {
message: messageIndex + 1,
})}
/>
<>
<Button
icon="print"
content="Print"
disabled={printerCooldown}
onClick={() => act("printMessage", {
message: parseInt(messageIndex, 10) + 1,
})}
/>
<Button.Confirm
icon="trash"
content="Delete"
color="red"
onClick={() => act("deleteMessage", {
message: parseInt(messageIndex, 10) + 1,
})}
/>
</>
)}>
<Box
dangerouslySetInnerHTML={textHtml} />
@@ -703,7 +719,7 @@ export const CommunicationsConsole = (props, context) => {
return (
<Window
width={400}
width={450}
height={650}
theme={emagged ? "syndicate" : undefined}>
<Window.Content overflow="auto">