From 3d0718f516867dd79037402e2834e2fe42a2d697 Mon Sep 17 00:00:00 2001
From: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
Date: Fri, 6 Jan 2023 08:50:39 -0800
Subject: [PATCH] [MANUAL MIRROR] Admin alert for communications console
messages (#18529)
Admin alert for communications console messages (#72412)
Adds an audio alert when a CentCom or Syndicate communications console
message is sent, for things such as ERT requests.
It is optional and can be toggled in the Game Preferences menu.
Also fixes an incorrect line in the prefs readme.md
Less missing CentCom messages because you're busy doing other things,
less complaining that you're ignoring them.
---
code/modules/admin/verbs/pray.dm | 8 ++++++++
code/modules/client/preferences/README.md | 2 +-
code/modules/client/preferences/admin.dm | 11 +++++++++++
code/modules/paperwork/fax.dm | 3 +++
.../preferences/features/game_preferences/admin.tsx | 6 ++++++
5 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm
index 2665d2215eb..bb0bfca26a9 100644
--- a/code/modules/admin/verbs/pray.dm
+++ b/code/modules/admin/verbs/pray.dm
@@ -55,6 +55,9 @@
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.message_centcom(sender.client, msg)
msg = span_adminnotice("CENTCOM:[ADMIN_FULLMONTY(sender)] [ADMIN_CENTCOM_REPLY(sender)]: [msg]")
+ for(var/client/staff as anything in GLOB.admins)
+ if(staff?.prefs.read_preference(/datum/preference/toggle/comms_notification))
+ SEND_SOUND(staff, sound('sound/misc/announce_dig.ogg'))
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.shuttle_caller_list)
console.override_cooldown()
@@ -64,6 +67,9 @@
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.message_syndicate(sender.client, msg)
msg = span_adminnotice("SYNDICATE:[ADMIN_FULLMONTY(sender)] [ADMIN_SYNDICATE_REPLY(sender)]: [msg]")
+ for(var/client/staff as anything in GLOB.admins)
+ if(staff?.prefs.read_preference(/datum/preference/toggle/comms_notification))
+ SEND_SOUND(staff, sound('sound/misc/announce_dig.ogg'))
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.shuttle_caller_list)
console.override_cooldown()
@@ -73,6 +79,8 @@
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.nuke_request(sender.client, msg)
msg = span_adminnotice("NUKE CODE REQUEST:[ADMIN_FULLMONTY(sender)] [ADMIN_CENTCOM_REPLY(sender)] [ADMIN_SET_SD_CODE]: [msg]")
+ for(var/client/staff as anything in GLOB.admins)
+ SEND_SOUND(staff, sound('sound/misc/announce_dig.ogg'))
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.shuttle_caller_list)
console.override_cooldown()
diff --git a/code/modules/client/preferences/README.md b/code/modules/client/preferences/README.md
index 96fb5e754e6..9df77515e51 100644
--- a/code/modules/client/preferences/README.md
+++ b/code/modules/client/preferences/README.md
@@ -248,7 +248,7 @@ For example, `/datum/preference/numeric/age` contains:
If your preference is `PREFERENCE_CHARACTER`, it MUST override `apply_to_human`, even if just to immediately `return`.
-You can also read preferences directly with `preferences.read_preference(/datum/preference/type/here)`, which will return the stored value.
+You can also read preferences directly with `prefs.read_preference(/datum/preference/type/here)`, which will return the stored value.
## Categories
Every preference needs to be in a `category`. These can be found in `code/__DEFINES/preferences.dm`.
diff --git a/code/modules/client/preferences/admin.dm b/code/modules/client/preferences/admin.dm
index 965116fdff9..47b96abca41 100644
--- a/code/modules/client/preferences/admin.dm
+++ b/code/modules/client/preferences/admin.dm
@@ -62,3 +62,14 @@
return FALSE
return is_admin(preferences.parent)
+
+/datum/preference/toggle/comms_notification
+ category = PREFERENCE_CATEGORY_GAME_PREFERENCES
+ savefile_key = "comms_notification"
+ savefile_identifier = PREFERENCE_PLAYER
+
+/datum/preference/toggle/comms_notification/is_accessible(datum/preferences/preferences)
+ if (!..(preferences))
+ return FALSE
+
+ return is_admin(preferences.parent)
diff --git a/code/modules/paperwork/fax.dm b/code/modules/paperwork/fax.dm
index a8d4a78f7a9..832ab59bed7 100644
--- a/code/modules/paperwork/fax.dm
+++ b/code/modules/paperwork/fax.dm
@@ -287,6 +287,9 @@ GLOBAL_VAR_INIT(nt_fax_department, pick("NT HR Department", "NT Legal Department
GLOB.requests.fax_request(usr.client, "sent a fax message from [fax_name]/[fax_id] to [params["name"]]", fax_paper)
to_chat(GLOB.admins, span_adminnotice("[icon2html(src.icon, GLOB.admins)]FAX REQUEST: [ADMIN_FULLMONTY(usr)]: [span_linkify("sent a fax message from [fax_name]/[fax_id][ADMIN_FLW(src)] to [html_encode(params["name"])]")] [ADMIN_SHOW_PAPER(fax_paper)]"), confidential = TRUE)
+ for(var/client/staff as anything in GLOB.admins)
+ if(staff?.prefs.read_preference(/datum/preference/toggle/comms_notification))
+ SEND_SOUND(staff, sound('sound/misc/announce_dig.ogg'))
log_fax(fax_paper, params["id"], params["name"])
loaded_item_ref = null
update_appearance()
diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx
index f72caa6c2ac..3e2539ccec9 100644
--- a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx
+++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/admin.tsx
@@ -42,3 +42,9 @@ export const ghost_roles_as_admin: FeatureToggle = {
`,
component: CheckboxInput,
};
+
+export const comms_notification: FeatureToggle = {
+ name: 'Enable comms console sound',
+ category: 'ADMIN',
+ component: CheckboxInput,
+};