Skip to content

Commit

Permalink
TGUI Guild (Part 2) (sojourn-13#5297)
Browse files Browse the repository at this point in the history
* Fix the gitignore

* TGUI Smelter

* Convert port_gen (PACMAN, Diesel Gen, And Such)

* TGUI wires

* Refactor smartfridge and TGUIifiy

* Add a warning if an asset file is completely empty

* Add a warning if an asset cache item is empty

* Fix a number of bugs with tank dispenser attackby()

* Fix all the crafting station recipe names to reflect what they spit out

* Fix point calculation problem and display points

* Only show points if the user has PERK_NO_OBFUSCATION

* Add a ~~toaster~~ performance mode to TGUI

* Fix wires UI runtiming and breaking if there are any fake wires

* TGUI Fire Alarm

* Convert hydroelectric turbines to TGUI
  • Loading branch information
ShadowLarkens authored May 21, 2024
1 parent 846bd36 commit 99284f0
Show file tree
Hide file tree
Showing 55 changed files with 3,672 additions and 1,138 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,3 @@ aux*.pdb

# Screenshot tests
/artifacts

tgui/public/
16 changes: 16 additions & 0 deletions code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,19 @@
}\
A.flags &= ~OVERLAY_QUEUED;\
} while (FALSE)

#define LIST_COLOR_RENAME \
list( \
"rebeccapurple" = "dark purple",\
"darkslategrey" = "dark grey", \
"darkolivegreen"= "dark green", \
"darkslateblue" = "dark blue", \
"darkkhaki" = "khaki", \
"darkseagreen" = "light green",\
"midnightblue" = "blue", \
"lightgrey" = "light grey", \
"darkgrey" = "dark grey", \
"darkmagenta" = "dark magenta",\
"steelblue" = "blue", \
"goldenrod" = "gold" \
)
27 changes: 27 additions & 0 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,33 @@ proc/get_average_color(var/icon, var/icon_state, var/image_dir)
dummySave = null
fdel("tmp/dummySave.sav") //if you get the idea to try and make this more optimized, make sure to still call unlock on the savefile after every write to unlock it.

/proc/icon2base64tgui(thing)
var/static/list/bicon_cache = list()

ASSERT(thing)

if(ispath(thing))
var/atom/A = thing
var/key = "[initial(A.icon)]:[initial(A.icon_state)]"
var/cached = bicon_cache[key]

if(!cached)
bicon_cache[key] = cached = icon2base64(path2icon(A))

return "data:image/png;base64,[cached]"

if(isicon(thing))
var/key = REF(thing)
var/cached = bicon_cache[key]

if(!cached)
bicon_cache[key] = cached = icon2base64(thing)

return "data:image/png;base64,[cached]"

CRASH("[thing] must be a path or an icon")


/proc/icon2html(thing, target, icon_state, dir = SOUTH, frame = 1, moving = FALSE, sourceonly = FALSE, extra_classes = null)
if (!thing)
return
Expand Down
3 changes: 3 additions & 0 deletions code/datums/craft/menu.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
tgui_id = "CraftMenu"

/datum/tgui_module/craft/ui_assets(mob/user)
if(user?.client?.get_preference_value(/datum/client_preference/tgui_toaster) == GLOB.PREF_YES)
return list()

