Skip to content

Commit

Permalink
Atmos Filter/Scrubber UI update (tgstation#32746)
Browse files Browse the repository at this point in the history
* filter tgui update

* vent scrubber tgui update

* portable scrubber tgui update

* fix portable scrubber ui
  • Loading branch information
duncathan authored and ninjanomnom committed Nov 16, 2017
1 parent b82f858 commit 33f2f2f
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 164 deletions.
3 changes: 3 additions & 0 deletions code/modules/atmospherics/gasmixtures/gas_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ GLOBAL_LIST_INIT(hardcoded_gases, list(/datum/gas/oxygen, /datum/gas/nitrogen, /

/proc/gas_id2path(id)
var/list/meta_gas = GLOB.meta_gas_info
if(id in meta_gas)
return id
for(var/path in meta_gas)
if(meta_gas[path][META_GAS_ID] == id)
return path
return ""

/*||||||||||||||/----------\||||||||||||||*\
||||||||||||||||[GAS DATUMS]||||||||||||||||
Expand Down
10 changes: 3 additions & 7 deletions code/modules/atmospherics/machinery/airalarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,7 @@
"power" = info["power"],
"scrubbing" = info["scrubbing"],
"widenet" = info["widenet"],
"filter_co2" = info["filter_co2"],
"filter_toxins" = info["filter_toxins"],
"filter_n2o" = info["filter_n2o"],
"filter_rare" = info["filter_rare"],
"filter_water_vapor" = info["filter_water_vapor"]
"filter_types" = info["filter_types"]
))
data["mode"] = mode
data["modes"] = list()
Expand Down Expand Up @@ -337,8 +333,8 @@
if(usr.has_unlimited_silicon_privilege && !wires.is_cut(WIRE_IDSCAN))
locked = !locked
. = TRUE
if("power", "co2_scrub", "tox_scrub", "n2o_scrub", "rare_scrub","water_vapor_scrub", "widenet", "scrubbing")
send_signal(device_id, list("[action]" = text2num(params["val"])))
if("power", "toggle_filter", "widenet", "scrubbing")
send_signal(device_id, list("[action]" = params["val"]))
. = TRUE
if("excheck")
send_signal(device_id, list("checks" = text2num(params["val"])^1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_filter", name, 475, 180, master_ui, state)
ui = new(user, src, ui_key, "atmos_filter", name, 475, 195, master_ui, state)
ui.open()

/obj/machinery/atmospherics/components/trinary/filter/ui_data()
Expand All @@ -133,13 +133,11 @@
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)

if(filter_type) //ui code is garbage and this is needed for it to work grr
if(ispath(filter_type)) //we need to send the gas ID. if it's a path, get it from the metainfo list...
data["filter_type"] = GLOB.meta_gas_info[filter_type][META_GAS_ID]
else //...otherwise, it's already in the form we need.
data["filter_type"] = filter_type
else
data["filter_type"] = "none"
data["filter_types"] = list()
data["filter_types"] += list(list("name" = "Nothing", "path" = "", "selected" = !filter_type))
for(var/path in GLOB.meta_gas_info)
var/list/gas = GLOB.meta_gas_info[path]
data["filter_types"] += list(list("name" = gas[META_GAS_NAME], "id" = gas[META_GAS_ID], "selected" = (path == gas_id2path(filter_type))))

return data

Expand Down Expand Up @@ -169,7 +167,7 @@
if("filter")
filter_type = null
var/filter_name = "nothing"
var/gas = text2path(params["mode"]) || gas_id2path(params["mode"])
var/gas = gas_id2path(params["mode"])
if(gas in GLOB.meta_gas_info)
filter_type = gas
filter_name = GLOB.meta_gas_info[gas][META_GAS_NAME]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
var/on = FALSE
var/scrubbing = SCRUBBING //0 = siphoning, 1 = scrubbing

var/scrub_CO2 = TRUE
var/scrub_Toxins = FALSE
var/scrub_N2O = FALSE
var/scrub_Rare = FALSE
var/scrub_WaterVapor = FALSE

var/filter_types = list(/datum/gas/carbon_dioxide)

var/volume_rate = 200
var/widenet = 0 //is this scrubber acting on the 3x3 area around it.
Expand Down Expand Up @@ -64,16 +59,7 @@
var/amount = idle_power_usage

if(scrubbing & SCRUBBING)
if(scrub_CO2)
amount += idle_power_usage
if(scrub_Toxins)
amount += idle_power_usage
if(scrub_N2O)
amount += idle_power_usage
if(scrub_Rare)
amount += idle_power_usage
if(scrub_WaterVapor)
amount += idle_power_usage
amount += idle_power_usage * length(filter_types)
else //scrubbing == SIPHONING
amount = active_power_usage

Expand Down Expand Up @@ -115,6 +101,12 @@
var/datum/signal/signal = new
signal.transmission_method = 1 //radio signal
signal.source = src

var/list/f_types = list()
for(var/path in GLOB.meta_gas_info)
var/list/gas = GLOB.meta_gas_info[path]
f_types += list(list("gas_id" = gas[META_GAS_ID], "gas_name" = gas[META_GAS_NAME], "enabled" = (path in filter_types)))

signal.data = list(
"tag" = id_tag,
"frequency" = frequency,
Expand All @@ -123,11 +115,7 @@
"power" = on,
"scrubbing" = scrubbing,
"widenet" = widenet,
"filter_co2" = scrub_CO2,
"filter_toxins" = scrub_Toxins,
"filter_n2o" = scrub_N2O,
"filter_rare" =scrub_Rare,
"filter_water_vapor" = scrub_WaterVapor,
"filter_types" = f_types,
"sigtype" = "status"
)

Expand Down Expand Up @@ -179,7 +167,7 @@
for(var/id in env_gases)
if(id == /datum/gas/nitrogen || id == /datum/gas/oxygen)
continue
if(env_gases[id][MOLES])
if(env_gases[id][MOLES] && filter_types[id])
should_we_scrub = TRUE
break
if(should_we_scrub)
Expand All @@ -197,55 +185,10 @@
var/list/filtered_gases = filtered_out.gases
filtered_out.temperature = removed.temperature

if(scrub_Toxins && removed_gases[/datum/gas/plasma])
ADD_GAS(/datum/gas/plasma, filtered_gases)
filtered_gases[/datum/gas/plasma][MOLES] = removed_gases[/datum/gas/plasma][MOLES]
removed_gases[/datum/gas/plasma][MOLES] = 0

if(scrub_CO2 && removed_gases[/datum/gas/carbon_dioxide])
ADD_GAS(/datum/gas/carbon_dioxide, filtered_gases)
filtered_gases[/datum/gas/carbon_dioxide][MOLES] = removed_gases[/datum/gas/carbon_dioxide][MOLES]
removed_gases[/datum/gas/carbon_dioxide][MOLES] = 0

if(scrub_N2O && removed_gases[/datum/gas/nitrous_oxide])
ADD_GAS(/datum/gas/nitrous_oxide, filtered_gases)
filtered_gases[/datum/gas/nitrous_oxide][MOLES] = removed_gases[/datum/gas/nitrous_oxide][MOLES]
removed_gases[/datum/gas/nitrous_oxide][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/bz])
ADD_GAS(/datum/gas/bz, filtered_gases)
filtered_gases[/datum/gas/bz][MOLES] = removed_gases[/datum/gas/bz][MOLES]
removed_gases[/datum/gas/bz][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/hypernoblium])
ADD_GAS(/datum/gas/hypernoblium, filtered_gases)
filtered_gases[/datum/gas/hypernoblium][MOLES] = removed_gases[/datum/gas/hypernoblium][MOLES]
removed_gases[/datum/gas/hypernoblium][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/stimulum])
ADD_GAS(/datum/gas/stimulum, filtered_gases)
filtered_gases[/datum/gas/stimulum][MOLES] = removed_gases[/datum/gas/stimulum][MOLES]
removed_gases[/datum/gas/stimulum][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/pluoxium])
ADD_GAS(/datum/gas/pluoxium, filtered_gases)
filtered_gases[/datum/gas/pluoxium][MOLES] = removed_gases[/datum/gas/pluoxium][MOLES]
removed_gases[/datum/gas/pluoxium][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/nitryl])
ADD_GAS(/datum/gas/nitryl, filtered_gases)
filtered_gases[/datum/gas/nitryl][MOLES] = removed_gases[/datum/gas/nitryl][MOLES]
removed_gases[/datum/gas/nitryl][MOLES] = 0

if(scrub_Rare && removed_gases[/datum/gas/tritium])
ADD_GAS(/datum/gas/tritium, filtered_gases)
filtered_gases[/datum/gas/tritium][MOLES] = removed_gases[/datum/gas/tritium][MOLES]
removed_gases[/datum/gas/tritium][MOLES] = 0

if(scrub_WaterVapor && removed_gases[/datum/gas/water_vapor])
ADD_GAS(/datum/gas/water_vapor, filtered_gases)
filtered_gases[/datum/gas/water_vapor][MOLES] = removed_gases[/datum/gas/water_vapor][MOLES]
removed_gases[/datum/gas/water_vapor][MOLES] = 0
for(var/gas in filter_types & removed_gases)
ADD_GAS(gas, filtered_gases)
filtered_gases[gas][MOLES] = removed_gases[gas][MOLES]
removed_gases[gas][MOLES] = 0

removed.garbage_collect()

Expand Down Expand Up @@ -303,30 +246,8 @@
if("toggle_scrubbing" in signal.data)
scrubbing = !scrubbing

if("co2_scrub" in signal.data)
scrub_CO2 = text2num(signal.data["co2_scrub"])
if("toggle_co2_scrub" in signal.data)
scrub_CO2 = !scrub_CO2

if("tox_scrub" in signal.data)
scrub_Toxins = text2num(signal.data["tox_scrub"])
if("toggle_tox_scrub" in signal.data)
scrub_Toxins = !scrub_Toxins

if("n2o_scrub" in signal.data)
scrub_N2O = text2num(signal.data["n2o_scrub"])
if("toggle_n2o_scrub" in signal.data)
scrub_N2O = !scrub_N2O

if("rare_scrub" in signal.data)
scrub_Rare = text2num(signal.data["rare_scrub"])
if("toggle_rare_scrub" in signal.data)
scrub_Rare = !scrub_Rare

if("water_vapor_scrub" in signal.data)
scrub_WaterVapor = text2num(signal.data["water_vapor_scrub"])
if("toggle_water_vapor_scrub" in signal.data)
scrub_WaterVapor = !scrub_WaterVapor
if("toggle_filter" in signal.data)
filter_types ^= gas_id2path(signal.data["toggle_filter"])

if("init" in signal.data)
name = signal.data["init"]
Expand Down
11 changes: 10 additions & 1 deletion code/modules/atmospherics/machinery/portable/scrubber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.physical_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "portable_scrubber", name, 420, 335, master_ui, state)
ui = new(user, src, ui_key, "portable_scrubber", name, 420, 435, master_ui, state)
ui.open()

/obj/machinery/portable_atmospherics/scrubber/ui_data()
Expand All @@ -75,6 +75,12 @@
data["connected"] = connected_port ? 1 : 0
data["pressure"] = round(air_contents.return_pressure() ? air_contents.return_pressure() : 0)

data["id_tag"] = -1 //must be defined in order to reuse code between portable and vent scrubbers
data["filter_types"] = list()
for(var/path in GLOB.meta_gas_info)
var/list/gas = GLOB.meta_gas_info[path]
data["filter_types"] += list(list("gas_id" = gas[META_GAS_ID], "gas_name" = gas[META_GAS_NAME], "enabled" = (path in scrubbing)))

if(holding)
data["holding"] = list()
data["holding"]["name"] = holding.name
Expand All @@ -93,6 +99,9 @@
holding.loc = get_turf(src)
holding = null
. = TRUE
if("toggle_filter")
scrubbing ^= gas_id2path(params["val"])
. = TRUE
update_icon()

/obj/machinery/portable_atmospherics/scrubber/huge
Expand Down
2 changes: 1 addition & 1 deletion tgui/assets/tgui.css

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions tgui/assets/tgui.js

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions tgui/src/interfaces/airalarm/scrubbers.ract
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<link rel='ractive' href='./back.ract'>
<link rel='ractive' href='../scrubbing_types.ract' name='filters'>

<ui-display title='Scrubber Controls' button>
{{#partial button}}
Expand All @@ -19,16 +20,7 @@
action='widenet' params='{"id_tag": "{{id_tag}}", "val": {{+!widenet}}}'>{{widenet ? "Expanded" : "Normal"}}</ui-button>
</ui-section>
<ui-section label='Filters'>
<ui-button icon='{{filter_co2 ? "check-square-o" : "square-o"}}' style='{{filter_co2 ? "selected" : null}}'
action='co2_scrub' params='{"id_tag": "{{id_tag}}", "val": {{+!filter_co2}}}'>CO2</ui-button>
<ui-button icon='{{filter_n2o ? "check-square-o" : "square-o"}}' style='{{filter_n2o ? "selected" : null}}'
action='n2o_scrub' params='{"id_tag": "{{id_tag}}", "val": {{+!filter_n2o}}}'>N2O</ui-button>
<ui-button icon='{{filter_toxins ? "check-square-o" : "square-o"}}' style='{{filter_toxins ? "selected" : null}}'
action='tox_scrub' params='{"id_tag": "{{id_tag}}", "val": {{+!filter_toxins}}}'>Plasma</ui-button>
<ui-button icon='{{filter_rare ? "check-square-o" : "square-o"}}' style='{{filter_rare ? "selected" : null}}'
action='rare_scrub' params='{"id_tag": "{{id_tag}}", "val": {{+!filter_rare}}}'>Rare Gases</ui-button>
<ui-button icon='{{filter_water_vapor ? "check-square-o" : "square-o"}}' style='{{filter_water_vapor ? "selected" : null}}'
action='water_vapor_scrub' params='{"id_tag": "{{id_tag}}", "val": {{+!filter_water_vapor}}}'>Water Vapor</ui-button>
<filters/>
</ui-section>
</ui-subdisplay>
{{else}}
Expand Down
30 changes: 4 additions & 26 deletions tgui/src/interfaces/atmos_filter.ract
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,9 @@
<span>{{Math.round(adata.pressure)}} kPa</span>
</ui-section>
<ui-section label='Filter'>
<ui-button state='{{data.filter_type == "none" ? "selected" : null}}'
action='filter' params='{"mode": ""}'>Nothing</ui-button>
<ui-button state='{{data.filter_type == "plasma" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/plasma"}'>Plasma</ui-button>
<ui-button state='{{data.filter_type == "o2" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/oxygen"}'>O2</ui-button>
<ui-button state='{{data.filter_type == "n2" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/nitrogen"}'>N2</ui-button>
<ui-button state='{{data.filter_type == "co2" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/carbon_dioxide"}'>CO2</ui-button>
<ui-button state='{{data.filter_type == "n2o" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/nitrous_oxide"}'>N2O</ui-button>
<ui-button state='{{data.filter_type == "bz" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/bz"}'>BZ</ui-button>
<ui-button state='{{data.filter_type == "nob" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/hypernoblium"}'>Hyper-Noblium</ui-button>
<ui-button state='{{data.filter_type == "nitryl" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/nitryl"}'>Nitryl</ui-button>
<ui-button state='{{data.filter_type == "tritium" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/tritium"}'>Tritium</ui-button>
<ui-button state='{{data.filter_type == "stimulum" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/stimulum"}'>Stimulum</ui-button>
<ui-button state='{{data.filter_type == "pluox" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/pluoxium"}'>Pluoxium</ui-button>
<ui-button state='{{data.filter_type == "water_vapor" ? "selected" : null}}'
action='filter' params='{"mode": "/datum/gas/water_vapor"}'>Water Vapor</ui-button>
{{#each data.filter_types}}
<ui-button state='{{selected ? "selected" : null}}'
action='filter' params='{"mode": {{id}}}'>{{name}}</ui-button>
{{/each}}
</ui-section>
</ui-display>
7 changes: 7 additions & 0 deletions tgui/src/interfaces/portable_scrubber.ract
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<link rel='ractive' href='./scrubbing_types.ract' name='filters'>

<ui-notice>
<span>The regulator {{data.holding ? "is" : "is not"}} connected to a tank.</span>
</ui-notice>
Expand Down Expand Up @@ -35,3 +37,8 @@
</ui-section>
{{/if}}
</ui-display>
<ui-display title='Filters'>
{{#with data}}
<filters/>
{{/with}}
</ui-display>
4 changes: 4 additions & 0 deletions tgui/src/interfaces/scrubbing_types.ract
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{#each filter_types}}
<ui-button icon='{{enabled ? "check-square-o" : "square-o"}}' style='{{enabled ? "selected" : null}}'
action='toggle_filter' params='{"id_tag": "{{id_tag}}", "val": {{gas_id}}}'>{{gas_name}}</ui-button>
{{/each}}

0 comments on commit 33f2f2f

Please sign in to comment.