Skip to content

Commit

Permalink
updateDialog and updateUsrDialog cleanup (tgstation#66494)
Browse files Browse the repository at this point in the history
This PR focuses on cleaning up two procs - updateDialog and updateUsrDialog. Both of which are/were used updating for old HTML UIs. As these UIs got converted to TGUI over time, these old code fragments started to pile up, often due to coders simply overlooking them. This resulted in them being dead code doing nothing when called, or randomly opening up windows when they shouldnt, for example when a vending machine is screwdrivered and UI cannot even be interacted with.

However, there were also some desirable uses - like opening a window when an ID is inserted into civilian bounty console, which you are then gonna obviously use to pick a bounty. I kept these uses and replaced them with proper ui_interact, so they now always work, instead of them working only when you had them set as a currently used machine on mob. The list of these changes is:

    Civilian Bounty Console will now always bring up its UI when you insert the ID.
    Air Alarm and APC will now always bring up its UI when you unlock their controls.
    Portable Chem Mixer, Chem Dispenser, Chem Heater, Improvised Chem Heater, Chem Spectometer and Chem Master will now always bring up their UI when you add or replace beaker to them.

Two old /Topic calls were cleaned up as well, as they were no longer relevant.

Removes dead or outdated code, adds sensible UX when working with certain UIs.
  • Loading branch information
Arkatos1 authored Apr 26, 2022
1 parent 8785478 commit b98d91c
Show file tree
Hide file tree
Showing 22 changed files with 17 additions and 84 deletions.
5 changes: 2 additions & 3 deletions code/game/machinery/civilian_bounties.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
inserted_scan_id = null
. = TRUE

///Self explanitory, holds the ID card inthe console for bounty payout and manipulation.
///Self explanitory, holds the ID card in the console for bounty payout and manipulation.
/obj/machinery/computer/piratepad_control/civilian/proc/id_insert(mob/user, obj/item/inserting_item, obj/item/target)
var/obj/item/card/id/card_to_insert = inserting_item
var/holder_item = FALSE
Expand All @@ -214,7 +214,7 @@
user.visible_message(span_notice("[user] inserts \the [card_to_insert] into \the [src]."),
span_notice("You insert \the [card_to_insert] into \the [src]."))
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
updateUsrDialog()
ui_interact(user)
return TRUE

///Removes A stored ID card.
Expand All @@ -230,7 +230,6 @@
span_notice("You get \the [target] from \the [src]."))
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
inserted_scan_id = null
updateUsrDialog()
return TRUE

///Upon completion of a civilian bounty, one of these is created. It is sold to cargo to give the cargo budget bounty money, and the person who completed it cash.
Expand Down
23 changes: 0 additions & 23 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,12 @@
if(secondsMainPowerLost>0)
if(!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2))
secondsMainPowerLost -= 1
updateDialog()
cont = TRUE
if(secondsBackupPowerLost>0)
if(!wires.is_cut(WIRE_BACKUP1) && !wires.is_cut(WIRE_BACKUP2))
secondsBackupPowerLost -= 1
updateDialog()
cont = TRUE
spawnPowerRestoreRunning = FALSE
updateDialog()
update_appearance()

/obj/machinery/door/airlock/proc/loseMainPower()
Expand Down Expand Up @@ -761,31 +758,11 @@
return

secondsElectrified--
updateDialog()
// This is to protect against changing to permanent, mid loop.
if(secondsElectrified == MACHINE_NOT_ELECTRIFIED)
set_electrified(MACHINE_NOT_ELECTRIFIED)
else
set_electrified(MACHINE_ELECTRIFIED_PERMANENT)
updateDialog()

/obj/machinery/door/airlock/Topic(href, href_list, nowindow = 0)
// If you add an if(..()) check you must first remove the var/nowindow parameter.
// Otherwise it will runtime with this kind of error: null.Topic()
if(!nowindow)
..()
if(!usr.canUseTopic(src) && !isAdminGhostAI(usr))
return
add_fingerprint(usr)