return list(
get_asset_datum(/datum/asset/simple/craft),
get_asset_datum(/datum/asset/simple/materials),
Expand Down
22 changes: 10 additions & 12 deletions code/datums/wires/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,18 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
return 1
return 0

/datum/wires/airlock/GetInteractWindow(mob/living/user)
/datum/wires/airlock/get_status(mob/living/user)
var/obj/machinery/door/airlock/A = holder
var/haspower = A.arePowerSystemsOn() //If there's no power, then no lights will be on.

. += ..(user)
. += text("<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]",
(A.locked ? "The door bolts have fallen!" : "The door bolts look up."),
((A.lights && haspower) ? "The door bolt lights are on." : "The door bolt lights are off!"),
((haspower) ? "The test light is on." : "The test light is off!"),
((A.backup_power_lost_until) ? "The backup power light is off!" : "The backup power light is on."),
((A.aiControlDisabled==0 && !A.emagged && haspower)? "The 'AI control allowed' light is on." : "The 'AI control allowed' light is off."),
((A.safe==0 && haspower)? "The 'Check Wiring' light is on." : "The 'Check Wiring' light is off."),
((A.normalspeed==0 && haspower)? "The 'Check Timing Mechanism' light is on." : "The 'Check Timing Mechanism' light is off."),
((A.aiDisabledIdScanner==0 && haspower)? "The IDScan light is on." : "The IDScan light is off."))
. = ..()
. += "The door bolts [A.locked ? "have fallen!" : "look up."]"
. += "The door bolt lights are [(A.lights && haspower) ? "on." : "off!"]"
. += "The test light is [haspower ? "on." : "off!"]"
. += "The backup power light is [A.backup_power_lost_until ? "off!" : "on."]"
. += "The 'AI control allowed' light is [(A.aiControlDisabled == 0 && !A.emagged && haspower) ? "on" : "off"]."
. += "The 'Check Wiring' light is [(A.safe == 0 && haspower) ? "on" : "off"]."
. += "The 'Check Timing Mechanism' light is [(A.normalspeed == 0 && haspower) ? "on" : "off"]."
. += "The IDScan light is [(A.aiDisabledIdScanner == 0 && haspower) ? "on" : "off."]"

/datum/wires/airlock/UpdateCut(var/index, var/mended)

Expand Down
8 changes: 5 additions & 3 deletions code/datums/wires/alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ var/const/AALARM_WIRE_AALARM = 16
return 1
return 0

/datum/wires/alarm/GetInteractWindow(mob/living/user)
/datum/wires/alarm/get_status(mob/living/user)
var/obj/machinery/alarm/A = holder
. += ..(user)
. += text("<br>\n[(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")]<br>\n[((A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")]<br>\n[(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")
. = ..()
. += "The Air Alarm is [A.locked ? "locked." : "unlocked."]"
. += "The Air Alarm is [(A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "offline." : "working properly!"]"
. += "The 'AI control allowed' light is [A.aidisabled ? "off" : "on"]."

/datum/wires/alarm/UpdateCut(var/index, var/mended)
var/obj/machinery/alarm/A = holder
Expand Down
9 changes: 5 additions & 4 deletions code/datums/wires/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
new /datum/wire_description(APC_WIRE_AI_CONTROL, "Remote access")
)

/datum/wires/apc/GetInteractWindow(mob/living/user)
/datum/wires/apc/get_status(mob/living/user)
var/obj/machinery/power/apc/A = holder
. += ..(user)
. += text("<br>\n[(A.locked ? "The APC is locked." : "The APC is unlocked.")]<br>\n[(A.shorted ? "The power wire of the APC has been shorted." : "The APC is working properly!")]<br>\n[(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")

. = ..()
. += "The APC is [A.locked ? "" : "un"]locked."
. += A.shorted ? "The APCs power has been shorted." : "The APC is working properly!"
. += "The 'AI control allowed' light is [A.aidisabled ? "off" : "on"]."

/datum/wires/apc/CanUse(var/mob/living/L)
var/obj/machinery/power/apc/A = holder
Expand Down
10 changes: 5 additions & 5 deletions code/datums/wires/autolathe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ var/const/AUTOLATHE_HACK_WIRE = 1
var/const/AUTOLATHE_SHOCK_WIRE = 2
var/const/AUTOLATHE_DISABLE_WIRE = 4

/datum/wires/autolathe/GetInteractWindow(mob/living/user)
/datum/wires/autolathe/get_status(mob/living/user)
var/obj/machinery/autolathe/A = holder
. += ..(user)
. += "<BR>The red light is [A.disabled ? "off" : "on"]."
. += "<BR>The green light is [A.shocked ? "off" : "on"]."
. += "<BR>The blue light is [A.hacked ? "off" : "on"].<BR>"
. = ..()
. += "The red light is [A.disabled ? "off" : "on"]."
. += "The green light is [A.shocked ? "off" : "on"]."
. += "The blue light is [A.hacked ? "off" : "on"]."

/datum/wires/autolathe/CanUse()
var/obj/machinery/autolathe/A = holder
Expand Down
14 changes: 6 additions & 8 deletions code/datums/wires/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
new /datum/wire_description(CAMERA_WIRE_ALARM, "Alarm")
)

/datum/wires/camera/GetInteractWindow(mob/living/user)

