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 13:03:53 -07:00
committed by GitHub
parent b9982f6970
commit 375a20e49b
1676 changed files with 15455 additions and 15226 deletions
+31 -31
View File
@@ -36,16 +36,16 @@
/obj/structure/bookcase/examine(mob/user)
. = ..()
if(!anchored)
. += "<span class='notice'>The <i>bolts</i> on the bottom are unsecured.</span>"
. += span_notice("The <i>bolts</i> on the bottom are unsecured.")
else
. += "<span class='notice'>It's secured in place with <b>bolts</b>.</span>"
. += span_notice("It's secured in place with <b>bolts</b>.")
switch(state)
if(BOOKCASE_UNANCHORED)
. += "<span class='notice'>There's a <b>small crack</b> visible on the back panel.</span>"
. += span_notice("There's a <b>small crack</b> visible on the back panel.")
if(BOOKCASE_ANCHORED)
. += "<span class='notice'>There's space inside for a <i>wooden</i> shelf.</span>"
. += span_notice("There's space inside for a <i>wooden</i> shelf.")
if(BOOKCASE_FINISHED)
. += "<span class='notice'>There's a <b>small crack</b> visible on the shelf.</span>"
. += span_notice("There's a <b>small crack</b> visible on the shelf.")
/obj/structure/bookcase/Initialize(mapload)
. = ..()
@@ -77,11 +77,11 @@
if(BOOKCASE_UNANCHORED)
if(I.tool_behaviour == TOOL_WRENCH)
if(I.use_tool(src, user, 20, volume=50))
to_chat(user, "<span class='notice'>You wrench the frame into place.</span>")
to_chat(user, span_notice("You wrench the frame into place."))
set_anchored(TRUE)
else if(I.tool_behaviour == TOOL_CROWBAR)
if(I.use_tool(src, user, 20, volume=50))
to_chat(user, "<span class='notice'>You pry the frame apart.</span>")
to_chat(user, span_notice("You pry the frame apart."))
deconstruct(TRUE)
if(BOOKCASE_ANCHORED)
@@ -89,12 +89,12 @@
var/obj/item/stack/sheet/mineral/wood/W = I
if(W.get_amount() >= 2)
W.use(2)
to_chat(user, "<span class='notice'>You add a shelf.</span>")
to_chat(user, span_notice("You add a shelf."))
state = BOOKCASE_FINISHED
update_appearance()
else if(I.tool_behaviour == TOOL_WRENCH)
I.play_tool_sound(src, 100)
to_chat(user, "<span class='notice'>You unwrench the frame.</span>")
to_chat(user, span_notice("You unwrench the frame."))
set_anchored(FALSE)
if(BOOKCASE_FINISHED)
@@ -107,11 +107,11 @@
for(var/obj/item/T in I.contents)
if(istype(T, /obj/item/book) || istype(T, /obj/item/spellbook))
STR.remove_from_storage(T, src)
to_chat(user, "<span class='notice'>You empty \the [I] into \the [src].</span>")
to_chat(user, span_notice("You empty \the [I] into \the [src]."))
update_appearance()
else if(istype(I, /obj/item/pen))
if(!user.is_literate())
to_chat(user, "<span class='notice'>You scribble illegibly on the side of [src]!</span>")
to_chat(user, span_notice("You scribble illegibly on the side of [src]!"))
return
var/newname = stripped_input(user, "What would you like to title this bookshelf?")
if(!user.canUseTopic(src, BE_CLOSE))
@@ -122,10 +122,10 @@
name = "bookcase ([sanitize(newname)])"
else if(I.tool_behaviour == TOOL_CROWBAR)
if(contents.len)
to_chat(user, "<span class='warning'>You need to remove the books first!</span>")
to_chat(user, span_warning("You need to remove the books first!"))
else
I.play_tool_sound(src, 100)
to_chat(user, "<span class='notice'>You pry the shelf out.</span>")
to_chat(user, span_notice("You pry the shelf out."))
new /obj/item/stack/sheet/mineral/wood(drop_location(), 2)
state = BOOKCASE_ANCHORED
update_appearance()
@@ -226,7 +226,7 @@
/obj/item/book/attack_self(mob/user)
if(!user.can_read(src))
return
user.visible_message("<span class='notice'>[user] opens a book titled \"[title]\" and begins reading intently.</span>")
user.visible_message(span_notice("[user] opens a book titled \"[title]\" and begins reading intently."))
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "book_nerd", /datum/mood_event/book_nerd)
on_read(user)
@@ -235,20 +235,20 @@
user << browse("<meta charset=UTF-8><TT><I>Penned by [author].</I></TT> <BR>" + "[dat]", "window=book[window_size != null ? ";size=[window_size]" : ""]")
onclose(user, "book")
else
to_chat(user, "<span class='notice'>This book is completely blank!</span>")
to_chat(user, span_notice("This book is completely blank!"))
/obj/item/book/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/pen))
if(user.is_blind())
to_chat(user, "<span class='warning'>As you are trying to write on the book, you suddenly feel very stupid!</span>")
to_chat(user, span_warning("As you are trying to write on the book, you suddenly feel very stupid!"))
return
if(unique)
to_chat(user, "<span class='warning'>These pages don't seem to take the ink well! Looks like you can't modify it.</span>")
to_chat(user, span_warning("These pages don't seem to take the ink well! Looks like you can't modify it."))
return
var/literate = user.is_literate()
if(!literate)
to_chat(user, "<span class='notice'>You scribble illegibly on the cover of [src]!</span>")
to_chat(user, span_notice("You scribble illegibly on the cover of [src]!"))
return
var/choice = tgui_input_list(usr, "What would you like to change?",,list("Title", "Contents", "Author", "Cancel"))
if(!user.canUseTopic(src, BE_CLOSE, literate))
@@ -259,10 +259,10 @@
if(!user.canUseTopic(src, BE_CLOSE, literate))
return
if (length_char(newtitle) > 30)
to_chat(user, "<span class='warning'>That title won't fit on the cover!</span>")
to_chat(user, span_warning("That title won't fit on the cover!"))
return
if(!newtitle)
to_chat(user, "<span class='warning'>That title is invalid.</span>")
to_chat(user, span_warning("That title is invalid."))
return
else
name = newtitle
@@ -272,7 +272,7 @@
if(!user.canUseTopic(src, BE_CLOSE, literate))
return
if(!content)
to_chat(user, "<span class='warning'>The content is invalid.</span>")
to_chat(user, span_warning("The content is invalid."))
return
else
dat += content
@@ -281,7 +281,7 @@
if(!user.canUseTopic(src, BE_CLOSE, literate))
return
if(!newauthor)
to_chat(user, "<span class='warning'>The name is invalid.</span>")
to_chat(user, span_warning("The name is invalid."))
return
else
author = newauthor
@@ -291,37 +291,37 @@
else if(istype(I, /obj/item/barcodescanner))
var/obj/item/barcodescanner/scanner = I
if(!scanner.computer)
to_chat(user, "<span class='alert'>[I]'s screen flashes: 'No associated computer found!'</span>")
to_chat(user, span_alert("[I]'s screen flashes: 'No associated computer found!'"))
else
switch(scanner.mode)
if(0)
scanner.book = src
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer.'</span>")
to_chat(user, span_notice("[I]'s screen flashes: 'Book stored in buffer.'"))
if(1)
scanner.book = src
scanner.computer.buffer_book = name
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Book title stored in associated computer buffer.'</span>")
to_chat(user, span_notice("[I]'s screen flashes: 'Book stored in buffer. Book title stored in associated computer buffer.'"))
if(2)
scanner.book = src
for(var/datum/borrowbook/b in scanner.computer.checkouts)
if(b.bookname == name)
scanner.computer.checkouts.Remove(b)
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Book has been checked in.'</span>")
to_chat(user, span_notice("[I]'s screen flashes: 'Book stored in buffer. Book has been checked in.'"))
return
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. No active check-out record found for current title.'</span>")
to_chat(user, span_notice("[I]'s screen flashes: 'Book stored in buffer. No active check-out record found for current title.'"))
if(3)
scanner.book = src
for(var/obj/item/book in scanner.computer.inventory)
if(book == src)
to_chat(user, "<span class='alert'>[I]'s screen flashes: 'Book stored in buffer. Title already present in inventory, aborting to avoid duplicate entry.'</span>")
to_chat(user, span_alert("[I]'s screen flashes: 'Book stored in buffer. Title already present in inventory, aborting to avoid duplicate entry.'"))
return
scanner.computer.inventory.Add(src)
to_chat(user, "<span class='notice'>[I]'s screen flashes: 'Book stored in buffer. Title added to general inventory.'</span>")
to_chat(user, span_notice("[I]'s screen flashes: 'Book stored in buffer. Title added to general inventory.'"))
else if((istype(I, /obj/item/kitchen/knife) || I.tool_behaviour == TOOL_WIRECUTTER) && !(flags_1 & HOLOGRAM_1))
to_chat(user, "<span class='notice'>You begin to carve out [title]...</span>")
to_chat(user, span_notice("You begin to carve out [title]..."))
if(do_after(user, 30, target = src))
to_chat(user, "<span class='notice'>You carve out the pages from [title]! You didn't want to read it anyway.</span>")
to_chat(user, span_notice("You carve out the pages from [title]! You didn't want to read it anyway."))
var/obj/item/storage/book/B = new
B.name = src.name
B.title = src.title
+9 -9
View File
@@ -333,15 +333,15 @@
/obj/machinery/computer/bookmanagement/proc/print_forbidden_lore(mob/user)
new /obj/item/melee/cultblade/dagger(get_turf(src))
to_chat(user, "<span class='warning'>Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a sinister dagger sitting on the desk. You don't even remember where it came from...</span>")
user.visible_message("<span class='warning'>[user] stares at the blank screen for a few moments, [user.p_their()] expression frozen in fear. When [user.p_they()] finally awaken[user.p_s()] from it, [user.p_they()] look[user.p_s()] a lot older.</span>", 2)
to_chat(user, span_warning("Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a sinister dagger sitting on the desk. You don't even remember where it came from..."))
user.visible_message(span_warning("[user] stares at the blank screen for a few moments, [user.p_their()] expression frozen in fear. When [user.p_they()] finally awaken[user.p_s()] from it, [user.p_they()] look[user.p_s()] a lot older."), 2)
/obj/machinery/computer/bookmanagement/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/barcodescanner))
var/obj/item/barcodescanner/scanner = W
scanner.computer = src
to_chat(user, "<span class='notice'>[scanner]'s associated machine has been set to [src].</span>")
audible_message("<span class='hear'>[src] lets out a low, short blip.</span>")
to_chat(user, span_notice("[scanner]'s associated machine has been set to [src]."))
audible_message(span_hear("[src] lets out a low, short blip."))
else
return ..()
@@ -485,7 +485,7 @@
B.author = author
B.dat = content
B.icon_state = "book[rand(1,8)]"
visible_message("<span class='notice'>[src]'s printer hums as it produces a completely bound book. How did it do that?</span>")
visible_message(span_notice("[src]'s printer hums as it produces a completely bound book. How did it do that?"))
break
qdel(query_library_print)
if(href_list["printbible"])
@@ -588,18 +588,18 @@
if(machine_stat)
return
if(busy)
to_chat(user, "<span class='warning'>The book binder is busy. Please wait for completion of previous operation.</span>")
to_chat(user, span_warning("The book binder is busy. Please wait for completion of previous operation."))
return
if(!user.transferItemToLoc(P, src))
return
user.visible_message("<span class='notice'>[user] loads some paper into [src].</span>", "<span class='notice'>You load some paper into [src].</span>")
audible_message("<span class='hear'>[src] begins to hum as it warms up its printing drums.</span>")
user.visible_message(span_notice("[user] loads some paper into [src]."), span_notice("You load some paper into [src]."))
audible_message(span_hear("[src] begins to hum as it warms up its printing drums."))
busy = TRUE
sleep(rand(200,400))
busy = FALSE
if(P)
if(!machine_stat)
visible_message("<span class='notice'>[src] whirs as it prints and binds a new book.</span>")
visible_message(span_notice("[src] whirs as it prints and binds a new book."))
var/obj/item/book/B = new(src.loc)
B.dat = P.info
B.name = "Print Job #" + "[rand(100, 999)]"
@@ -85,7 +85,7 @@
/obj/machinery/skill_station/attackby(obj/item/I, mob/living/user, params)
if(istype(I,/obj/item/skillchip))
if(inserted_skillchip)
to_chat(user,"<span class='notice'>There's already a skillchip inside.</span>")
to_chat(user,span_notice("There's already a skillchip inside."))
return
if(!user.transferItemToLoc(I, src))
return
@@ -125,9 +125,9 @@
var/mob/living/carbon/carbon_occupant = occupant
var/implant_msg = carbon_occupant.implant_skillchip(inserted_skillchip, FALSE)
if(implant_msg)
to_chat(carbon_occupant,"<span class='notice'>Operation failed! [implant_msg]</span>")
to_chat(carbon_occupant,span_notice("Operation failed! [implant_msg]"))
else
to_chat(carbon_occupant,"<span class='notice'>Operation complete!</span>")
to_chat(carbon_occupant,span_notice("Operation complete!"))
inserted_skillchip = null
update_appearance()
@@ -138,7 +138,7 @@
return
if(to_be_removed.is_on_cooldown())
to_chat(occupant, "<span class='notice'>DANGER! Operation cannot be completed, removal is unsafe.</span>")
to_chat(occupant, span_notice("DANGER! Operation cannot be completed, removal is unsafe."))
CRASH("Unusual error - [usr] attempted to start removal of [to_be_removed] when the interface state should not have allowed it.")
working = TRUE
@@ -154,15 +154,15 @@
var/mob/living/carbon/carbon_occupant = occupant
if(to_be_removed.is_on_cooldown())
to_chat(carbon_occupant,"<span class='notice'>Safety mechanisms activated! Skillchip cannot be safely removed.</span>")
to_chat(carbon_occupant,span_notice("Safety mechanisms activated! Skillchip cannot be safely removed."))
return
if(!istype(carbon_occupant))
to_chat(carbon_occupant,"<span class='notice'>Occupant does not appear to be a carbon-based lifeform!</span>")
to_chat(carbon_occupant,span_notice("Occupant does not appear to be a carbon-based lifeform!"))
return
if(!carbon_occupant.remove_skillchip(to_be_removed))
to_chat(carbon_occupant,"<span class='notice'>Failed to remove skillchip!</span>")
to_chat(carbon_occupant,span_notice("Failed to remove skillchip!"))
return
if(to_be_removed.removable)
@@ -170,29 +170,29 @@
else
qdel(to_be_removed)
to_chat(carbon_occupant, "<span class='notice'>Operation complete!</span>")
to_chat(carbon_occupant, span_notice("Operation complete!"))
/obj/machinery/skill_station/proc/toggle_chip_active(obj/item/skillchip/to_be_toggled)
var/mob/living/carbon/carbon_occupant = occupant
if(to_be_toggled.is_on_cooldown())
to_chat(carbon_occupant,"<span class='notice'>Safety mechanisms activated! Skillchip cannot be safely modified.</span>")
to_chat(carbon_occupant,span_notice("Safety mechanisms activated! Skillchip cannot be safely modified."))
return
if(!istype(carbon_occupant))
to_chat(carbon_occupant,"<span class='notice'>Occupant does not appear to be a carbon-based lifeform!</span>")
to_chat(carbon_occupant,span_notice("Occupant does not appear to be a carbon-based lifeform!"))
return
if(to_be_toggled.is_active())
var/active_msg = to_be_toggled.try_deactivate_skillchip(FALSE, FALSE)
if(active_msg)
to_chat(carbon_occupant,"<span class='notice'>Failed to deactivate skillchip! [active_msg]</span>")
to_chat(carbon_occupant,span_notice("Failed to deactivate skillchip! [active_msg]"))
return
// This code will fire when to_be_toggled.active is FALSE
var/active_msg = to_be_toggled.try_activate_skillchip(FALSE, FALSE)
if(active_msg)
to_chat(carbon_occupant,"<span class='notice'>Failed to activate skillchip! [active_msg]</span>")
to_chat(carbon_occupant,span_notice("Failed to activate skillchip! [active_msg]"))
/obj/machinery/skill_station/ui_data(mob/user)
. = ..()
@@ -285,7 +285,7 @@
stack_trace("[usr] tried to toggle skillchip activation when [src] was in an invalid state.")
return TRUE
if(inserted_skillchip)
to_chat(occupant,"<span class='notice'>You eject the skillchip.</span>")
to_chat(occupant,span_notice("You eject the skillchip."))
var/mob/living/carbon/human/H = occupant
H.put_in_hands(inserted_skillchip)
inserted_skillchip = null
+8 -8
View File
@@ -27,18 +27,18 @@
var/obj/structure/chisel_message/existing_message = locate() in T
if(!remaining_uses && !existing_message)
to_chat(user, "<span class='warning'>[src] is too worn out to use.</span>")
to_chat(user, span_warning("[src] is too worn out to use."))
return
if(!good_chisel_message_location(T))
to_chat(user, "<span class='warning'>It's not appropriate to engrave on [T].</span>")
to_chat(user, span_warning("It's not appropriate to engrave on [T]."))
return
if(existing_message)
user.visible_message("<span class='notice'>[user] starts erasing [existing_message].</span>", "<span class='notice'>You start erasing [existing_message].</span>", "<span class='hear'>You hear a chipping sound.</span>")
user.visible_message(span_notice("[user] starts erasing [existing_message]."), span_notice("You start erasing [existing_message]."), span_hear("You hear a chipping sound."))
playsound(loc, 'sound/items/gavel.ogg', 50, TRUE, -1)
if(do_after(user, tool_speed, target = existing_message))
user.visible_message("<span class='notice'>[user] erases [existing_message].</span>", "<span class='notice'>You erase [existing_message][existing_message.creator_key == user.ckey ? ", refunding a use" : ""].</span>")
user.visible_message(span_notice("[user] erases [existing_message]."), span_notice("You erase [existing_message][existing_message.creator_key == user.ckey ? ", refunding a use" : ""]."))
existing_message.persists = FALSE
qdel(existing_message)
playsound(loc, 'sound/items/gavel.ogg', 50, TRUE, -1)
@@ -48,17 +48,17 @@
var/message = stripped_input(user, "What would you like to engrave?", "Leave a message")
if(!message)
to_chat(user, "<span class='notice'>You decide not to engrave anything.</span>")
to_chat(user, span_notice("You decide not to engrave anything."))
return
if(!target.Adjacent(user) && locate(/obj/structure/chisel_message) in T)
to_chat(user, "<span class='warning'>Someone wrote here before you chose! Find another spot.</span>")
to_chat(user, span_warning("Someone wrote here before you chose! Find another spot."))
return
playsound(loc, 'sound/items/gavel.ogg', 50, TRUE, -1)
user.visible_message("<span class='notice'>[user] starts engraving a message into [T]...</span>", "<span class='notice'>You start engraving a message into [T]...</span>", "<span class='hear'>You hear a chipping sound.</span>")
user.visible_message(span_notice("[user] starts engraving a message into [T]..."), span_notice("You start engraving a message into [T]..."), span_hear("You hear a chipping sound."))
if(can_use() && do_after(user, tool_speed, target = T) && can_use()) //This looks messy but it's actually really clever!
if(!locate(/obj/structure/chisel_message) in T)
user.visible_message("<span class='notice'>[user] leaves a message for future spacemen!</span>", "<span class='notice'>You engrave a message into [T]!</span>", "<span class='hear'>You hear a chipping sound.</span>")
user.visible_message(span_notice("[user] leaves a message for future spacemen!"), span_notice("You engrave a message into [T]!"), span_hear("You hear a chipping sound."))
playsound(loc, 'sound/items/gavel.ogg', 50, TRUE, -1)
var/obj/structure/chisel_message/M = new(T)
M.register(user, message)