if((in_range(src, usr) && isturf(loc)) && panel_open)
usr.set_machine(src)

add_fingerprint(usr)
if(!nowindow)
updateUsrDialog()
else
updateDialog()

/obj/machinery/door/airlock/screwdriver_act(mob/living/user, obj/item/tool)
if(panel_open && detonated)
Expand Down
3 changes: 0 additions & 3 deletions code/game/machinery/gulag_teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ The console is located at computer/gulag_teleporter.dm
return
toggle_open()

/obj/machinery/gulag_teleporter/updateUsrDialog()
return

/obj/machinery/gulag_teleporter/attackby(obj/item/I, mob/user)
if(!occupant && default_deconstruction_screwdriver(user, "[icon_state]", "[icon_state]",I))
update_appearance()
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/launch_pad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@
log_msg += "nothing"
log_msg += " [sending ? "to" : "from"] [target_x], [target_y], [z] ([A ? A.name : "null area"])"
log_game(log_msg.Join())
updateDialog()

//Starts in the briefcase. Don't spawn this directly, or it will runtime when closing.
/obj/machinery/launchpad/briefcase
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/spaceheater.dm
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
return
replace_beaker(user, container)
to_chat(user, span_notice("You add [container] to [src]'s water bath."))
updateUsrDialog()
ui_interact(user)
return
//Dropper tools
if(beaker)
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/syndicatebomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@
holder.delayedlittle = FALSE
holder.explode_now = FALSE
holder.update_appearance()
holder.updateDialog()
STOP_PROCESSING(SSfastprocess, holder)

/obj/item/bombcore/training/detonate()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/portable_chem_mixer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
return
replace_beaker(user, B)
update_appearance()
updateUsrDialog()
ui_interact(user)
return
return ..()

Expand Down
3 changes: 2 additions & 1 deletion code/modules/atmospherics/machinery/airalarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,8 @@
if(src.allowed(usr) && !wires.is_cut(WIRE_IDSCAN))
locked = !locked
to_chat(user, span_notice("You [ locked ? "lock" : "unlock"] the air alarm interface."))
updateUsrDialog()
if(!locked)
ui_interact(user)
else
to_chat(user, span_danger("Access denied."))
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
..()
if(A == beaker)
beaker = null
updateUsrDialog()

/obj/machinery/atmospherics/components/unary/cryo_cell/on_deconstruction()
if(beaker)
Expand Down
1 change: 0 additions & 1 deletion code/modules/hydroponics/seed_extractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
else if (istype(O, /obj/item/seeds))
if(add_seed(O))
to_chat(user, span_notice("You add [O] to [src.name]."))
updateUsrDialog()
return
else if(!user.combat_mode)
to_chat(user, span_warning("You can't extract any seeds from \the [O.name]!"))
Expand Down
1 change: 0 additions & 1 deletion code/modules/mining/machine_redemption.dm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@

/obj/machinery/mineral/ore_redemption/attackby(obj/item/W, mob/user, params)
if(default_deconstruction_screwdriver(user, "ore_redemption-open", "ore_redemption", W))
updateUsrDialog()
return
if(default_deconstruction_crowbar(W))
return
Expand Down
22 changes: 1 addition & 21 deletions code/modules/paperwork/filingcabinet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/obj/structure/filingcabinet/filingcabinet //not changing the path to avoid unnecessary map issues, but please don't name stuff like this in the future -Pete
icon_state = "tallcabinet"


/obj/structure/filingcabinet/Initialize(mapload)
. = ..()
if(mapload)
Expand Down Expand Up @@ -59,7 +58,6 @@
icon_state = "[initial(icon_state)]-open"
sleep(5)
icon_state = initial(icon_state)
updateUsrDialog()
else if(!user.combat_mode)
to_chat(user, span_warning("You can't put [P] in [src]!"))
else
Expand Down Expand Up @@ -87,7 +85,6 @@

