From bff87cacfb4423a2c6a784acf533e1eca6fa3e73 Mon Sep 17 00:00:00 2001 From: GDN <96800819+GDNgit@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:47:27 -0600 Subject: [PATCH] makes the card console no longer autoupdate (#23342) --- code/game/machinery/computer/card.dm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/game/machinery/computer/card.dm b/code/game/machinery/computer/card.dm index a4aee582a83..4ca992f8d0b 100644 --- a/code/game/machinery/computer/card.dm +++ b/code/game/machinery/computer/card.dm @@ -21,6 +21,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) var/mode = 0 var/target_dept = 0 //Which department this computer has access to. 0=all departments var/obj/item/radio/Radio + var/reset_timer //Cooldown for closing positions in seconds //if set to -1: No cooldown... probably a bad idea @@ -137,6 +138,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) scan.forceMove(get_turf(src)) scan = null playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, 0) + SStgui.update_uis(src) return else if(modify) to_chat(user, "You remove \the [modify] from \the [src].") @@ -146,6 +148,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) modify.forceMove(get_turf(src)) modify = null playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, 0) + SStgui.update_uis(src) else to_chat(user, "There is nothing to remove from the console.") @@ -310,10 +313,21 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) /obj/machinery/computer/card/ui_state(mob/user) return GLOB.default_state +/obj/machinery/computer/card/proc/change_ui_autoupdate(value, mob/user) + var/datum/tgui/ui = SStgui.try_update_ui(user, src, "main") + reset_timer = null + if(ui) + ui.set_autoupdate(value) + /obj/machinery/computer/card/ui_interact(mob/user, datum/tgui/ui = null) ui = SStgui.try_update_ui(user, src, ui) if(!ui) ui = new(user, src, "CardComputer", name) + var/delta = (world.time / 10) - GLOB.time_last_changed_position + if(change_position_cooldown < delta && !reset_timer) + ui.set_autoupdate(FALSE) + else + reset_timer = addtimer(CALLBACK(src, PROC_REF(change_ui_autoupdate), FALSE, user), delta SECONDS) ui.open() /obj/machinery/computer/card/ui_data(mob/user) @@ -582,6 +596,9 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) return FALSE if(opened_positions[edit_job_target] >= 0) GLOB.time_last_changed_position = world.time / 10 + change_ui_autoupdate(TRUE, usr) + reset_timer = addtimer(CALLBACK(src, PROC_REF(change_ui_autoupdate), FALSE, usr), GLOB.time_last_changed_position SECONDS) + j.total_positions++ opened_positions[edit_job_target]++ log_game("[key_name(usr)] ([scan.assignment]) has opened a job slot for job \"[j.title]\".") @@ -599,6 +616,8 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0) //Allow instant closing without cooldown if a position has been opened before if(opened_positions[edit_job_target] <= 0) GLOB.time_last_changed_position = world.time / 10 + change_ui_autoupdate(TRUE, usr) + reset_timer = addtimer(CALLBACK(src, PROC_REF(change_ui_autoupdate), FALSE, usr), (GLOB.time_last_changed_position + 1) SECONDS) j.total_positions-- opened_positions[edit_job_target]-- log_game("[key_name(usr)] ([scan.assignment]) has closed a job slot for job \"[j.title]\".")