Skip to content

Commit

Permalink
Rizzes up the announcements UwU (BeeStation#11656)
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy authored Oct 13, 2024
1 parent 49f4c9f commit 4036ec4
Show file tree
Hide file tree
Showing 15 changed files with 669 additions and 112 deletions.
2 changes: 2 additions & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "code\__DEFINES\ai.dm"
#include "code\__DEFINES\airlock.dm"
#include "code\__DEFINES\alarm.dm"
#include "code\__DEFINES\announcements.dm"
#include "code\__DEFINES\anomalies.dm"
#include "code\__DEFINES\antagonists.dm"
#include "code\__DEFINES\aquarium.dm"
Expand Down Expand Up @@ -253,6 +254,7 @@
#include "code\__HELPERS\_logging.dm"
#include "code\__HELPERS\_string_lists.dm"
#include "code\__HELPERS\admin.dm"
#include "code\__HELPERS\announcements.dm"
#include "code\__HELPERS\areas.dm"
#include "code\__HELPERS\atoms.dm"
#include "code\__HELPERS\bitflag_list.dm"
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/announcements.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Priority-type announcement messages for `priority_announcement()`
/// Prefix this announcement with "Priority Announcement"
#define ANNOUNCEMENT_TYPE_PRIORITY "Priority"
/// Make it sound like it's coming from the Captain
#define ANNOUNCEMENT_TYPE_CAPTAIN "Captain"
/// Make it sound like it's coming from the Syndicate
#define ANNOUNCEMENT_TYPE_SYNDICATE "Syndicate"
84 changes: 84 additions & 0 deletions code/__HELPERS/announcements.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* 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 = 'sound/ai/default/attention.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 class='major_announcement_title'>[sender_override]</span>"
announcement_strings += "<span class='subheader_announcement_text'>[title]</span>"
announcement_strings += "<span class='ooc_announcement_text'>[text]</span>"
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))
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")
return "<div class='chat_alert_[color]'>[message]</div>"

/**
* Inserts a span styled message into an OOC alert style div
*
*
* Arguments
* * message - required, the message contents
*/
/proc/create_ooc_announcement_div(message)
return "<div class='ooc_alert'>[message]</div>"
Loading

0 comments on commit 4036ec4

Please sign in to comment.