return data


/obj/structure/filingcabinet/ui_act(action, params)
. = ..()
if(.)
Expand All @@ -99,17 +96,15 @@
var/obj/item/content = locate(params["ref"]) in src
if(istype(content) && in_range(src, usr))
usr.put_in_hands(content)
updateUsrDialog()
icon_state = "[initial(icon_state)]-open"
addtimer(VARSET_CALLBACK(src, icon_state, initial(icon_state)), 5)

return TRUE

/obj/structure/filingcabinet/attack_tk(mob/user)
if(anchored)
return attack_self_tk(user)
return ..()


/obj/structure/filingcabinet/attack_self_tk(mob/user)
. = COMPONENT_CANCEL_ATTACK_CHAIN
if(contents.len)
Expand All @@ -122,21 +117,6 @@
return
to_chat(user, span_notice("You find nothing in [src]."))


/obj/structure/filingcabinet/Topic(href, href_list)
if(!usr.canUseTopic(src, BE_CLOSE, NO_DEXTERITY, FALSE, !iscyborg(usr)))
return
if(href_list["retrieve"])
usr << browse("", "window=filingcabinet") // Close the menu

var/obj/item/P = locate(href_list["retrieve"]) in src //contents[retrieveindex]
if(istype(P) && in_range(src, usr))
usr.put_in_hands(P)
updateUsrDialog()
icon_state = "[initial(icon_state)]-open"
addtimer(VARSET_CALLBACK(src, icon_state, initial(icon_state)), 5)


/*
* Security Record Cabinets
*/
Expand Down
1 change: 0 additions & 1 deletion code/modules/power/apc/apc_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@
if(atom_to_check == cell)
cell = null
update_appearance()
updateUsrDialog()

/obj/machinery/power/apc/examine(mob/user)
. = ..()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/power/apc/apc_tool_act.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
locked = !locked
to_chat(user, span_notice("You [ locked ? "lock" : "unlock"] the APC interface."))
update_appearance()
updateUsrDialog()
if(!locked)
ui_interact(user)
else
to_chat(user, span_warning("Access denied."))
3 changes: 0 additions & 3 deletions code/modules/power/gravitygenerator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
/obj/machinery/gravity_generator/main/proc/complete_state_update()
update_appearance()
update_list()
updateUsrDialog()

// Set the state of the gravity.
/obj/machinery/gravity_generator/main/proc/set_state(new_state)
Expand Down Expand Up @@ -370,8 +369,6 @@ GLOBAL_LIST_EMPTY(gravity_generators) // We will keep track of this by adding ne
if(charge_count % 4 == 0 && prob(75)) // Let them know it is charging/discharging.
playsound(src.loc, 'sound/effects/empulse.ogg', 100, TRUE)

updateDialog()

