From bc4bfcaaa071c4a9a3ed8a0c9d6ed13202da3b3f Mon Sep 17 00:00:00 2001 From: FabianK3 <21039694+FabianK3@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:38:30 +0200 Subject: [PATCH] Fixes UI navigation in engineering power-monitor program (#19940) When selecting a sensor in the engineering power-monitor program, you are not able to return to the sensor list without restarting the whole console. Even though the issue is known for some time now, i weren't able to find an issue to reference in the PR. - Fixes broken UI navigation when trying to return to the sensor list. - Resets UI navigation state when program gets closed. --- .../programs/engineering/powermonitor.dm | 18 +++++++++++------- ...-bugfix-powermonitor-program-navigation.yml | 6 ++++++ 2 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 html/changelogs/fabiank3-bugfix-powermonitor-program-navigation.yml diff --git a/code/modules/modular_computers/file_system/programs/engineering/powermonitor.dm b/code/modules/modular_computers/file_system/programs/engineering/powermonitor.dm index 6965a77fe06..03f8660a7ba 100644 --- a/code/modules/modular_computers/file_system/programs/engineering/powermonitor.dm +++ b/code/modules/modular_computers/file_system/programs/engineering/powermonitor.dm @@ -20,12 +20,10 @@ /datum/computer_file/program/power_monitor/ui_data(mob/user) var/list/data = initial_data() - var/list/sensors = list() - // Focus: If it remains null if no sensor is selected and UI will display sensor list, otherwise it will display sensor reading. - var/obj/machinery/power/sensor/focus + var/obj/machinery/power/sensor/focus // Placeholder for selected sensor, if one has been selected from the UI list - // Build list of data from sensor readings. + // Prepare list of sensors (see refresh_sensors()) and set focus to sensor based of active_sensor (see ui_act()->setsensor) for(var/obj/machinery/power/sensor/S in grid_sensors) sensors.Add(list(list( "name" = S.name_tag, @@ -34,12 +32,18 @@ if(S.name_tag == active_sensor) focus = S - data["all_sensors"] = sensors + // Prepare return value: data["focus"] will dictate which view is visible (list or focused sensor) + data["all_sensors"] = sensors // Represents main menu list of all found sensors if(focus) - data["focus"] = focus.return_reading_data() - + data["focus"] = focus.return_reading_data() // Force view to selected sensor, include focused sensors data + else + data["focus"] = null // Force view to main menu return data +/datum/computer_file/program/power_monitor/kill_program(forced) + ..() + active_sensor = null // Reset UI navigation state + /datum/computer_file/program/power_monitor/proc/has_alarm() for(var/obj/machinery/power/sensor/S in grid_sensors) if(S.check_grid_warning()) diff --git a/html/changelogs/fabiank3-bugfix-powermonitor-program-navigation.yml b/html/changelogs/fabiank3-bugfix-powermonitor-program-navigation.yml new file mode 100644 index 00000000000..c6d63710b91 --- /dev/null +++ b/html/changelogs/fabiank3-bugfix-powermonitor-program-navigation.yml @@ -0,0 +1,6 @@ +author: FabianK3 + +delete-after: True + +changes: + - bugfix: "Fixed broken UI navigation in engineering power-monitor program."