Files
Bubberstation/code/modules/security_levels/security_level_datums.dm
san7890 30bac3a301 Adds Custom Announcement Dividers (#79071)
This ports a whole bunch of various PRs and commits from
https://github.com/effigy-se/effigy-se , with heavy refactoring to keep
it fresh for /tg/'s code standards.

## About The Pull Request

The whole slew of announcement touchups lately (as in #78995
(37db1ecbf8) / #79052
(12308dbd3d)) have made me realize how
much this stuff sucks. The author of these new spans was advertising
these in coding general, so I sat down and coded it. Look at the spans,
they're much nicer than what we had going on:

(ignore the capitalized alert status names, this was removed)

<details>
<summary>Dark Mode</summary>


![image](https://github.com/tgstation/tgstation/assets/34697715/107b8efb-b7a1-41ff-9d16-358c4dc3738d)

![image](https://github.com/tgstation/tgstation/assets/34697715/9e730dfe-7ba3-4edd-96bb-0630fe5e85cf)
</details>

<details>
<summary>Light Mode</summary>


![image](https://github.com/tgstation/tgstation/assets/34697715/57f642f9-ee17-4b16-8027-00a9350e9059)

![image](https://github.com/tgstation/tgstation/assets/34697715/b28b7f49-fd4f-420a-9313-e16b9781c07c)
</details>

This PR also features

* Major announcement code handling cleanup and refactor! There was a lot
of copypasta so let's distill it all down into one proc
* Better cacheing! We were doing a shit load of new string generation
needlessly! That's fixed now.
* Better string concatenation! Lists are better for string tree reasons.
It still works just as well, as you can see from the screenshots above.
Best of all, no fucking `<br>` dogshit everywhere!
* We don't use string equivalency in order to figure out the "type" of
an announcement. It's all defines now. This was a bonus that I just
coded in since it irritated me.
* Minor spellcheck of "announcement".
* All of our HTML string mangling stuff is now all span macros! I love
macros.

## Why It's Good For The Game

In the same vein of adding examine blocks (#67937
(b864589522)) because old examinations
tended to blend in with the chat and everything chat-wise used to suck
really hard- I think this is a really nice way to draw attention to
announcements in the chat box without needing a shit load of line breaks
that just really look ugly and have no real consistency. You can look at
the PRs/commits I linked above for an idea of just how ugly it could be
getting.

I haven't audited every announcement in this PR, we can tweak this down
the line.

## Changelog

🆑 LT3, san7890
add: Announcements have gotten a fresh coat of paint! They should be
popping with splendid new colors and should have a lot less ugly
linebreaks, while still managing to keep your attention at the screen.
/🆑

I know we didn't need to port all the CSS themes but I added them
anyways in case admins wanna have some fun.
There can probably be more code improvements, just figured I'd crack it
out while I had time.
The colors also seem fine, let me know if we need more redness or
something. It's okay for stuff to be toned down a bit imo, but that
should be done after a hot second.

---------

Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
2023-10-20 21:35:20 +02:00

93 lines
2.9 KiB
Plaintext

/**
* Security levels
*
* These are used by the security level subsystem. Each one of these represents a security level that a player can set.
*
* Base type is abstract
*/
/datum/security_level
/// The name of this security level.
var/name = "not set"
/// The color of our announcement divider.
var/announcement_color = "default"
/// The numerical level of this security level, see defines for more information.
var/number_level = -1
/// The sound that we will play when this security level is set
var/sound
/// The looping sound that will be played while the security level is set
var/looping_sound
/// The looping sound interval
var/looping_sound_interval
/// The shuttle call time modification of this security level
var/shuttle_call_time_mod = 0
/// Our announcement when lowering to this level
var/lowering_to_announcement
/// Our announcement when elevating to this level
var/elevating_to_announcement
/// Our configuration key for lowering to text, if set, will override the default lowering to announcement.
var/lowering_to_configuration_key
/// Our configuration key for elevating to text, if set, will override the default elevating to announcement.
var/elevating_to_configuration_key
/datum/security_level/New()
. = ..()
if(lowering_to_configuration_key) // I'm not sure about you, but isn't there an easier way to do this?
lowering_to_announcement = global.config.Get(lowering_to_configuration_key)
if(elevating_to_configuration_key)
elevating_to_announcement = global.config.Get(elevating_to_configuration_key)
/**
* GREEN
*
* No threats
*/
/datum/security_level/green
name = "green"
announcement_color = "green"
sound = 'sound/misc/notice2.ogg' // Friendly beep
number_level = SEC_LEVEL_GREEN
lowering_to_configuration_key = /datum/config_entry/string/alert_green
shuttle_call_time_mod = ALERT_COEFF_GREEN
/**
* BLUE
*
* Caution advised
*/
/datum/security_level/blue
name = "blue"
announcement_color = "blue"
sound = 'sound/misc/notice1.ogg' // Angry alarm
number_level = SEC_LEVEL_BLUE
lowering_to_configuration_key = /datum/config_entry/string/alert_blue_downto
elevating_to_configuration_key = /datum/config_entry/string/alert_blue_upto
shuttle_call_time_mod = ALERT_COEFF_BLUE
/**
* RED
*
* Hostile threats
*/
/datum/security_level/red
name = "red"
announcement_color = "red"
sound = 'sound/misc/notice3.ogg' // More angry alarm
number_level = SEC_LEVEL_RED
lowering_to_configuration_key = /datum/config_entry/string/alert_red_downto
elevating_to_configuration_key = /datum/config_entry/string/alert_red_upto
shuttle_call_time_mod = ALERT_COEFF_RED
/**
* DELTA
*
* Station destruction is imminent
*/
/datum/security_level/delta
name = "delta"
announcement_color = "purple"
sound = 'sound/misc/airraid.ogg' // Air alarm to signify importance
number_level = SEC_LEVEL_DELTA
elevating_to_configuration_key = /datum/config_entry/string/alert_delta
shuttle_call_time_mod = ALERT_COEFF_DELTA