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
+72 -72
View File
@@ -36,18 +36,18 @@
. = ..()
if(reinf)
if(anchored && state == WINDOW_SCREWED_TO_FRAME)
. += "<span class='notice'>The window is <b>screwed</b> to the frame.</span>"
. += span_notice("The window is <b>screwed</b> to the frame.")
else if(anchored && state == WINDOW_IN_FRAME)
. += "<span class='notice'>The window is <i>unscrewed</i> but <b>pried</b> into the frame.</span>"
. += span_notice("The window is <i>unscrewed</i> but <b>pried</b> into the frame.")
else if(anchored && state == WINDOW_OUT_OF_FRAME)
. += "<span class='notice'>The window is out of the frame, but could be <i>pried</i> in. It is <b>screwed</b> to the floor.</span>"
. += span_notice("The window is out of the frame, but could be <i>pried</i> in. It is <b>screwed</b> to the floor.")
else if(!anchored)
. += "<span class='notice'>The window is <i>unscrewed</i> from the floor, and could be deconstructed by <b>wrenching</b>.</span>"
. += span_notice("The window is <i>unscrewed</i> from the floor, and could be deconstructed by <b>wrenching</b>.")
else
if(anchored)
. += "<span class='notice'>The window is <b>screwed</b> to the floor.</span>"
. += span_notice("The window is <b>screwed</b> to the floor.")
else
. += "<span class='notice'>The window is <i>unscrewed</i> from the floor, and could be deconstructed by <b>wrenching</b>.</span>"
. += span_notice("The window is <i>unscrewed</i> from the floor, and could be deconstructed by <b>wrenching</b>.")
/obj/structure/window/Initialize(mapload, direct)
. = ..()
@@ -89,7 +89,7 @@
/obj/structure/window/rcd_act(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
if(RCD_DECONSTRUCT)
to_chat(user, "<span class='notice'>You deconstruct the window.</span>")
to_chat(user, span_notice("You deconstruct the window."))
qdel(src)
return TRUE
return FALSE
@@ -139,7 +139,7 @@
/obj/structure/window/attack_tk(mob/user)
user.changeNext_move(CLICK_CD_MELEE)
user.visible_message("<span class='notice'>Something knocks on [src].</span>")
user.visible_message(span_notice("Something knocks on [src]."))
add_fingerprint(user)
playsound(src, knocksound, 50, TRUE)
return COMPONENT_CANCEL_ATTACK_CHAIN
@@ -159,12 +159,12 @@
user.changeNext_move(CLICK_CD_MELEE)
if(!user.combat_mode)
user.visible_message("<span class='notice'>[user] knocks on [src].</span>", \
"<span class='notice'>You knock on [src].</span>")
user.visible_message(span_notice("[user] knocks on [src]."), \
span_notice("You knock on [src]."))
playsound(src, knocksound, 50, TRUE)
else
user.visible_message("<span class='warning'>[user] bashes [src]!</span>", \
"<span class='warning'>You bash [src]!</span>")
user.visible_message(span_warning("[user] bashes [src]!"), \
span_warning("You bash [src]!"))
playsound(src, bashsound, 100, TRUE)
/obj/structure/window/attack_paw(mob/user, list/modifiers)
@@ -186,36 +186,36 @@
if(!I.tool_start_check(user, amount = 0))
return
to_chat(user, "<span class='notice'>You begin repairing [src]...</span>")
to_chat(user, span_notice("You begin repairing [src]..."))
if(I.use_tool(src, user, 40, volume = 50))
obj_integrity = max_integrity
update_nearby_icons()
to_chat(user, "<span class='notice'>You repair [src].</span>")
to_chat(user, span_notice("You repair [src]."))
else
to_chat(user, "<span class='warning'>[src] is already in good condition!</span>")
to_chat(user, span_warning("[src] is already in good condition!"))
return
if(!(flags_1&NODECONSTRUCT_1) && !(reinf && state >= RWINDOW_FRAME_BOLTED))
if(I.tool_behaviour == TOOL_SCREWDRIVER)
to_chat(user, "<span class='notice'>You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor...</span>")
to_chat(user, span_notice("You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor..."))
if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored)))
set_anchored(!anchored)
to_chat(user, "<span class='notice'>You [anchored ? "fasten the window to":"unfasten the window from"] the floor.</span>")
to_chat(user, span_notice("You [anchored ? "fasten the window to":"unfasten the window from"] the floor."))
return
else if(I.tool_behaviour == TOOL_WRENCH && !anchored)
to_chat(user, "<span class='notice'>You begin to disassemble [src]...</span>")
to_chat(user, span_notice("You begin to disassemble [src]..."))
if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount)
G.add_fingerprint(user)
playsound(src, 'sound/items/Deconstruct.ogg', 50, TRUE)
to_chat(user, "<span class='notice'>You successfully disassemble [src].</span>")
to_chat(user, span_notice("You successfully disassemble [src]."))
qdel(src)
return
else if(I.tool_behaviour == TOOL_CROWBAR && reinf && (state == WINDOW_OUT_OF_FRAME) && anchored)
to_chat(user, "<span class='notice'>You begin to lever the window into the frame...</span>")
to_chat(user, span_notice("You begin to lever the window into the frame..."))
if(I.use_tool(src, user, 100, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
state = RWINDOW_SECURE
to_chat(user, "<span class='notice'>You pry the window into the frame.</span>")
to_chat(user, span_notice("You pry the window into the frame."))
return
return ..()
@@ -282,13 +282,13 @@
/obj/structure/window/proc/can_be_rotated(mob/user,rotation_type)
if(anchored)
to_chat(user, "<span class='warning'>[src] cannot be rotated while it is fastened to the floor!</span>")
to_chat(user, span_warning("[src] cannot be rotated while it is fastened to the floor!"))
return FALSE
var/target_dir = turn(dir, rotation_type == ROTATION_CLOCKWISE ? -90 : 90)
if(!valid_window_location(loc, target_dir, is_fulltile = fulltile))
to_chat(user, "<span class='warning'>[src] cannot be rotated in that direction!</span>")
to_chat(user, span_warning("[src] cannot be rotated in that direction!"))
return FALSE
return TRUE
@@ -401,76 +401,76 @@
if(tool.tool_behaviour == TOOL_WELDER)
var/obj/item/weldingtool/welder = tool
if(welder.isOn())
user.visible_message("<span class='notice'>[user] holds \the [tool] to the security screws on \the [src]...</span>",
"<span class='notice'>You begin heating the security screws on \the [src]...</span>")
user.visible_message(span_notice("[user] holds \the [tool] to the security screws on \the [src]..."),
span_notice("You begin heating the security screws on \the [src]..."))
if(tool.use_tool(src, user, 150, volume = 100))
to_chat(user, "<span class='notice'>The security screws are glowing white hot and look ready to be removed.</span>")
to_chat(user, span_notice("The security screws are glowing white hot and look ready to be removed."))
state = RWINDOW_BOLTS_HEATED
addtimer(CALLBACK(src, .proc/cool_bolts), 300)
else if (tool.tool_behaviour)
to_chat(user, "<span class='warning'>The security screws need to be heated first!</span>")
to_chat(user, span_warning("The security screws need to be heated first!"))
if(RWINDOW_BOLTS_HEATED)
if(tool.tool_behaviour == TOOL_SCREWDRIVER)
user.visible_message("<span class='notice'>[user] digs into the heated security screws and starts removing them...</span>",
"<span class='notice'>You dig into the heated screws hard and they start turning...</span>")
user.visible_message(span_notice("[user] digs into the heated security screws and starts removing them..."),
span_notice("You dig into the heated screws hard and they start turning..."))
if(tool.use_tool(src, user, 50, volume = 50))
state = RWINDOW_BOLTS_OUT
to_chat(user, "<span class='notice'>The screws come out, and a gap forms around the edge of the pane.</span>")
to_chat(user, span_notice("The screws come out, and a gap forms around the edge of the pane."))
else if (tool.tool_behaviour)
to_chat(user, "<span class='warning'>The security screws need to be removed first!</span>")
to_chat(user, span_warning("The security screws need to be removed first!"))
if(RWINDOW_BOLTS_OUT)
if(tool.tool_behaviour == TOOL_CROWBAR)
user.visible_message("<span class='notice'>[user] wedges \the [tool] into the gap in the frame and starts prying...</span>",
"<span class='notice'>You wedge \the [tool] into the gap in the frame and start prying...</span>")
user.visible_message(span_notice("[user] wedges \the [tool] into the gap in the frame and starts prying..."),
span_notice("You wedge \the [tool] into the gap in the frame and start prying..."))
if(tool.use_tool(src, user, 40, volume = 50))
state = RWINDOW_POPPED
to_chat(user, "<span class='notice'>The panel pops out of the frame, exposing some thin metal bars that looks like they can be cut.</span>")
to_chat(user, span_notice("The panel pops out of the frame, exposing some thin metal bars that looks like they can be cut."))
else if (tool.tool_behaviour)
to_chat(user, "<span class='warning'>The gap needs to be pried first!</span>")
to_chat(user, span_warning("The gap needs to be pried first!"))
if(RWINDOW_POPPED)
if(tool.tool_behaviour == TOOL_WIRECUTTER)
user.visible_message("<span class='notice'>[user] starts cutting the exposed bars on \the [src]...</span>",
"<span class='notice'>You start cutting the exposed bars on \the [src]</span>")
user.visible_message(span_notice("[user] starts cutting the exposed bars on \the [src]..."),
span_notice("You start cutting the exposed bars on \the [src]"))
if(tool.use_tool(src, user, 20, volume = 50))
state = RWINDOW_BARS_CUT
to_chat(user, "<span class='notice'>The panels falls out of the way exposing the frame bolts.</span>")
to_chat(user, span_notice("The panels falls out of the way exposing the frame bolts."))
else if (tool.tool_behaviour)
to_chat(user, "<span class='warning'>The bars need to be cut first!</span>")
to_chat(user, span_warning("The bars need to be cut first!"))
if(RWINDOW_BARS_CUT)
if(tool.tool_behaviour == TOOL_WRENCH)
user.visible_message("<span class='notice'>[user] starts unfastening \the [src] from the frame...</span>",
"<span class='notice'>You start unfastening the bolts from the frame...</span>")
user.visible_message(span_notice("[user] starts unfastening \the [src] from the frame..."),
span_notice("You start unfastening the bolts from the frame..."))
if(tool.use_tool(src, user, 40, volume = 50))
to_chat(user, "<span class='notice'>You unscrew the bolts from the frame and the window pops loose.</span>")
to_chat(user, span_notice("You unscrew the bolts from the frame and the window pops loose."))
state = WINDOW_OUT_OF_FRAME
set_anchored(FALSE)
else if (tool.tool_behaviour)
to_chat(user, "<span class='warning'>The bolts need to be loosened first!</span>")
to_chat(user, span_warning("The bolts need to be loosened first!"))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/obj/structure/window/proc/cool_bolts()
if(state == RWINDOW_BOLTS_HEATED)
state = RWINDOW_SECURE
visible_message("<span class='notice'>The bolts on \the [src] look like they've cooled off...</span>")
visible_message(span_notice("The bolts on \the [src] look like they've cooled off..."))
/obj/structure/window/reinforced/examine(mob/user)
. = ..()
switch(state)
if(RWINDOW_SECURE)
. += "<span class='notice'>It's been screwed in with one way screws, you'd need to <b>heat them</b> to have any chance of backing them out.</span>"
. += span_notice("It's been screwed in with one way screws, you'd need to <b>heat them</b> to have any chance of backing them out.")
if(RWINDOW_BOLTS_HEATED)
. += "<span class='notice'>The screws are glowing white hot, and you'll likely be able to <b>unscrew them</b> now.</span>"
. += span_notice("The screws are glowing white hot, and you'll likely be able to <b>unscrew them</b> now.")
if(RWINDOW_BOLTS_OUT)
. += "<span class='notice'>The screws have been removed, revealing a small gap you could fit a <b>prying tool</b> in.</span>"
. += span_notice("The screws have been removed, revealing a small gap you could fit a <b>prying tool</b> in.")
if(RWINDOW_POPPED)
. += "<span class='notice'>The main plate of the window has popped out of the frame, exposing some bars that look like they can be <b>cut</b>.</span>"
. += span_notice("The main plate of the window has popped out of the frame, exposing some bars that look like they can be <b>cut</b>.")
if(RWINDOW_BARS_CUT)
. += "<span class='notice'>The main pane can be easily moved out of the way to reveal some <b>bolts</b> holding the frame in.</span>"
. += span_notice("The main pane can be easily moved out of the way to reveal some <b>bolts</b> holding the frame in.")
/obj/structure/window/reinforced/spawner/east
dir = EAST
@@ -542,43 +542,43 @@
switch(state)
if(RWINDOW_SECURE)
if(I.tool_behaviour == TOOL_WELDER && user.combat_mode)
user.visible_message("<span class='notice'>[user] holds \the [I] to the security screws on \the [src]...</span>",
"<span class='notice'>You begin heating the security screws on \the [src]...</span>")
user.visible_message(span_notice("[user] holds \the [I] to the security screws on \the [src]..."),
span_notice("You begin heating the security screws on \the [src]..."))
if(I.use_tool(src, user, 180, volume = 100))
to_chat(user, "<span class='notice'>The security screws are glowing white hot and look ready to be removed.</span>")
to_chat(user, span_notice("The security screws are glowing white hot and look ready to be removed."))
state = RWINDOW_BOLTS_HEATED
addtimer(CALLBACK(src, .proc/cool_bolts), 300)
return
if(RWINDOW_BOLTS_HEATED)
if(I.tool_behaviour == TOOL_SCREWDRIVER)
user.visible_message("<span class='notice'>[user] digs into the heated security screws and starts removing them...</span>",
"<span class='notice'>You dig into the heated screws hard and they start turning...</span>")
user.visible_message(span_notice("[user] digs into the heated security screws and starts removing them..."),
span_notice("You dig into the heated screws hard and they start turning..."))
if(I.use_tool(src, user, 80, volume = 50))
state = RWINDOW_BOLTS_OUT
to_chat(user, "<span class='notice'>The screws come out, and a gap forms around the edge of the pane.</span>")
to_chat(user, span_notice("The screws come out, and a gap forms around the edge of the pane."))
return
if(RWINDOW_BOLTS_OUT)
if(I.tool_behaviour == TOOL_CROWBAR)
user.visible_message("<span class='notice'>[user] wedges \the [I] into the gap in the frame and starts prying...</span>",
"<span class='notice'>You wedge \the [I] into the gap in the frame and start prying...</span>")
user.visible_message(span_notice("[user] wedges \the [I] into the gap in the frame and starts prying..."),
span_notice("You wedge \the [I] into the gap in the frame and start prying..."))
if(I.use_tool(src, user, 50, volume = 50))
state = RWINDOW_POPPED
to_chat(user, "<span class='notice'>The panel pops out of the frame, exposing some thin metal bars that looks like they can be cut.</span>")
to_chat(user, span_notice("The panel pops out of the frame, exposing some thin metal bars that looks like they can be cut."))
return
if(RWINDOW_POPPED)
if(I.tool_behaviour == TOOL_WIRECUTTER)
user.visible_message("<span class='notice'>[user] starts cutting the exposed bars on \the [src]...</span>",
"<span class='notice'>You start cutting the exposed bars on \the [src]</span>")
user.visible_message(span_notice("[user] starts cutting the exposed bars on \the [src]..."),
span_notice("You start cutting the exposed bars on \the [src]"))
if(I.use_tool(src, user, 30, volume = 50))
state = RWINDOW_BARS_CUT
to_chat(user, "<span class='notice'>The panels falls out of the way exposing the frame bolts.</span>")
to_chat(user, span_notice("The panels falls out of the way exposing the frame bolts."))
return
if(RWINDOW_BARS_CUT)
if(I.tool_behaviour == TOOL_WRENCH)
user.visible_message("<span class='notice'>[user] starts unfastening \the [src] from the frame...</span>",
"<span class='notice'>You start unfastening the bolts from the frame...</span>")
user.visible_message(span_notice("[user] starts unfastening \the [src] from the frame..."),
span_notice("You start unfastening the bolts from the frame..."))
if(I.use_tool(src, user, 50, volume = 50))
to_chat(user, "<span class='notice'>You unfasten the bolts from the frame and the window pops loose.</span>")
to_chat(user, span_notice("You unfasten the bolts from the frame and the window pops loose."))
state = WINDOW_OUT_OF_FRAME
set_anchored(FALSE)
return
@@ -588,15 +588,15 @@
. = ..()
switch(state)
if(RWINDOW_SECURE)
. += "<span class='notice'>It's been screwed in with one way screws, you'd need to <b>heat them</b> to have any chance of backing them out.</span>"
. += span_notice("It's been screwed in with one way screws, you'd need to <b>heat them</b> to have any chance of backing them out.")
if(RWINDOW_BOLTS_HEATED)
. += "<span class='notice'>The screws are glowing white hot, and you'll likely be able to <b>unscrew them</b> now.</span>"
. += span_notice("The screws are glowing white hot, and you'll likely be able to <b>unscrew them</b> now.")
if(RWINDOW_BOLTS_OUT)
. += "<span class='notice'>The screws have been removed, revealing a small gap you could fit a <b>prying tool</b> in.</span>"
. += span_notice("The screws have been removed, revealing a small gap you could fit a <b>prying tool</b> in.")
if(RWINDOW_POPPED)
. += "<span class='notice'>The main plate of the window has popped out of the frame, exposing some bars that look like they can be <b>cut</b>.</span>"
. += span_notice("The main plate of the window has popped out of the frame, exposing some bars that look like they can be <b>cut</b>.")
if(RWINDOW_BARS_CUT)
. += "<span class='notice'>The main pane can be easily moved out of the way to reveal some <b>bolts</b> holding the frame in.</span>"
. += span_notice("The main pane can be easily moved out of the way to reveal some <b>bolts</b> holding the frame in.")
/obj/structure/window/plasma/reinforced/spawner/east
dir = EAST
@@ -792,7 +792,7 @@
/obj/structure/window/paperframe/examine(mob/user)
. = ..()
if(obj_integrity < max_integrity)
. += "<span class='info'>It looks a bit damaged, you may be able to fix it with some <b>paper</b>.</span>"
. += span_info("It looks a bit damaged, you may be able to fix it with some <b>paper</b>.")
/obj/structure/window/paperframe/spawnDebris(location)
. = list(new /obj/item/stack/sheet/mineral/wood(location))
@@ -828,11 +828,11 @@
if(user.combat_mode)
return ..()
if(istype(W, /obj/item/paper) && obj_integrity < max_integrity)
user.visible_message("<span class='notice'>[user] starts to patch the holes in \the [src].</span>")
user.visible_message(span_notice("[user] starts to patch the holes in \the [src]."))
if(do_after(user, 20, target = src))
obj_integrity = min(obj_integrity+4,max_integrity)
qdel(W)
user.visible_message("<span class='notice'>[user] patches some of the holes in \the [src].</span>")
user.visible_message(span_notice("[user] patches some of the holes in \the [src]."))
if(obj_integrity == max_integrity)
update_appearance()
return