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.
This commit is contained in:
Leshana
2017-05-21 16:04:45 -04:00
parent e16a3f4b3d
commit b4ca6b11e1
13 changed files with 43 additions and 29 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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))

View File

@@ -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)

View File

@@ -119,6 +119,17 @@ var/list/all_maps = list()
empty_levels = list(world.maxz)
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()
// Another way to setup the map datum that can be convenient. Just declare all your zlevels as subtypes of a common
// subtype of /datum/map_z_level and set zlevel_datum_type on /datum/map to have the lists auto-initialized.

View File

@@ -1,6 +1,8 @@
{{if data.map_levels.length}}
<div class="notice" style="height: 22px">
{{:helper.link('Show Air Alrms On Map', 'pin-s', {'showMap' : 1})}}
</div>
{{/if}}
<div class='item'>
{{for data.alarms}}
{{:helper.link(value.name, null, {'alarm' : value.ref}, null, value.danger == 2 ? 'redButton' : (value.danger == 1 ? 'yellowButton' : null))}}

View File

@@ -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}}
<div style="float: right;">
<span style="float: left;">Z Level:&nbsp;</span>
{{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}}
</div>
{{/if}}

View File

@@ -16,7 +16,9 @@ Used In File(s): \code\game\machinery\computer\crew.dm
}
</style>
{{if data.map_levels.length}}
{{:helper.link('Show Tracker Map', 'pin-s', {'showMap' : 1})}}
{{/if}}
<table class='wideTable'><tbody>
{{for data.crewmembers}}
{{if value.sensor_type == 1}}

View File

@@ -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}}
<div style="float: right;">
<span style="float: left;">Z Level:&nbsp;</span>
{{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}}
</div>
{{/if}}

View File

@@ -2,7 +2,9 @@
<div class="notice" style="height: 22px">
{{:helper.link('Show List', 'cancel', { 'clear' : 1})}} Sensor selected: {{:data.focus.name}}
</div>
{{if data.map_levels.length}}
{{:helper.link('Show APCs On Map', 'pin-s', {'showMap' : 1})}}
{{/if}}
{{if data.focus.error}}
{{:data.focus.error}}
{{else}}

View File

@@ -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}}<span>Sensor selected: {{:data.focus.name}}</span>{{/if}}
{{if data.station_levels.length > 1}}
{{if data.map_levels.length > 1}}
<div style="float: right;">
<span style="float: left;">Z Level:&nbsp;</span>
{{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}}
</div>
{{/if}}

View File

@@ -2,7 +2,9 @@
Title: Security Camera Console (Main content)
Used In File(s): \code\game\machinery\computer\camera.dm
-->
{{if data.map_levels.length}}
{{:helper.link('Show Map', 'pin-s', {'showMap' : 1})}}
{{/if}}
{{:helper.link('Reset', 'refresh', {'reset' : 1})}}
<div style="float:left;">
<div class='item'>

View File

@@ -14,11 +14,11 @@ Used In File(s): \code\game\machinery\computer\camera.dm
{{/if}}
</div>
</div>
{{if data.station_levels.length > 1}}
{{if data.map_levels.length > 1}}
<div style="float: right;">
<span style="float: left;">Z Level:&nbsp;</span>
{{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}}
</div>
{{/if}}