mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-27 02:23:10 +00:00
The AI now has a personal power monitor interface.
This commit is contained in:
@@ -16,12 +16,11 @@
|
||||
density = 1
|
||||
anchored = 1.0
|
||||
circuit = /obj/item/weapon/circuitboard/powermonitor
|
||||
var/list/grid_sensors
|
||||
var/alerting = 0
|
||||
var/active_sensor = null //name_tag of the currently selected sensor
|
||||
use_power = 1
|
||||
idle_power_usage = 300
|
||||
active_power_usage = 300
|
||||
var/obj/nano_module/power_monitor/power_monitor
|
||||
|
||||
// Proc: process()
|
||||
// Parameters: None
|
||||
@@ -53,19 +52,7 @@
|
||||
/obj/machinery/computer/power_monitor/New()
|
||||
..()
|
||||
spawn(50)
|
||||
refresh_sensors()
|
||||
|
||||
// Proc: refresh_sensors()
|
||||
// Parameters: None
|
||||
// Description: Refreshes list of active sensors kept on this computer.
|
||||
/obj/machinery/computer/power_monitor/proc/refresh_sensors()
|
||||
grid_sensors = list()
|
||||
for(var/obj/machinery/power/sensor/S in machines)
|
||||
if((S.loc.z == src.loc.z) || (S.long_range)) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
|
||||
if(S.name_tag == "#UNKN#") // Default name. Shouldn't happen!
|
||||
warning("Powernet sensor with unset ID Tag! [S.x]X [S.y]Y [S.z]Z")
|
||||
else
|
||||
grid_sensors += S
|
||||
power_monitor = new(src)
|
||||
|
||||
// Proc: attack_hand()
|
||||
// Parameters: None
|
||||
@@ -77,50 +64,18 @@
|
||||
return
|
||||
ui_interact(user)
|
||||
|
||||
// Proc: Topic()
|
||||
// Parameters: 2 (href, href_list - allows us to process UI clicks)
|
||||
// Description: Allows us to process UI clicks, which are relayed in form of hrefs.
|
||||
/obj/machinery/computer/power_monitor/Topic(href, href_list)
|
||||
..()
|
||||
if( href_list["clear"] )
|
||||
active_sensor = null
|
||||
else if( href_list["setsensor"] )
|
||||
active_sensor = href_list["setsensor"]
|
||||
// Proc: ui_interact()
|
||||
// Parameters: 4 (standard NanoUI parameters)
|
||||
// Description: Uses dark magic to operate the NanoUI of this computer.
|
||||
/obj/machinery/computer/power_monitor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
power_monitor.ui_interact(user, ui_key, ui, force_open)
|
||||
|
||||
|
||||
// Proc: check_warnings()
|
||||
// Parameters: None
|
||||
// Description: Verifies if any warnings were registered by connected sensors.
|
||||
/obj/machinery/computer/power_monitor/proc/check_warnings()
|
||||
for(var/obj/machinery/power/sensor/S in grid_sensors)
|
||||
for(var/obj/machinery/power/sensor/S in power_monitor.grid_sensors)
|
||||
if(S.check_grid_warning())
|
||||
return 1
|
||||
return 0
|
||||
|
||||
// Proc: ui_interact()
|
||||
// Parameters: 4 (standard NanoUI parameters)
|
||||
// Description: Uses dark magic to operate the NanoUI of this computer.
|
||||
/obj/machinery/computer/power_monitor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/list/data = list()
|
||||
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 = null
|
||||
|
||||
// Build list of data from sensor readings.
|
||||
for(var/obj/machinery/power/sensor/S in grid_sensors)
|
||||
sensors.Add(list(list(
|
||||
"name" = S.name_tag,
|
||||
"alarm" = S.check_grid_warning()
|
||||
)))
|
||||
if(S.name_tag == active_sensor)
|
||||
focus = S
|
||||
|
||||
data["all_sensors"] = sensors
|
||||
if(focus)
|
||||
data["focus"] = focus.return_reading_data()
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "power_monitor.tmpl", "Power Monitoring Console", 800, 500)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
Reference in New Issue
Block a user