From f2ba7a8e94d9fbef013d3ac8014d7a3cc6a26b4d Mon Sep 17 00:00:00 2001 From: lessthanthree <83487515+lessthnthree@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:06:53 +0000 Subject: [PATCH] Admin server announcement uses new announcement span (#80403) ## About The Pull Request The current admin announce is just notice span text, which is easily missed mixed in with all the other white noise of the chat box. Currently admins have to fill it with linebreaks or manually add their own spans to increase visibility. This updates the admin announcement proc to use the new alert box divs, similar to other announcements, making it more visible. ## Why It's Good For The Game Admin server-wide announcements are generally things you want the players to notice  ## Changelog :cl: LT3 admin: Server wide admin announcements now use an alert box like other announcements /:cl: --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/__DEFINES/span.dm | 2 + code/__HELPERS/announcements.dm | 76 +++++++++++++++++++++++++++++++ code/modules/admin/verbs/admin.dm | 2 +- tgstation.dme | 1 + 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 code/__HELPERS/announcements.dm diff --git a/code/__DEFINES/span.dm b/code/__DEFINES/span.dm index cbd29cd4218..a30e980770b 100644 --- a/code/__DEFINES/span.dm +++ b/code/__DEFINES/span.dm @@ -13,6 +13,7 @@ #define span_alertwarning(str) ("" + str + "") #define span_alien(str) ("" + str + "") #define span_announce(str) ("" + str + "") +#define span_announcement_header(str) ("" + str + "") #define span_average(str) ("" + str + "") @@ -70,6 +71,7 @@ #define span_interface(str) ("" + str + "") #define span_linkify(str) ("" + str + "") #define span_looc(str) ("" + str + "") +#define span_major_announcement_text(str) ("" + str + "") #define span_medal(str) ("" + str + "") #define span_medradio(str) ("" + str + "") #define span_memo(str) ("" + str + "") diff --git a/code/__HELPERS/announcements.dm b/code/__HELPERS/announcements.dm new file mode 100644 index 00000000000..d0deab12e99 --- /dev/null +++ b/code/__HELPERS/announcements.dm @@ -0,0 +1,76 @@ +/** + * Sends a div formatted chat box announcement + * + * Formatted like: + * + * " Server Announcement " (or sender_override) + * + * " Title " + * + * " Text " + * + * Arguments + * * text - required, the text to announce + * * title - optional, the title of the announcement. + * * players - optional, a list of all players to send the message to. defaults to the entire world + * * play_sound - if TRUE, play a sound with the announcement (based on player option) + * * sound_override - optional, override the default announcement sound + * * sender_override - optional, modifies the sender of the announcement + * * encode_title - if TRUE, the title will be HTML encoded + * * encode_text - if TRUE, the text will be HTML encoded + * * color_override - optional, set a color for the announcement box + */ + +/proc/send_formatted_announcement( + text, + title = "", + players, + play_sound = TRUE, + sound_override = 'sound/ai/default/attention.ogg', + sender_override = "Server Admin Announcement", + encode_title = TRUE, + encode_text = TRUE, + color_override = "grey", +) + if(isnull(text)) + return + + var/list/announcement_strings = list() + + if(encode_title && title && length(title) > 0) + title = html_encode(title) + if(encode_text) + text = html_encode(text) + if(!length(text)) + return + + announcement_strings += span_announcement_header(generate_unique_announcement_header(title, sender_override)) + announcement_strings += span_major_announcement_text(text) + var/finalized_announcement = create_announcement_div(jointext(announcement_strings, ""), color_override) + + if(islist(players)) + for(var/mob/target in players) + to_chat(target, finalized_announcement) + if(play_sound && target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements)) + SEND_SOUND(target, sound(sound_override)) + else + to_chat(world, finalized_announcement) + + if(!play_sound) + return + + for(var/mob/player in GLOB.player_list) + if(player.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements)) + SEND_SOUND(player, sound(sound_override)) + +/** + * Inserts a span styled message into an alert box div + * + * + * Arguments + * * message - required, the message contents + * * color - optional, set a div color other than default + */ +/proc/create_announcement_div(message, color = "default") + var/processed_message = "