. = ..(user)
/datum/wires/camera/get_status(mob/living/user)
var/obj/machinery/camera/C = holder
. += "<br>\n[(C.view_range == initial(C.view_range) ? "The focus light is on." : "The focus light is off.")]"
. += "<br>\n[(C.can_use() ? "The power link light is on." : "The power link light is off.")]"
. += "<br>\n[(C.light_disabled ? "The camera light is off." : "The camera light is on.")]"
. += "<br>\n[(C.alarm_on ? "The alarm light is on." : "The alarm light is off.")]"
return .
. = ..()
. += "The focus light is [(C.view_range == initial(C.view_range)) ? "on" : "off"]."
. += "The power link light is [C.can_use() ? "on" : "off"]."
. += "The camera light is [C.light_disabled ? "off" : "on"]."
. += "The alarm light is [C.alarm_on ? "on" : "off"]."

/datum/wires/camera/CanUse(var/mob/living/L)
var/obj/machinery/camera/C = holder
Expand Down
10 changes: 5 additions & 5 deletions code/datums/wires/jukebox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
return FALSE

// Show the status of lights as a hint to the current state
/datum/wires/jukebox/GetInteractWindow(mob/living/user)
/datum/wires/jukebox/get_status(mob/living/user)
var/obj/machinery/media/jukebox/A = holder
. = ..(user)
. += "<br>\n The power light is [A.stat & (BROKEN|NOPOWER) ? "off." : "on."]"
. += "<br>\n The parental guidance light is [A.hacked ? "off." : "on."]"
. += "<br>\n The data light is [IsIndexCut(WIRE_REVERSE) ? "hauntingly dark." : "glowing softly."]"
. = ..()
. += "The power light is [A.stat & (BROKEN|NOPOWER) ? "off." : "on."]"
. += "The parental guidance light is [A.hacked ? "off." : "on."]"
. += "The data light is [IsIndexCut(WIRE_REVERSE) ? "hauntingly dark." : "glowing softly."]"

// Give a hint as to what each wire does
/datum/wires/jukebox/UpdatePulsed(wire)
Expand Down
31 changes: 31 additions & 0 deletions code/datums/wires/mulebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ var/const/WIRE_BEACON_RX = 256 // beacon ping recv
var/obj/machinery/bot/mulebot/M = holder
M.interact(user)

/datum/wires/mulebot/proc/GetInteractWindow(mob/living/user)
var/user_skill
var/html = "<div class='block'>"
html += "<h3>Exposed Wires</h3>"
html += "<table[table_options]>"

if(!user)
user = usr

if(istype(user))
user_skill = user.stats.getStat(STAT_MEC)

for(var/colour in wires)
html += "<tr>"
var/datum/wire_description/wd = get_description(GetIndex(colour))
if(wd)
if(user.stats && user.stats.getPerk(PERK_HANDYMAN) || user_skill && (wd.skill_level <= user_skill))
html += "<td[row_options1]><font color='[colour]'>[wd.description]</font></td>"
else
html += "<td[row_options1]><font color='[colour]'>[capitalize(colour)]</font></td>"
else
html += "<td[row_options1]><font color='[colour]'>[capitalize(colour)]</font></td>"
html += "<td[row_options2]>"
html += "<A href='?src=\ref[src];action=1;cut=[colour]'>[IsColourCut(colour) ? "Mend" : "Cut"]</A>"
html += " <A href='?src=\ref[src];action=1;pulse=[colour]'>Pulse</A>"
html += " <A href='?src=\ref[src];action=1;attach=[colour]'>[IsAttached(colour) ? "Detach" : "Attach"] Signaller</A>"
html += "</table>"
html += "</div>"

return html

/datum/wires/mulebot/UpdatePulsed(var/index)
switch(index)
if(WIRE_POWER1, WIRE_POWER2)
Expand Down
10 changes: 5 additions & 5 deletions code/datums/wires/nuclearbomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ var/const/NUCLEARBOMB_WIRE_SAFETY = 4
var/obj/machinery/nuclearbomb/N = holder
return N.panel_open

/datum/wires/nuclearbomb/GetInteractWindow(mob/living/user)
/datum/wires/nuclearbomb/get_status(mob/living/user)
var/obj/machinery/nuclearbomb/N = holder
. += ..(user)
. += "<BR>The device is [N.timing ? "shaking!" : "still."]<BR>"
. += "The device is is [N.safety ? "quiet" : "whirring"].<BR>"
. += "The lights are [N.lighthack ? "static" : "functional"].<BR>"
. = ..()
. += "The device is [N.timing ? "shaking!" : "still."]"
. += "The device is is [N.safety ? "quiet" : "whirring"]."
. += "The lights are [N.lighthack ? "static" : "functional"]."

