Files
CHOMPStation2/code/modules/tgui/modules/power_monitor.dm
ShadowLarkens 951f37d2e3 TGUI Engineering: Squashed Edition (Commits Below)
TGUI APCs

 TGUI vending machines

 Fix AI default_tgui_interaction

 TGUI Airlocks

 Station & Atmospheric Alert TGUI + Misc NTOS-TGUI Fixes

 TGUI Air Alarms & Central Atmospheric Control

 Airlock TGUI

 TG... got rid of UI for fire alarm. í´·

 TGUI Gas Heating/Cooling System

 TGUI Gas Pump & Passive Gate + Fixes

 TGUI Omni Atmospherics

 TGUI Pipe Dispensers & RPD

 TGUI IntelliCore & Vending Fix

 TGUI Handheld Tanks

 TGUI Portable Pump & Scrubber

 TGUI Tank Dispenser & Canisters

 TGUI Radios

 TGUI SMES & Air Alarm adjustment

 Tweak vending machine interfaces a tad

 TGUI Algae Farm

 TGUI general_air_control

 - Distro & Waste Console
 - Riot Control Console
 - Atmos Intake Console
 - Engine Cooling Console

 TGUI Heavy Scrubber Control (and body scanner fix)

 TGUI trinary devices & shutoff monitor

 TGUI Telecomms Log Browser

 TGUI Telecomms Machine Browser

 TGUI Spaceheater Internal Panel

 TGUI Gravity Generator

 TGUI Id Cards & Fix ID Card Images

 TGUI Id Card Redesign

 TGUI Turbolift

 TGUI Suit Cycler & Suit Storage Unit & Vending Fixes

 TGUI Power Monitor

 TGUI Signalers

 TGUI Employment Records

 TGUI Drone Console

 TGUI RIGSuits

 TGUI PA & PACMAN, and Margin Fix

 TGUI Solar Panels & Fix Power Monitor

 Adjust TGUI modules & their interaction with NTOS

 TGUI RCON

 TGUI Message Monitor

 Bump TGUI line limit to 120 (ParadiseSS13/Paradise#14002)

 TGUI Exonet & NTNet Relay

 TGUI Telecomms Multitool Menu

 TGUI Shield Capacitor & Shield Generator

 TGUI Supermatter-everything & Refactors
2020-08-09 04:46:31 -07:00

86 lines
2.2 KiB
Plaintext

/datum/tgui_module/power_monitor
name = "Power monitor"
tgui_id = "PowerMonitor"
var/list/grid_sensors
var/active_sensor = null //name_tag of the currently selected sensor
/datum/tgui_module/power_monitor/New()
. = ..()
refresh_sensors()
/datum/tgui_module/power_monitor/tgui_data(mob/user)
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
var/z = get_z(user)
var/list/map_levels = using_map.get_map_levels(z)
// Build list of data from sensor readings.
for(var/obj/machinery/power/sensor/S in grid_sensors)
if(!(S.z in map_levels))
continue
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.tgui_data(user)
else
data["focus"] = null
return data
/datum/tgui_module/power_monitor/tgui_act(action, params)
if(..())
return TRUE
switch(action)
if("clear")
active_sensor = null
. = TRUE
if("refresh")
refresh_sensors()
. = TRUE
if("setsensor")
active_sensor = params["id"]
. = TRUE
/datum/tgui_module/power_monitor/proc/has_alarm()
for(var/obj/machinery/power/sensor/S in grid_sensors)
if(S.check_grid_warning())
return TRUE
return FALSE
/datum/tgui_module/power_monitor/proc/refresh_sensors()
grid_sensors = list()
// Handle ultranested programs
var/turf/T = get_turf(tgui_host())
var/list/levels = list()
if(!T) // Safety check
return
if(T)
levels += using_map.get_map_levels(T.z, FALSE)
for(var/obj/machinery/power/sensor/S in machines)
if(T && (S.loc.z == T.z) || (S.loc.z in levels) || (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
/datum/tgui_module/power_monitor/ntos
ntos = TRUE
// Subtype for self_state
/datum/tgui_module/power_monitor/robot
/datum/tgui_module/power_monitor/robot/tgui_state(mob/user)
return GLOB.tgui_self_state