diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index b31c3bb4c8..2b4373f574 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -626,7 +626,7 @@ var/global/floorIsLava = 0 if(!check_rights(R_SERVER,0)) message = sanitize(message, 500, extra = 0) message = replacetext(message, "\n", "
") // required since we're putting it in a

tag - to_world("[usr.client.holder.fakekey ? "Administrator" : usr.key] Announces:

[message]

") + send_ooc_announcement(message, "From [usr.client.holder.fakekey ? "Administrator" : usr.key]") // CHOMPEdit log_admin("Announce: [key_name(usr)] : [message]") feedback_add_details("admin_verb","A") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/modular_chomp/code/_HELPERS/announcements.dm b/modular_chomp/code/_HELPERS/announcements.dm new file mode 100644 index 0000000000..d41b2b76ac --- /dev/null +++ b/modular_chomp/code/_HELPERS/announcements.dm @@ -0,0 +1,86 @@ +/** + * 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 (escaped) + * * encode_text - if TRUE, the text will be HTML encoded (escaped) + */ + +/proc/send_ooc_announcement( + text, + title = "", + players, + play_sound = TRUE, + sound_override = 'modular_chomp/sound/misc/bloop.ogg', + sender_override = "Server Admin Announcement", + encode_title = TRUE, + encode_text = FALSE, +) + 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_major_announcement_title(sender_override) + announcement_strings += span_subheader_announcement_text(title) + announcement_strings += span_ooc_announcement_text(text) + var/finalized_announcement = create_ooc_announcement_div(jointext(announcement_strings, "")) + + 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)) + if(play_sound && target.client?.is_preference_enabled(/datum/client_preference/holder/play_adminhelp_ping)) + SEND_SOUND(target, sound(sound_override)) + else + to_chat(world, finalized_announcement) + + if(!play_sound) + return + + for(var/mob/player in player_list) + //if(player.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements)) + if(player.client?.is_preference_enabled(/datum/client_preference/holder/play_adminhelp_ping)) + 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") + return "
[message]
" + +/** + * Inserts a span styled message into an OOC alert style div + * + * + * Arguments + * * message - required, the message contents + */ +/proc/create_ooc_announcement_div(message) + return "
[message]
" diff --git a/modular_chomp/code/__defines/span.dm b/modular_chomp/code/__defines/span.dm new file mode 100644 index 0000000000..e9ef173f51 --- /dev/null +++ b/modular_chomp/code/__defines/span.dm @@ -0,0 +1,4 @@ +#define span_major_announcement_text(str) ("" + str + "") +#define span_major_announcement_title(str) ("" + str + "") +#define span_ooc_announcement_text(str) ("" + str + "") +#define span_subheader_announcement_text(str) ("" + str + "") diff --git a/modular_chomp/sound/misc/bloop.ogg b/modular_chomp/sound/misc/bloop.ogg new file mode 100644 index 0000000000..260e9e926e Binary files /dev/null and b/modular_chomp/sound/misc/bloop.ogg differ diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss index a92d02427c..bb48314f35 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss @@ -1235,6 +1235,24 @@ $border-width-px: $border-width * 1px; flex-direction: column; } +.ooc_alert { + background: #4d4100; + border: 1px solid #cca300; + margin: 0.5em; + padding: 0.5em 0.5em 0.5em 0.2em; + color: #ffffff; + font-weight: bold; + display: flex; + flex-direction: column; +} + +.ooc_announcement_text { + color: #cca300; + padding: 0.5em 0 0 0.35em; + display: flex; + flex-direction: column; +} + @each $color-name, $color-value in $alert-stripe-colors { .chat_alert_#{$color-name} { color: #ffffff; diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss index 5d83c32be2..3452bf965a 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss @@ -1262,6 +1262,24 @@ $border-width-px: $border-width * 1px; flex-direction: column; } +.ooc_alert { + background: #bdc8ff; + border: 1px solid #002eb8; + margin: 0.5em; + padding: 0.5em 0.5em 0.5em 0.2em; + color: #00283a; + font-weight: bold; + display: flex; + flex-direction: column; +} + +.ooc_announcement_text { + color: #002eb8; + padding: 0.5em 0 0 0.35em; + display: flex; + flex-direction: column; +} + @each $color-name, $color-value in $alert-stripe-colors { .chat_alert_#{$color-name} { color: #ffffff; diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-vchatdark.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-vchatdark.scss index aa15f6ee67..a8e1b08109 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-vchatdark.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-vchatdark.scss @@ -1236,6 +1236,24 @@ $border-width-px: $border-width * 1px; flex-direction: column; } +.ooc_alert { + background: #4d4100; + border: 1px solid #cca300; + margin: 0.5em; + padding: 0.5em 0.5em 0.5em 0.2em; + color: #ffffff; + font-weight: bold; + display: flex; + flex-direction: column; +} + +.ooc_announcement_text { + color: #cca300; + padding: 0.5em 0 0 0.35em; + display: flex; + flex-direction: column; +} + @each $color-name, $color-value in $alert-stripe-colors { .chat_alert_#{$color-name} { color: #ffffff; diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-vchatlight.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-vchatlight.scss index 279dd7bc21..f26caaae57 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-vchatlight.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-vchatlight.scss @@ -1260,6 +1260,24 @@ $border-width-px: $border-width * 1px; flex-direction: column; } +.ooc_alert { + background: #bdc8ff; + border: 1px solid #002eb8; + margin: 0.5em; + padding: 0.5em 0.5em 0.5em 0.2em; + color: #00283a; + font-weight: bold; + display: flex; + flex-direction: column; +} + +.ooc_announcement_text { + color: #002eb8; + padding: 0.5em 0 0 0.35em; + display: flex; + flex-direction: column; +} + @each $color-name, $color-value in $alert-stripe-colors { .chat_alert_#{$color-name} { color: #ffffff; diff --git a/vorestation.dme b/vorestation.dme index 9ae6d0c849..f11490b5b9 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -4614,9 +4614,11 @@ #include "modular_chomp\code\coalesce_ch.dm" #include "modular_chomp\code\global.dm" #include "modular_chomp\code\__defines\_planes+layers.dm" +#include "modular_chomp\code\__defines\span.dm" #include "modular_chomp\code\__defines\text.dm" #include "modular_chomp\code\_global_vars\tgui.dm" #include "modular_chomp\code\_global_vars\list\names.dm" +#include "modular_chomp\code\_HELPERS\announcements.dm" #include "modular_chomp\code\_HELPERS\game.dm" #include "modular_chomp\code\_HELPERS\mobs.dm" #include "modular_chomp\code\_HELPERS\type2type.dm"