/datum/wires/nuclearbomb/UpdatePulsed(var/index)
var/obj/machinery/nuclearbomb/N = holder
Expand Down
14 changes: 7 additions & 7 deletions code/datums/wires/recycle_vendor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ var/const/VENDING_WIRE_SPEAKER = 2
if(V.panel_open)
return TRUE

/datum/wires/recycle_vendor/GetInteractWindow(mob/living/user)
/datum/wires/recycle_vendor/get_status(mob/living/user)
var/obj/machinery/recycle_vendor/V = holder
. += ..(user)
. += "<BR>The orange light is [BITTEST(V.wire_flags, WIRE_SHOCK) ? "off" : "on"].<BR>"
. += "The red light is [BITTEST(V.wire_flags, WIRE_THROW) ? "off" : "blinking"].<BR>"
. += "The green light is [BITTEST(V.wire_flags, WIRE_SPEAKER) ? "on" : "off"].<BR>"
. += "The [BITTEST(V.wire_flags, WIRE_ID_SCAN) ? "purple" : "yellow"] light is on.<BR>"
. = ..()
. += "The orange light is [BITTEST(V.wire_flags, WIRE_SHOCK) ? "off" : "on"]."
. += "The red light is [BITTEST(V.wire_flags, WIRE_THROW) ? "off" : "blinking"]."
. += "The green light is [BITTEST(V.wire_flags, WIRE_SPEAKER) ? "on" : "off"]."
. += "The [BITTEST(V.wire_flags, WIRE_ID_SCAN) ? "purple" : "yellow"] light is on."

/datum/wires/recycle_vendor/UpdatePulsed(index)
var/obj/machinery/recycle_vendor/V = holder
Expand All @@ -51,4 +51,4 @@ var/const/VENDING_WIRE_SPEAKER = 2
if(VENDING_WIRE_ELECTRIFY)
mended ? (BITRESET(V.wire_flags, WIRE_SHOCK)) : (BITSET(V.wire_flags, WIRE_SHOCK))
if(VENDING_WIRE_IDSCAN)
mended ? (BITRESET(V.wire_flags, WIRE_ID_SCAN)) : (BITSET(V.wire_flags, WIRE_ID_SCAN))
mended ? (BITRESET(V.wire_flags, WIRE_ID_SCAN)) : (BITSET(V.wire_flags, WIRE_ID_SCAN))
14 changes: 6 additions & 8 deletions code/datums/wires/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ var/const/BORG_WIRE_LOCKED_DOWN = 4
var/const/BORG_WIRE_AI_CONTROL = 8
var/const/BORG_WIRE_CAMERA = 16

/datum/wires/robot/GetInteractWindow(mob/living/user)

. = ..(user)
/datum/wires/robot/get_status(mob/living/user)
var/mob/living/silicon/robot/R = holder
. += text("<br>\n[(R.lawupdate ? "The LawSync light is on." : "The LawSync light is off.")]")
. += text("<br>\n[(R.connected_ai ? "The AI link light is on." : "The AI link light is off.")]")
. += text("<br>\n[((!isnull(R.camera) && R.camera.status == 1) ? "The Camera light is on." : "The Camera light is off.")]")
. += text("<br>\n[(R.lockcharge ? "The lockdown light is on." : "The lockdown light is off.")]")
return .
. = ..()
. += "The LawSync light is [R.lawupdate ? "on" : "off"]."
. += "The AI link light is [R.connected_ai ? "on" : "off"]."
. += "The Camera light is [(R.camera && R.camera.status == 1) ? "on" : "off"]."
. += "The lockdown light is [R.lockcharge ? "on" : "off"]."

/datum/wires/robot/UpdateCut(var/index, var/mended)

Expand Down
10 changes: 5 additions & 5 deletions code/datums/wires/smartfridge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ var/const/SMARTFRIDGE_WIRE_IDSCAN = 4
return 1
return 0

/datum/wires/smartfridge/GetInteractWindow(mob/living/user)
/datum/wires/smartfridge/get_status(mob/living/user)
var/obj/machinery/smartfridge/S = holder
. += ..(user)
. += "<BR>The orange light is [S.seconds_electrified ? "off" : "on"].<BR>"
. += "The red light is [S.shoot_inventory ? "off" : "blinking"].<BR>"
. += "A [S.scan_id ? "purple" : "yellow"] light is on.<BR>"
. = ..()
. += "<BR>The orange light is [S.seconds_electrified ? "off" : "on"]."
. += "The red light is [S.shoot_inventory ? "off" : "blinking"]."
. += "A [S.scan_id ? "purple" : "yellow"] light is on."

