Skip to content

Commit

Permalink
Fixes announcements font scaling (tgstation#78995)
Browse files Browse the repository at this point in the history
## About The Pull Request

Creates CSS spans for priority announcement and minor announcement so
they scale properly with the player's chosen font size


![image](https://github.com/tgstation/tgstation/assets/83487515/0706891d-05e9-4f00-b24f-ebf37efdd18d)

## Why It's Good For The Game

Fixes tgstation#78875

## Changelog

:cl: LT3
fix: Fixed font scaling for announcements
/:cl:
  • Loading branch information
lessthnthree committed Oct 16, 2023
1 parent 83354bf commit 37db1ec
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 34 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/span.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#define span_message(str) ("<span class='message'>" + str + "</span>")
#define span_mind_control(str) ("<span class='mind_control'>" + str + "</span>")
#define span_minorannounce(str) ("<span class='minorannounce'>" + str + "</span>")
#define span_minoralert(str) ("<span class='minoralert'>" + str + "</span>")
#define span_monkey(str) ("<span class='monkey'>" + str + "</span>")
#define span_name(str) ("<span class='name'>" + str + "</span>")
#define span_narsie(str) ("<span class='narsie'>" + str + "</span>")
Expand All @@ -85,6 +86,9 @@
#define span_papyrus(str) ("<span class='papyrus'>" + str + "</span>")
#define span_phobia(str) ("<span class='phobia'>" + str + "</span>")
#define span_prefix(str) ("<span class='prefix'>" + str + "</span>")
#define span_priorityalert(str) ("<span class='priorityalert'>" + str + "</span>")
#define span_priorityannounce(str) ("<span class='priorityannounce'>" + str + "</span>")
#define span_prioritytitle(str) ("<span class='prioritytitle'>" + str + "</span>")
#define span_purple(str) ("<span class='purple'>" + str + "</span>")
#define span_radio(str) ("<span class='radio'>" + str + "</span>")
#define span_reallybig(str) ("<span class='reallybig'>" + str + "</span>")
Expand Down
34 changes: 19 additions & 15 deletions code/__HELPERS/priority_announce.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,25 @@
else if(SSstation.announcer.event_sounds[sound])
sound = SSstation.announcer.event_sounds[sound]

announcement += "<br><br>"

if(type == "Priority")
announcement += "<h1 class='alert'>Priority Announcement</h1>"
announcement += "[span_priorityannounce("<u>Priority Announcement</u>")]"
if (title && length(title) > 0)
announcement += "<br><h2 class='alert'>[title]</h2>"
announcement += "[span_prioritytitle("<br>[title]")]"
else if(type == "Captain")
announcement += "<h1 class='alert'>Captain Announces</h1>"
announcement += "[span_priorityannounce("<u>Captain Announces</u>")]"
GLOB.news_network.submit_article(text, "Captain's Announcement", "Station Announcements", null)
else if(type == "Syndicate Captain")
announcement += "<h1 class='alert'>Syndicate Captain Announces</h1>"
announcement += "[span_priorityannounce("<u>Syndicate Captain Announces</u>")]"

else
if(!sender_override)
announcement += "<h1 class='alert'>[command_name()] Update</h1>"
announcement += "[span_priorityannounce("<u>[command_name()] Update</u>")]"
else
announcement += "<h1 class='alert'>[sender_override]</h1>"
announcement += "[span_priorityannounce("<u>[sender_override]</u>")]"
if (title && length(title) > 0)
announcement += "<br><h2 class='alert'>[title]</h2>"
announcement += "[span_prioritytitle("<br>[title]")]"

if(!sender_override)
if(title == "")
Expand All @@ -63,10 +65,11 @@

///If the announcer overrides alert messages, use that message.
if(SSstation.announcer.custom_alert_message && !has_important_message)
announcement += SSstation.announcer.custom_alert_message
announcement += "[span_priorityalert("<br>[SSstation.announcer.custom_alert_message]<br>")]"
else
announcement += "<br>[span_alert(text)]<br>"
announcement += "<br>"
announcement += "[span_priorityalert("<br>[text]<br>")]"

announcement += "<br><br>"

if(!players)
players = GLOB.player_list
Expand All @@ -85,11 +88,11 @@
if(announce)
priority_announce("A report has been downloaded and printed out at all communications consoles.", "Incoming Classified Message", SSstation.announcer.get_rand_report_sound(), has_important_message = TRUE)

var/datum/comm_message/M = new
M.title = title
M.content = text
var/datum/comm_message/message = new
message.title = title
message.content = text

SScommunications.send_message(M)
SScommunications.send_message(message)

/**
* Sends a minor annoucement to players.
Expand Down Expand Up @@ -121,7 +124,8 @@
if(!target.can_hear())
continue

to_chat(target, "[span_minorannounce("<font color = red>[title]</font color><BR>[message]")]<BR>")
to_chat(target, "<br>[span_minorannounce(title)]<br>")
to_chat(target, "[span_minoralert(message)]<br><br><br>")
if(should_play_sound && target.client?.prefs.read_preference(/datum/preference/toggle/sound_announcements))
var/sound_to_play = sound_override || (alert ? 'sound/misc/notice1.ogg' : 'sound/misc/notice2.ogg')
SEND_SOUND(target, sound(sound_to_play))
2 changes: 1 addition & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ SUBSYSTEM_DEF(ticker)
to_chat(world, span_notice("and..."))
for(var/holidayname in GLOB.holidays)
var/datum/holiday/holiday = GLOB.holidays[holidayname]
to_chat(world, "<h4>[holiday.greet()]</h4>")
to_chat(world, span_info(holiday.greet()))

PostSetup()

Expand Down
30 changes: 12 additions & 18 deletions code/modules/hallucination/station_message.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#define ALERT_TITLE(text) ("<h1 class='alert'>" + text + "</h1>")
#define ALERT_BODY(text) ("<br><br>" + span_alert(text) + "<br><br>")

/datum/hallucination/station_message
abstract_hallucination_parent = /datum/hallucination/station_message
random_hallucination_weight = 1
Expand All @@ -12,16 +9,16 @@
/datum/hallucination/station_message/blob_alert

/datum/hallucination/station_message/blob_alert/start()
to_chat(hallucinator, ALERT_TITLE("Biohazard Alert"))
to_chat(hallucinator, ALERT_BODY("Confirmed outbreak of level 5 biohazard aboard [station_name()]. All personnel must contain the outbreak."))
to_chat(hallucinator, span_priorityannounce("Biohazard Alert"))
to_chat(hallucinator, span_priorityalert("Confirmed outbreak of level 5 biohazard aboard [station_name()]. All personnel must contain the outbreak."))
SEND_SOUND(hallucinator, sound(SSstation.announcer.event_sounds[ANNOUNCER_OUTBREAK5]))
return ..()

/datum/hallucination/station_message/shuttle_dock

/datum/hallucination/station_message/shuttle_dock/start()
to_chat(hallucinator, ALERT_TITLE("Priority Announcement"))
to_chat(hallucinator, ALERT_BODY("[SSshuttle.emergency || "The Emergency Shuttle"] has docked with the station. You have 3 minutes to board the Emergency Shuttle."))
to_chat(hallucinator, span_priorityannounce("Priority Announcement"))
to_chat(hallucinator, span_priorityalert("[SSshuttle.emergency || "The Emergency Shuttle"] has docked with the station. You have 3 minutes to board the Emergency Shuttle."))
SEND_SOUND(hallucinator, sound(SSstation.announcer.event_sounds[ANNOUNCER_SHUTTLEDOCK]))
return ..()

Expand All @@ -31,8 +28,8 @@
if(!(locate(/mob/living/silicon/ai) in GLOB.silicon_mobs))
return FALSE

to_chat(hallucinator, ALERT_TITLE("Anomaly Alert"))
to_chat(hallucinator, ALERT_BODY("Hostile runtimes detected in all station systems, please deactivate your AI to prevent possible damage to its morality core."))
to_chat(hallucinator, span_priorityannounce("Anomaly Alert"))
to_chat(hallucinator, span_priorityalert("Hostile runtimes detected in all station systems, please deactivate your AI to prevent possible damage to its morality core."))
SEND_SOUND(hallucinator, sound(SSstation.announcer.event_sounds[ANNOUNCER_AIMALF]))
return ..()

Expand All @@ -56,8 +53,8 @@
var/message_with_name = pick(ascension_bodies)
message_with_name = replacetext(message_with_name, "%FAKENAME%", totally_real_heretic.real_name)

to_chat(hallucinator, ALERT_TITLE(generate_heretic_text()))
to_chat(hallucinator, ALERT_BODY("[generate_heretic_text()] [message_with_name] [generate_heretic_text()]"))
to_chat(hallucinator, span_priorityannounce("[generate_heretic_text()]"))
to_chat(hallucinator, span_priorityalert("[generate_heretic_text()] [message_with_name] [generate_heretic_text()]"))
SEND_SOUND(hallucinator, sound(SSstation.announcer.event_sounds[ANNOUNCER_SPANOMALIES]))
return ..()

Expand All @@ -74,8 +71,8 @@
var/area/fake_summon_area_type = pick(GLOB.the_station_areas - hallucinator_area.type)
var/area/fake_summon_area = GLOB.areas_by_type[fake_summon_area_type]

to_chat(hallucinator, ALERT_TITLE("Central Command Higher Dimensional Affairs"))
to_chat(hallucinator, ALERT_BODY("Figments from an eldritch god are being summoned by [totally_real_cult_leader.real_name] \
to_chat(hallucinator, span_priorityannounce("Central Command Higher Dimensional Affairs"))
to_chat(hallucinator, span_priorityalert("Figments from an eldritch god are being summoned by [totally_real_cult_leader.real_name] \
into [fake_summon_area] from an unknown dimension. Disrupt the ritual at all costs!"))

SEND_SOUND(hallucinator, 'sound/ambience/antag/bloodcult/bloodcult_scribe.ogg')
Expand All @@ -85,8 +82,8 @@
random_hallucination_weight = 2

/datum/hallucination/station_message/meteors/start()
to_chat(hallucinator, ALERT_TITLE("Meteor Alert"))
to_chat(hallucinator, ALERT_BODY("Meteors have been detected on collision course with the station."))
to_chat(hallucinator, span_priorityannounce("Meteor Alert"))
to_chat(hallucinator, span_priorityalert("Meteors have been detected on collision course with the station."))
SEND_SOUND(hallucinator, sound(SSstation.announcer.event_sounds[ANNOUNCER_METEORS]))
return ..()

Expand All @@ -113,6 +110,3 @@

hallucinator.playsound_local(get_turf(hallucinator), 'sound/effects/explosion_distant.ogg', 50, FALSE, pressure_affected = FALSE)
qdel(src)

#undef ALERT_TITLE
#undef ALERT_BODY
28 changes: 28 additions & 0 deletions tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,36 @@ em {
}

.minorannounce {
color: #c51e1e;
font-weight: bold;
font-size: 185%;
margin-top: 1rem;
}

.minoralert {
color: #a4bad6;
font-size: 125%;
margin-top: 1rem;
}

.priorityannounce {
color: #a4bad6;
font-weight: bold;
font-size: 225%;
margin-top: 1rem;
}

.prioritytitle {
color: #9ab0ff;
font-weight: bold;
font-size: 185%;
margin-top: 1rem;
}

.priorityalert {
color: #c51e1e;
font-size: 140%;
margin-top: 1rem;
}

.greenannounce {
Expand Down
17 changes: 17 additions & 0 deletions tgui/packages/tgui-panel/styles/tgchat/chat-light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,27 @@ h2.alert {
}

.minorannounce {
color: #ff0000;
font-weight: bold;
font-size: 185%;
}

.minoralert {
color: #000000;
font-size: 125%;
}

.priorityannounce {
color: #000000;
font-weight: bold;
font-size: 210%;
}

.priorityalert {
color: #ff0000;
font-size: 140%;
}

.greenannounce {
color: #00ff00;
font-weight: bold;
Expand Down

0 comments on commit 37db1ec

Please sign in to comment.