Refactors most spans into span procs (#59645)

Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs.
Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines.

Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing.
Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc.

(Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
This commit is contained in:
Watermelon914
2021-06-14 21:03:53 +01:00
committed by GitHub
parent b9982f6970
commit 375a20e49b
1676 changed files with 15455 additions and 15226 deletions

View File

@@ -1019,7 +1019,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
return
if (!isnum(desiredLvl))
to_chat(user, "<span class='danger'>UpdateJobPreference - desired level was not a number. Please notify coders!</span>")
to_chat(user, span_danger("UpdateJobPreference - desired level was not a number. Please notify coders!"))
ShowChoices(user)
return
@@ -1049,7 +1049,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
/datum/preferences/proc/SetQuirks(mob/user)
if(!SSquirks)
to_chat(user, "<span class='danger'>The quirk subsystem is still initializing! Try again in a minute.</span>")
to_chat(user, span_danger("The quirk subsystem is still initializing! Try again in a minute."))
return
var/list/dat = list()
@@ -1145,7 +1145,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/expires = "This is a permanent ban."
if(ban_details["expiration_time"])
expires = " The ban is for [DisplayTimeText(text2num(ban_details["duration"]) MINUTES)] and expires on [ban_details["expiration_time"]] (server time)."
to_chat(user, "<span class='danger'>You, or another user of this computer or connection ([ban_details["key"]]) is banned from playing [href_list["bancheck"]].<br>The ban reason is: [ban_details["reason"]]<br>This ban (BanID #[ban_details["id"]]) was applied by [ban_details["admin_key"]] on [ban_details["bantime"]] during round ID [ban_details["round_id"]].<br>[expires]</span>")
to_chat(user, span_danger("You, or another user of this computer or connection ([ban_details["key"]]) is banned from playing [href_list["bancheck"]].<br>The ban reason is: [ban_details["reason"]]<br>This ban (BanID #[ban_details["id"]]) was applied by [ban_details["admin_key"]] on [ban_details["bantime"]] during round ID [ban_details["round_id"]].<br>[expires]"))
return
if(href_list["preference"] == "job")
switch(href_list["task"])
@@ -1188,22 +1188,22 @@ GLOBAL_LIST_EMPTY(preferences_datums)
continue
for(var/Q in all_quirks)
if((Q in L) && !(Q == quirk)) //two quirks have lined up in the list of the list of quirks that conflict with each other, so return (see quirks.dm for more details)
to_chat(user, "<span class='danger'>[quirk] is incompatible with [Q].</span>")
to_chat(user, span_danger("[quirk] is incompatible with [Q]."))
return
var/value = SSquirks.quirk_points[quirk]
var/balance = GetQuirkBalance()
if(quirk in all_quirks)
if(balance + value < 0)
to_chat(user, "<span class='warning'>Refunding this would cause you to go below your balance!</span>")
to_chat(user, span_warning("Refunding this would cause you to go below your balance!"))
return
all_quirks -= quirk
else
var/is_positive_quirk = SSquirks.quirk_points[quirk] > 0
if(is_positive_quirk && GetPositiveQuirkCount() >= MAX_QUIRKS)
to_chat(user, "<span class='warning'>You can't have more than [MAX_QUIRKS] positive quirks!</span>")
to_chat(user, span_warning("You can't have more than [MAX_QUIRKS] positive quirks!"))
return
if(balance - value < 0)
to_chat(user, "<span class='warning'>You don't have enough balance to gain this quirk!</span>")
to_chat(user, span_warning("You don't have enough balance to gain this quirk!"))
return
all_quirks += quirk
SetQuirks(user)
@@ -1383,7 +1383,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
else if((MUTCOLORS_PARTSONLY in pref_species.species_traits) || ReadHSV(temp_hsv)[3] >= ReadHSV("#7F7F7F")[3]) // mutantcolors must be bright, but only if they affect the skin
features["mcolor"] = sanitize_hexcolor(new_mutantcolor)
else
to_chat(user, "<span class='danger'>Invalid color. Your color is not bright enough.</span>")
to_chat(user, span_danger("Invalid color. Your color is not bright enough."))
if("color_ethereal")
var/new_etherealcolor = input(user, "Choose your ethereal color", "Character Preference") as null|anything in GLOB.color_list_ethereal
@@ -1735,7 +1735,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if("clear_scars")
var/path = "data/player_saves/[user.ckey[1]]/[user.ckey]/scars.sav"
fdel(path)
to_chat(user, "<span class='notice'>All scar slots cleared.</span>")
to_chat(user, span_notice("All scar slots cleared."))
if("hear_midis")
toggles ^= SOUND_MIDI
@@ -1867,7 +1867,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if("clear_heart")
hearted = FALSE
hearted_until = null
to_chat(user, "<span class='notice'>OOC Commendation Heart disabled</span>")
to_chat(user, span_notice("OOC Commendation Heart disabled"))
save_preferences()
ShowChoices(user)