/datum/wires/smartfridge/UpdatePulsed(var/index)
var/obj/machinery/smartfridge/S = holder
Expand Down
11 changes: 5 additions & 6 deletions code/datums/wires/smes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ var/const/SMES_WIRE_FAILSAFES = 16 // Cut to disable failsafes, mend to reenable
return 1
return 0


/datum/wires/smes/GetInteractWindow(mob/living/user)
/datum/wires/smes/get_status(mob/living/user)
var/obj/machinery/power/smes/buildable/S = holder
. += ..(user)
. += "The green light is [(S.input_cut || S.input_pulsed || S.output_cut || S.output_pulsed) ? "off" : "on"]<br>"
. += "The red light is [(S.safeties_enabled || S.grounding) ? "off" : "blinking"]<br>"
. = ..()
. += "The green light is [(S.input_cut || S.input_pulsed || S.output_cut || S.output_pulsed) ? "off" : "on"]"
. += "The red light is [(S.safeties_enabled || S.grounding) ? "off" : "blinking"]"
. += "The blue light is [S.RCon ? "on" : "off"]"


Expand Down Expand Up @@ -64,4 +63,4 @@ var/const/SMES_WIRE_FAILSAFES = 16 // Cut to disable failsafes, mend to reenable
if(S.safeties_enabled)
S.safeties_enabled = 0
spawn(10)
S.safeties_enabled = 1
S.safeties_enabled = 1
10 changes: 5 additions & 5 deletions code/datums/wires/suit_storage_unit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ var/const/SUIT_STORAGE_WIRE_LOCKED = 4
return 1
return 0

/datum/wires/suit_storage_unit/GetInteractWindow(mob/living/user)
/datum/wires/suit_storage_unit/get_status(mob/living/user)
var/obj/machinery/suit_storage_unit/S = holder
. += ..(user)
. += "<BR>The orange light is [S.electrified ? "off" : "on"].<BR>"
. += "The red light is [S.safeties ? "off" : "blinking"].<BR>"
. += "The yellow light is [S.locked ? "on" : "off"].<BR>"
. = ..()
. += "The orange light is [S.electrified ? "off" : "on"]."
. += "The red light is [S.safeties ? "off" : "blinking"]."
. += "The yellow light is [S.locked ? "on" : "off"]."

/datum/wires/suit_storage_unit/UpdatePulsed(var/index)
var/obj/machinery/suit_storage_unit/S = holder
Expand Down
20 changes: 10 additions & 10 deletions code/datums/wires/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ var/const/VENDING_WIRE_IDSCAN = 8
return 1
return 0

/datum/wires/vending/GetInteractWindow(mob/living/user)
/datum/wires/vending/get_status(mob/living/user)
var/obj/machinery/vending/V = holder
. += ..(user)
. += "<BR>The orange light is [V.seconds_electrified ? "off" : "on"].<BR>"
. += "The red light is [V.shoot_inventory ? "off" : "blinking"].<BR>"
. += "The green light is [(V.categories & CAT_HIDDEN) ? "on" : "off"].<BR>"
. += "The [V.scan_id ? "purple" : "yellow"] light is on.<BR>"
. = ..()
. += "The orange light is [V.seconds_electrified ? "off" : "on"]."
. += "The red light is [V.shoot_inventory ? "off" : "blinking"]."
. += "The green light is [(V.categories & CAT_HIDDEN) ? "on" : "off"]."
. += "The [V.scan_id ? "purple" : "yellow"] light is on."

/datum/wires/vending/UpdatePulsed(var/index)
var/obj/machinery/vending/V = holder
Expand Down Expand Up @@ -113,10 +113,10 @@ var/const/VENDING_INT_WIRE_POWER = 64
new /datum/wire_description(VENDING_INT_WIRE_POWER, "Power")
)

/datum/wires/vending/intermediate/GetInteractWindow(mob/living/user)
. += ..(user)
. += "The [is_signal_securely_cut ? "blue" : "pink"] light is on.<BR>"
. += "The suspicious light is [is_contraband_securely_pulsed ? "blinking" : "on"].<BR>"
/datum/wires/vending/intermediate/get_status(mob/living/user)
. = ..()
. += "The [is_signal_securely_cut ? "blue" : "pink"] light is on."
. += "The suspicious light is [is_contraband_securely_pulsed ? "blinking" : "on"]."

/datum/wires/vending/intermediate/UpdatePulsed(var/index)
if(is_powered)
Expand Down
Loading

0 comments on commit 99284f0

Please sign in to comment.