From a2aac9dd31b4dd9be37d50555fc24cb5c49ea66b Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 26 Apr 2022 16:26:56 +0200 Subject: [PATCH] [MIRROR] updateDialog and updateUsrDialog cleanup [MDB IGNORE] (#13118) * updateDialog and updateUsrDialog cleanup (#66494) 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. * updateDialog and updateUsrDialog cleanup Co-authored-by: Arkatos1 <43862960+Arkatos1@users.noreply.github.com> --- code/game/machinery/civilian_bounties.dm | 5 ++-- code/game/machinery/doors/airlock.dm | 23 ------------------- code/game/machinery/gulag_teleporter.dm | 3 --- code/game/machinery/launch_pad.dm | 1 - code/game/machinery/spaceheater.dm | 2 +- code/game/machinery/syndicatebomb.dm | 1 - .../items/devices/portable_chem_mixer.dm | 2 +- .../atmospherics/machinery/airalarm.dm | 3 ++- .../components/unary_devices/cryo.dm | 1 - code/modules/hydroponics/seed_extractor.dm | 1 - code/modules/mining/machine_redemption.dm | 1 - code/modules/paperwork/filingcabinet.dm | 22 +----------------- code/modules/power/apc/apc_main.dm | 1 - code/modules/power/apc/apc_tool_act.dm | 3 ++- code/modules/power/gravitygenerator.dm | 3 --- .../chemistry/machinery/chem_dispenser.dm | 2 +- .../chemistry/machinery/chem_heater.dm | 2 +- .../chemistry/machinery/chem_mass_spec.dm | 4 ++-- .../chemistry/machinery/chem_master.dm | 4 ++-- code/modules/recycling/disposal/bin.dm | 2 -- code/modules/research/techweb/_techweb.dm | 11 ++------- code/modules/vending/_vending.dm | 4 ---- 22 files changed, 17 insertions(+), 84 deletions(-) diff --git a/code/game/machinery/civilian_bounties.dm b/code/game/machinery/civilian_bounties.dm index f798a0a852c..19f7ea8f703 100644 --- a/code/game/machinery/civilian_bounties.dm +++ b/code/game/machinery/civilian_bounties.dm @@ -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 @@ -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. @@ -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. diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index c1a2cbcbcaf..e2484149038 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -407,15 +407,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() @@ -783,31 +780,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) diff --git a/code/game/machinery/gulag_teleporter.dm b/code/game/machinery/gulag_teleporter.dm index 0d44d795f17..1be6593b689 100644 --- a/code/game/machinery/gulag_teleporter.dm +++ b/code/game/machinery/gulag_teleporter.dm @@ -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() diff --git a/code/game/machinery/launch_pad.dm b/code/game/machinery/launch_pad.dm index a0ee702722b..a849f8f940b 100644 --- a/code/game/machinery/launch_pad.dm +++ b/code/game/machinery/launch_pad.dm @@ -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 diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm index 38f76e281ef..ee91c55c750 100644 --- a/code/game/machinery/spaceheater.dm +++ b/code/game/machinery/spaceheater.dm @@ -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) diff --git a/code/game/machinery/syndicatebomb.dm b/code/game/machinery/syndicatebomb.dm index b269c71fcab..220d16ba2d3 100644 --- a/code/game/machinery/syndicatebomb.dm +++ b/code/game/machinery/syndicatebomb.dm @@ -344,7 +344,6 @@ holder.delayedlittle = FALSE holder.explode_now = FALSE holder.update_appearance() - holder.updateDialog() STOP_PROCESSING(SSfastprocess, holder) /obj/item/bombcore/training/detonate() diff --git a/code/game/objects/items/devices/portable_chem_mixer.dm b/code/game/objects/items/devices/portable_chem_mixer.dm index 144d9d0eefb..eba967b874f 100644 --- a/code/game/objects/items/devices/portable_chem_mixer.dm +++ b/code/game/objects/items/devices/portable_chem_mixer.dm @@ -48,7 +48,7 @@ return replace_beaker(user, B) update_appearance() - updateUsrDialog() + ui_interact(user) return return ..() diff --git a/code/modules/atmospherics/machinery/airalarm.dm b/code/modules/atmospherics/machinery/airalarm.dm index 5fc499db532..1bab9dd3b0d 100644 --- a/code/modules/atmospherics/machinery/airalarm.dm +++ b/code/modules/atmospherics/machinery/airalarm.dm @@ -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 diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index c95f4423a1b..3fb3c3371ec 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -184,7 +184,6 @@ ..() if(A == beaker) beaker = null - updateUsrDialog() /obj/machinery/atmospherics/components/unary/cryo_cell/on_deconstruction() if(beaker) diff --git a/code/modules/hydroponics/seed_extractor.dm b/code/modules/hydroponics/seed_extractor.dm index 2a1f2e966a1..248553a77a5 100644 --- a/code/modules/hydroponics/seed_extractor.dm +++ b/code/modules/hydroponics/seed_extractor.dm @@ -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]!")) diff --git a/code/modules/mining/machine_redemption.dm b/code/modules/mining/machine_redemption.dm index 7e62c6dc6f9..d535904af02 100644 --- a/code/modules/mining/machine_redemption.dm +++ b/code/modules/mining/machine_redemption.dm @@ -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 diff --git a/code/modules/paperwork/filingcabinet.dm b/code/modules/paperwork/filingcabinet.dm index c11f027abb3..39093c747b5 100644 --- a/code/modules/paperwork/filingcabinet.dm +++ b/code/modules/paperwork/filingcabinet.dm @@ -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) @@ -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 @@ -87,7 +85,6 @@ return data - /obj/structure/filingcabinet/ui_act(action, params) . = ..() if(.) @@ -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) @@ -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 */ diff --git a/code/modules/power/apc/apc_main.dm b/code/modules/power/apc/apc_main.dm index 9ec8c76896b..f7d7eb58e4b 100644 --- a/code/modules/power/apc/apc_main.dm +++ b/code/modules/power/apc/apc_main.dm @@ -209,7 +209,6 @@ if(atom_to_check == cell) cell = null update_appearance() - updateUsrDialog() /obj/machinery/power/apc/examine(mob/user) . = ..() diff --git a/code/modules/power/apc/apc_tool_act.dm b/code/modules/power/apc/apc_tool_act.dm index 5032385620c..2750cd9e4c2 100644 --- a/code/modules/power/apc/apc_tool_act.dm +++ b/code/modules/power/apc/apc_tool_act.dm @@ -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.")) diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index b0ae3328e32..ea37bc02c1e 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -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) @@ -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) diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index 6daf009f080..12a34ef216d 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -429,7 +429,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 ..() diff --git a/code/modules/reagents/chemistry/machinery/chem_heater.dm b/code/modules/reagents/chemistry/machinery/chem_heater.dm index 556cf9e55c1..fa88b246998 100644 --- a/code/modules/reagents/chemistry/machinery/chem_heater.dm +++ b/code/modules/reagents/chemistry/machinery/chem_heater.dm @@ -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 diff --git a/code/modules/reagents/chemistry/machinery/chem_mass_spec.dm b/code/modules/reagents/chemistry/machinery/chem_mass_spec.dm index 994e79550d6..1aa72f924eb 100644 --- a/code/modules/reagents/chemistry/machinery/chem_mass_spec.dm +++ b/code/modules/reagents/chemistry/machinery/chem_mass_spec.dm @@ -90,7 +90,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 ..() @@ -110,7 +110,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() diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 3aa244e19b8..f552203e864 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -147,7 +147,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) @@ -157,7 +157,7 @@ return bottle = I to_chat(user, span_notice("You add [I] into the dispenser slot.")) - updateUsrDialog() + ui_interact(user) else return ..() diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index 3d0a446dde1..f23d126765c 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -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() diff --git a/code/modules/research/techweb/_techweb.dm b/code/modules/research/techweb/_techweb.dm index abccd710972..8daa85c5b6e 100644 --- a/code/modules/research/techweb/_techweb.dm +++ b/code/modules/research/techweb/_techweb.dm @@ -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) @@ -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 @@ -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) diff --git a/code/modules/vending/_vending.dm b/code/modules/vending/_vending.dm index 1f031034d87..b1ccc4634e5 100644 --- a/code/modules/vending/_vending.dm +++ b/code/modules/vending/_vending.dm @@ -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 @@ -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 @@ -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) @@ -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)