From 93495bd53ef6e0804d0f8ddca47bcd5b2ed42440 Mon Sep 17 00:00:00 2001 From: Leshana Date: Sun, 21 May 2017 16:04:45 -0400 Subject: [PATCH] Switch nanomap computers over to using get_sensor_levels() * Added a proc to the map datum which returns what zlevels a nanomap capable computer should display. * Updated the atmos control, power monitoring, crew monitoring, and camera consoles to use it. * Changed templates to not show the map button if no map levels are available. * Overrode it for tether to let crew monitoring computers monitor the whole station. --- code/game/machinery/computer/camera.dm | 2 +- code/modules/nano/modules/atmos_control.dm | 3 ++- code/modules/nano/modules/crew_monitor.dm | 15 ++++----------- code/modules/nano/modules/power_monitor.dm | 3 ++- maps/tether/tether_defines.dm | 18 ++++++++++++++++++ maps/tether/tether_things.dm | 10 ---------- maps/~map_system/maps.dm | 13 ++++++++++++- nano/templates/atmos_control.tmpl | 2 ++ nano/templates/atmos_control_map_header.tmpl | 6 +++--- nano/templates/crew_monitor.tmpl | 4 +++- nano/templates/crew_monitor_map_header.tmpl | 6 +++--- nano/templates/power_monitor.tmpl | 4 +++- nano/templates/power_monitor_map_header.tmpl | 6 +++--- nano/templates/sec_camera.tmpl | 4 +++- nano/templates/sec_camera_map_header.tmpl | 6 +++--- 15 files changed, 62 insertions(+), 40 deletions(-) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 5a01285356..176e2d7743 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -47,7 +47,7 @@ data["cameras"] = camera_repository.cameras_in_network(current_network) if(current_camera) switch_to_camera(user, current_camera) - data["station_levels"] = using_map.station_levels + data["map_levels"] = using_map.get_map_levels(src.z) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if (!ui) diff --git a/code/modules/nano/modules/atmos_control.dm b/code/modules/nano/modules/atmos_control.dm index 6e1fdff37c..742696396b 100644 --- a/code/modules/nano/modules/atmos_control.dm +++ b/code/modules/nano/modules/atmos_control.dm @@ -32,6 +32,7 @@ /datum/nano_module/atmos_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state) var/data[0] var/alarms[0] + var/turf/T = get_turf(nano_host()) // TODO: Move these to a cache, similar to cameras for(var/obj/machinery/alarm/alarm in (monitored_alarms.len ? monitored_alarms : machines)) @@ -43,7 +44,7 @@ "y" = alarm.y, "z" = alarm.z) data["alarms"] = alarms - data["station_levels"] = using_map.station_levels + data["map_levels"] = using_map.get_map_levels(T.z) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if(!ui) diff --git a/code/modules/nano/modules/crew_monitor.dm b/code/modules/nano/modules/crew_monitor.dm index a3b5ba19a7..ba36fc6d68 100644 --- a/code/modules/nano/modules/crew_monitor.dm +++ b/code/modules/nano/modules/crew_monitor.dm @@ -20,12 +20,10 @@ var/turf/T = get_turf(nano_host()) data["isAI"] = isAI(user) - - data["station_levels"] = get_z_levels(T) - var/list/crewmembers = list() - for(var/z in data["station_levels"]) - crewmembers += crew_repository.health_data(z) - data["crewmembers"] = crewmembers + data["map_levels"] = using_map.get_map_levels(T.z, FALSE) + data["crewmembers"] = list() + for(var/z in (data["map_levels"] | T.z)) // Always show crew from the current Z even if we can't show a map + data["crewmembers"] += crew_repository.health_data(z) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if(!ui) @@ -35,8 +33,6 @@ ui.add_template("mapContent", "crew_monitor_map_content.tmpl") // adding a template with the key "mapHeader" replaces the map header content ui.add_template("mapHeader", "crew_monitor_map_header.tmpl") - if(!(ui.map_z_level in data["station_levels"])) - ui.set_map_z_level(data["station_levels"][1]) ui.set_initial_data(data) ui.open() @@ -44,9 +40,6 @@ // should make the UI auto-update; doesn't seem to? ui.set_auto_update(1) -/datum/nano_module/crew_monitor/proc/get_z_levels(var/turf/T) - return list(T.z) - /*/datum/nano_module/crew_monitor/proc/scan() for(var/mob/living/carbon/human/H in mob_list) if(istype(H.w_uniform, /obj/item/clothing/under)) diff --git a/code/modules/nano/modules/power_monitor.dm b/code/modules/nano/modules/power_monitor.dm index 8eea3bef9c..89e1dbda62 100644 --- a/code/modules/nano/modules/power_monitor.dm +++ b/code/modules/nano/modules/power_monitor.dm @@ -12,6 +12,7 @@ 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/turf/T = get_turf(nano_host()) // Build list of data from sensor readings. for(var/obj/machinery/power/sensor/S in grid_sensors) @@ -25,7 +26,7 @@ data["all_sensors"] = sensors if(focus) data["focus"] = focus.return_reading_data() - data["station_levels"] = using_map.station_levels + data["map_levels"] = using_map.get_map_levels(T.z) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if (!ui) diff --git a/maps/tether/tether_defines.dm b/maps/tether/tether_defines.dm index 59db78ccef..ea11116e6e 100644 --- a/maps/tether/tether_defines.dm +++ b/maps/tether/tether_defines.dm @@ -174,3 +174,21 @@ holomap_legend_x[z] = 220 holomap_legend_y[z] = 160 holomap_smoosh = list(list(1,2,3,5,6,7)) + + +// Short range computers see only the six main levels, others can see the surrounding surface levels. +/datum/map/tether/get_map_levels(var/srcz, var/long_range = TRUE) + if (long_range && (srcz in map_levels)) + return map_levels + else if (srcz == Z_LEVEL_TRANSIT) + return list() // Nothing on transit! + else if (srcz >= Z_LEVEL_SURFACE_LOW && srcz <= Z_LEVEL_SPACE_HIGH) + return list( + Z_LEVEL_SURFACE_LOW, + Z_LEVEL_SURFACE_MID, + Z_LEVEL_SURFACE_HIGH, + Z_LEVEL_SPACE_LOW, + Z_LEVEL_SPACE_MID, + Z_LEVEL_SPACE_HIGH) + else + return ..() diff --git a/maps/tether/tether_things.dm b/maps/tether/tether_things.dm index 69984aeafc..2a94ec9b8d 100644 --- a/maps/tether/tether_things.dm +++ b/maps/tether/tether_things.dm @@ -191,16 +191,6 @@ var/global/list/latejoin_tram = list() ..() turfs = latejoin_tram -// Override crew monitors so that ones on the station see the whole station, and ones on surface the whole surface. -/datum/nano_module/crew_monitor/get_z_levels(var/turf/T) - switch(T.z) - if(Z_LEVEL_SURFACE_LOW to Z_LEVEL_SURFACE_HIGH) - return list(Z_LEVEL_SURFACE_LOW, Z_LEVEL_SURFACE_MID, Z_LEVEL_SURFACE_HIGH) - if(Z_LEVEL_SPACE_LOW to Z_LEVEL_SPACE_HIGH) - return list(Z_LEVEL_SPACE_LOW, Z_LEVEL_SPACE_MID, Z_LEVEL_SPACE_HIGH) - else - return ..() - // // Holodorms // diff --git a/maps/~map_system/maps.dm b/maps/~map_system/maps.dm index 0ee2316a4b..86ef5ec8d6 100644 --- a/maps/~map_system/maps.dm +++ b/maps/~map_system/maps.dm @@ -111,4 +111,15 @@ var/list/all_maps = list() if(empty_levels == null) world.maxz++ empty_levels = list(world.maxz) - return pick(empty_levels) \ No newline at end of file + return pick(empty_levels) + +// Get the list of zlevels that a computer on srcz can see maps of (for power/crew monitor, cameras, etc) +// The long_range parameter expands the coverage. Default is to return map_levels for long range otherwise just srcz. +// zLevels outside station_levels will return an empty list. +/datum/map/proc/get_map_levels(var/srcz, var/long_range = TRUE) + if (long_range && (srcz in map_levels)) + return map_levels + else if (srcz in station_levels) + return list(srcz) + else + return list() diff --git a/nano/templates/atmos_control.tmpl b/nano/templates/atmos_control.tmpl index 2bade2a264..3d2a1203f7 100644 --- a/nano/templates/atmos_control.tmpl +++ b/nano/templates/atmos_control.tmpl @@ -1,6 +1,8 @@ +{{if data.map_levels.length}}
{{:helper.link('Show Air Alrms On Map', 'pin-s', {'showMap' : 1})}}
+{{/if}}
{{for data.alarms}} {{:helper.link(value.name, null, {'alarm' : value.ref}, null, value.danger == 2 ? 'redButton' : (value.danger == 1 ? 'yellowButton' : null))}} diff --git a/nano/templates/atmos_control_map_header.tmpl b/nano/templates/atmos_control_map_header.tmpl index 8c67be2dfe..7fea71a965 100644 --- a/nano/templates/atmos_control_map_header.tmpl +++ b/nano/templates/atmos_control_map_header.tmpl @@ -3,11 +3,11 @@ Title: Atmos Control Console (Map Header) Used In File(s): \code\modules\nano\modules\atmos_control.dm --> {{:helper.link('Show List', 'script', {'showMap' : 0})}} -{{if data.station_levels.length > 1}} +{{if data.map_levels.length > 1}}
Z Level:  - {{for data.station_levels }} - {{:helper.link(value, null, {'mapZLevel' : value}) }} + {{for data.map_levels }} + {{:helper.link(value, null, {'mapZLevel' : value}, null, config.mapZLevel == value ? 'selected' : null)}} {{/for}}
{{/if}} diff --git a/nano/templates/crew_monitor.tmpl b/nano/templates/crew_monitor.tmpl index cd3a014652..74467e4b0f 100644 --- a/nano/templates/crew_monitor.tmpl +++ b/nano/templates/crew_monitor.tmpl @@ -16,7 +16,9 @@ Used In File(s): \code\game\machinery\computer\crew.dm } -{{:helper.link('Show Tracker Map', 'pin-s', {'showMap' : 1})}} +{{if data.map_levels.length}} + {{:helper.link('Show Tracker Map', 'pin-s', {'showMap' : 1})}} +{{/if}} {{for data.crewmembers}} {{if value.sensor_type == 1}} diff --git a/nano/templates/crew_monitor_map_header.tmpl b/nano/templates/crew_monitor_map_header.tmpl index c3417e5242..2ec9485491 100644 --- a/nano/templates/crew_monitor_map_header.tmpl +++ b/nano/templates/crew_monitor_map_header.tmpl @@ -3,11 +3,11 @@ Title: Crew Monitoring Console (Map header) Used In File(s): \code\game\machinery\computer\crew.dm --> {{:helper.link('Show Detail List', 'script', {'showMap' : 0})}} -{{if data.station_levels.length > 1}} +{{if data.map_levels.length > 1}}
Z Level:  - {{for data.station_levels }} - {{:helper.link(value, null, {'mapZLevel' : value}) }} + {{for data.map_levels }} + {{:helper.link(value, null, {'mapZLevel' : value}, null, config.mapZLevel == value ? 'selected' : null)}} {{/for}}
{{/if}} diff --git a/nano/templates/power_monitor.tmpl b/nano/templates/power_monitor.tmpl index 5e6b557663..6c9e5eee34 100644 --- a/nano/templates/power_monitor.tmpl +++ b/nano/templates/power_monitor.tmpl @@ -2,7 +2,9 @@
{{:helper.link('Show List', 'cancel', { 'clear' : 1})}} Sensor selected: {{:data.focus.name}}
- {{:helper.link('Show APCs On Map', 'pin-s', {'showMap' : 1})}} + {{if data.map_levels.length}} + {{:helper.link('Show APCs On Map', 'pin-s', {'showMap' : 1})}} + {{/if}} {{if data.focus.error}} {{:data.focus.error}} {{else}} diff --git a/nano/templates/power_monitor_map_header.tmpl b/nano/templates/power_monitor_map_header.tmpl index fa9f39d168..171fd03429 100644 --- a/nano/templates/power_monitor_map_header.tmpl +++ b/nano/templates/power_monitor_map_header.tmpl @@ -4,11 +4,11 @@ Used In File(s): \code\modules\nano\modules\power_monitor.dm --> {{:helper.link('Show Network Information', 'script', {'showMap' : 0})}} {{if data.focus}}Sensor selected: {{:data.focus.name}}{{/if}} -{{if data.station_levels.length > 1}} +{{if data.map_levels.length > 1}}
Z Level:  - {{for data.station_levels }} - {{:helper.link(value, null, {'mapZLevel' : value}) }} + {{for data.map_levels }} + {{:helper.link(value, null, {'mapZLevel' : value}, null, config.mapZLevel == value ? 'selected' : null)}} {{/for}}
{{/if}} diff --git a/nano/templates/sec_camera.tmpl b/nano/templates/sec_camera.tmpl index 356bad1df3..1d46f1868f 100644 --- a/nano/templates/sec_camera.tmpl +++ b/nano/templates/sec_camera.tmpl @@ -2,7 +2,9 @@ Title: Security Camera Console (Main content) Used In File(s): \code\game\machinery\computer\camera.dm --> -{{:helper.link('Show Map', 'pin-s', {'showMap' : 1})}} +{{if data.map_levels.length}} + {{:helper.link('Show Map', 'pin-s', {'showMap' : 1})}} +{{/if}} {{:helper.link('Reset', 'refresh', {'reset' : 1})}}
diff --git a/nano/templates/sec_camera_map_header.tmpl b/nano/templates/sec_camera_map_header.tmpl index e4e424f095..0281c70cf5 100644 --- a/nano/templates/sec_camera_map_header.tmpl +++ b/nano/templates/sec_camera_map_header.tmpl @@ -14,11 +14,11 @@ Used In File(s): \code\game\machinery\computer\camera.dm {{/if}}
-{{if data.station_levels.length > 1}} +{{if data.map_levels.length > 1}}
Z Level:  - {{for data.station_levels }} - {{:helper.link(value, null, {'mapZLevel' : value}) }} + {{for data.map_levels }} + {{:helper.link(value, null, {'mapZLevel' : value}, null, config.mapZLevel == value ? 'selected' : null)}} {{/for}}
{{/if}}