var/overlay_state = null
switch(charge_count)
if(0 to 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
return
replace_beaker(user, B)
to_chat(user, span_notice("You add [B] to [src]."))
updateUsrDialog()
ui_interact(user)
else if(!user.combat_mode && !istype(I, /obj/item/card/emag))
to_chat(user, span_warning("You can't load [I] into [src]!"))
return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/machinery/chem_heater.dm
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
return
replace_beaker(user, B)
to_chat(user, span_notice("You add [B] to [src]."))
updateUsrDialog()
ui_interact(user)
update_appearance()
return

Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/chemistry/machinery/chem_mass_spec.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This will not clean any inverted reagents. Inverted reagents will still be corre
replace_beaker(user, BEAKER1, beaker)
to_chat(user, span_notice("You add [beaker] to [src]."))
update_appearance()
updateUsrDialog()
ui_interact(user)
return
..()

Expand All @@ -109,7 +109,7 @@ This will not clean any inverted reagents. Inverted reagents will still be corre
return
replace_beaker(user, BEAKER2, beaker)
to_chat(user, span_notice("You add [beaker] to [src]."))
updateUsrDialog()
ui_interact(user)
. = SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN

update_appearance()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/chemistry/machinery/chem_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
return
replace_beaker(user, B)
to_chat(user, span_notice("You add [B] to [src]."))
updateUsrDialog()
ui_interact(user)
update_appearance()
else if(!condi && istype(I, /obj/item/storage/pill_bottle))
if(bottle)
Expand All @@ -156,7 +156,7 @@
return
bottle = I
to_chat(user, span_notice("You add [I] into the dispenser slot."))
updateUsrDialog()
ui_interact(user)
else
return ..()

Expand Down
2 changes: 0 additions & 2 deletions code/modules/recycling/disposal/bin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,6 @@
do_flush()
flush_count = 0

updateDialog()

if(flush && air_contents.return_pressure() >= SEND_PRESSURE) // flush can happen even without power
do_flush()

Expand Down
11 changes: 2 additions & 9 deletions code/modules/research/techweb/_techweb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,8 @@
if(wipe_custom_designs)
custom_designs = list()
for(var/id in processing)
update_node_status(SSresearch.techweb_node_by_id(id), FALSE)
update_node_status(SSresearch.techweb_node_by_id(id))
CHECK_TICK
for(var/v in consoles_accessing)
var/obj/machinery/computer/rdconsole/V = v
V.updateUsrDialog()

/datum/techweb/proc/add_point_list(list/pointlist)
for(var/i in pointlist)
Expand Down Expand Up @@ -386,7 +383,7 @@
next += SSresearch.techweb_node_by_id(id)
current = next

/datum/techweb/proc/update_node_status(datum/techweb_node/node, autoupdate_consoles = TRUE)
/datum/techweb/proc/update_node_status(datum/techweb_node/node)
var/researched = FALSE
var/available = FALSE
var/visible = FALSE
Expand Down Expand Up @@ -415,10 +412,6 @@
if(visible)
visible_nodes[node.id] = TRUE
update_tiers(node)
if(autoupdate_consoles)
for(var/v in consoles_accessing)
var/obj/machinery/computer/rdconsole/V = v
V.updateUsrDialog()

//Laggy procs to do specific checks, just in case. Don't use them if you can just use the vars that already store all this!
/datum/techweb/proc/designHasReqs(datum/design/D)
Expand Down
4 changes: 0 additions & 4 deletions code/modules/vending/_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ GLOBAL_LIST_EMPTY(vending_products)
if(anchored)
default_deconstruction_screwdriver(user, icon_state, icon_state, I)
update_appearance()
updateUsrDialog()
else
to_chat(user, span_warning("You must first secure [src]."))
return TRUE
Expand Down Expand Up @@ -477,7 +476,6 @@ GLOBAL_LIST_EMPTY(vending_products)
if(compartmentLoadAccessCheck(user) && !user.combat_mode)
if(canLoadItem(I))
loadingAttempt(I,user)
updateUsrDialog() //can't put this on the proc above because we spam it below

if(istype(I, /obj/item/storage/bag)) //trays USUALLY
var/obj/item/storage/T = I
Expand All @@ -496,7 +494,6 @@ GLOBAL_LIST_EMPTY(vending_products)
to_chat(user, span_warning("[src] refuses some items!"))
if(loaded)
to_chat(user, span_notice("You insert [loaded] dishes into [src]'s compartment."))
updateUsrDialog()
else
. = ..()
if(tiltable && !tilted && I.force)
Expand Down Expand Up @@ -1207,7 +1204,6 @@ GLOBAL_LIST_EMPTY(vending_products)
if(isliving(usr))
vend_act(usr, params["item"])
vend_ready = TRUE
updateUsrDialog()
return TRUE

/obj/machinery/vending/custom/attackby(obj/item/I, mob/user, params)
Expand Down

0 comments on commit b98d91c

Please sign in to comment.