mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 13:05:36 +01:00
Re-structure tgui's ui_act
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
|
||||
Passive gate is similar to the regular pump except:
|
||||
@@ -11,7 +10,7 @@ Passive gate is similar to the regular pump except:
|
||||
icon_state = "passgate_map"
|
||||
|
||||
name = "passive gate"
|
||||
desc = "A one-way air valve that does not require power"
|
||||
desc = "A one-way air valve that does not require power."
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
@@ -103,24 +102,32 @@ Passive gate is similar to the regular pump except:
|
||||
/obj/machinery/atmospherics/components/binary/passive_gate/get_ui_data()
|
||||
var/data = list()
|
||||
data["on"] = on
|
||||
data["set_pressure"] = round(target_pressure)
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/passive_gate/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("pressure")
|
||||
switch(params["pressure"])
|
||||
if ("max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
if ("custom")
|
||||
target_pressure = max(0, min(MAX_OUTPUT_PRESSURE, safe_input("Pressure control", "Enter new output pressure (0-[MAX_OUTPUT_PRESSURE] kPa)", target_pressure)))
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
var/pressure = params["pressure"]
|
||||
if(pressure == "max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
. = .(action, list("pressure" = pressure))
|
||||
else if(text2num(pressure) != null)
|
||||
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
|
||||
. = TRUE
|
||||
if(.)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/passive_gate/atmosinit()
|
||||
..()
|
||||
@@ -146,12 +153,10 @@ Passive gate is similar to the regular pump except:
|
||||
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
|
||||
|
||||
if("status" in signal.data)
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return //do not update_icon
|
||||
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return
|
||||
|
||||
broadcast_status()
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
/obj/machinery/atmospherics/components/binary/pump
|
||||
icon_state = "pump_map"
|
||||
name = "gas pump"
|
||||
desc = "A pump"
|
||||
desc = "A pump that moves gas by pressure."
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
@@ -114,24 +114,32 @@ Thus, the two variables affect pump operation are set in New():
|
||||
/obj/machinery/atmospherics/components/binary/pump/get_ui_data()
|
||||
var/data = list()
|
||||
data["on"] = on
|
||||
data["set_pressure"] = round(target_pressure)
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/pump/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("pressure")
|
||||
switch(params["pressure"])
|
||||
if("max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
if("custom")
|
||||
target_pressure = max(0, min(MAX_OUTPUT_PRESSURE, safe_input("Pressure control", "Enter new output pressure (0-[MAX_OUTPUT_PRESSURE] kPa)", target_pressure)))
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
var/pressure = params["pressure"]
|
||||
if(pressure == "max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
. = .(action, list("pressure" = pressure))
|
||||
else if(text2num(pressure) != null)
|
||||
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
|
||||
. = TRUE
|
||||
if(.)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/pump/atmosinit()
|
||||
..()
|
||||
@@ -157,12 +165,10 @@ Thus, the two variables affect pump operation are set in New():
|
||||
investigate_log("was turned [on ? "on" : "off"] by a remote signal", "atmos")
|
||||
|
||||
if("status" in signal.data)
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return //do not update_icon
|
||||
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return
|
||||
|
||||
broadcast_status()
|
||||
update_icon()
|
||||
return
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
/obj/machinery/atmospherics/components/binary/volume_pump
|
||||
icon_state = "volpump_map"
|
||||
name = "volumetric gas pump"
|
||||
desc = "A volumetric pump"
|
||||
desc = "A pump that moves gas by volume."
|
||||
|
||||
can_unwrench = 1
|
||||
|
||||
@@ -110,7 +110,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
/obj/machinery/atmospherics/components/binary/volume_pump/get_ui_data()
|
||||
var/data = list()
|
||||
data["on"] = on
|
||||
data["transfer_rate"] = round(transfer_rate)
|
||||
data["rate"] = round(transfer_rate)
|
||||
data["max_rate"] = round(MAX_TRANSFER_RATE)
|
||||
return data
|
||||
|
||||
@@ -120,19 +120,27 @@ Thus, the two variables affect pump operation are set in New():
|
||||
set_frequency(frequency)
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/volume_pump/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
if("transfer")
|
||||
switch(params["rate"])
|
||||
if("max")
|
||||
transfer_rate = MAX_TRANSFER_RATE
|
||||
if("custom")
|
||||
transfer_rate = max(0, min(MAX_TRANSFER_RATE, safe_input("Pressure control", "Enter new transfer rate (0-[MAX_TRANSFER_RATE] L/s)", transfer_rate)))
|
||||
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("rate")
|
||||
var/rate = params["rate"]
|
||||
if(rate == "max")
|
||||
transfer_rate = MAX_TRANSFER_RATE
|
||||
. = TRUE
|
||||
else if(rate == "input")
|
||||
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, transfer_rate) as num|null
|
||||
. = .(action, list("rate" = rate))
|
||||
else if(text2num(rate) != null)
|
||||
transfer_rate = Clamp(text2num(rate), 0, MAX_TRANSFER_RATE)
|
||||
. = TRUE
|
||||
if(.)
|
||||
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/components/binary/volume_pump/receive_signal(datum/signal/signal)
|
||||
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
#define FILTER_NOTHING ""
|
||||
//very cleverly using the gas IDs so as to simplify a bunch of logic
|
||||
#define FILTER_PLASMA "plasma"
|
||||
#define FILTER_OXYGEN "o2"
|
||||
#define FILTER_NITROGEN "n2"
|
||||
#define FILTER_CARBONDIOXIDE "co2"
|
||||
#define FILTER_NITROUSOXIDE "n2o"
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/filter
|
||||
name = "gas filter"
|
||||
icon_state = "filter_off"
|
||||
@@ -13,7 +5,7 @@
|
||||
can_unwrench = 1
|
||||
var/on = 0
|
||||
var/target_pressure = ONE_ATMOSPHERE
|
||||
var/filter_type = FILTER_PLASMA
|
||||
var/filter_type = ""
|
||||
var/frequency = 0
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
@@ -98,10 +90,6 @@
|
||||
filtered_out.assert_gas(filter_type)
|
||||
filtered_out.gases[filter_type][MOLES] = removed.gases[filter_type][MOLES]
|
||||
removed.gases[filter_type][MOLES] = 0
|
||||
if(filter_type == FILTER_PLASMA && removed.gases["agent_b"])
|
||||
filtered_out.assert_gas("agent_b")
|
||||
filtered_out.gases["agent_b"][MOLES] = removed.gases["agent_b"][MOLES]
|
||||
removed.gases["agent_b"][MOLES] = 0
|
||||
removed.garbage_collect()
|
||||
else
|
||||
filtered_out = null
|
||||
@@ -133,37 +121,39 @@
|
||||
/obj/machinery/atmospherics/components/trinary/filter/get_ui_data()
|
||||
var/data = list()
|
||||
data["on"] = on
|
||||
data["set_pressure"] = round(target_pressure)
|
||||
data["pressure"] = round(target_pressure)
|
||||
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
|
||||
data["filter_type"] = filter_type
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/filter/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("pressure")
|
||||
switch(params["pressure"])
|
||||
if("max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
if("custom")
|
||||
target_pressure = max(0, min(MAX_OUTPUT_PRESSURE, safe_input("Pressure control", "Enter new output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", target_pressure)))
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
var/pressure = params["pressure"]
|
||||
if(pressure == "max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
. = .(action, list("pressure" = pressure))
|
||||
else if(text2num(pressure) != null)
|
||||
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
|
||||
. = TRUE
|
||||
if(.)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if("filter")
|
||||
filter_type = params["mode"]
|
||||
var/filtering_name = "nothing"
|
||||
switch(filter_type)
|
||||
if(FILTER_PLASMA)
|
||||
filtering_name = "plasma"
|
||||
if(FILTER_OXYGEN)
|
||||
filtering_name = "oxygen"
|
||||
if(FILTER_NITROGEN)
|
||||
filtering_name = "nitrogen"
|
||||
if(FILTER_CARBONDIOXIDE)
|
||||
filtering_name = "carbon dioxide"
|
||||
if(FILTER_NITROUSOXIDE)
|
||||
filtering_name = "nitrous oxide"
|
||||
investigate_log("was set to filter [filtering_name] by [key_name(usr)]", "atmos")
|
||||
filter_type = ""
|
||||
var/filter_name = "nothing"
|
||||
var/mode = params["mode"]
|
||||
if(mode in meta_gas_info)
|
||||
filter_type = mode
|
||||
filter_name = meta_gas_info[mode][META_GAS_NAME]
|
||||
investigate_log("was set to filter [filter_name] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
@@ -139,26 +139,36 @@
|
||||
return data
|
||||
|
||||
/obj/machinery/atmospherics/components/trinary/mixer/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("power")
|
||||
on = !on
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("pressure")
|
||||
switch(params["pressure"])
|
||||
if("max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
if("custom")
|
||||
target_pressure = max(0, min(MAX_OUTPUT_PRESSURE, safe_input("Pressure control", "Enter new output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", target_pressure)))
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
var/pressure = params["pressure"]
|
||||
if(pressure == "max")
|
||||
target_pressure = MAX_OUTPUT_PRESSURE
|
||||
. = TRUE
|
||||
else if(pressure == "input")
|
||||
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
|
||||
. = .(action, list("pressure" = pressure))
|
||||
else if(text2num(pressure) != null)
|
||||
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
|
||||
. = TRUE
|
||||
if(.)
|
||||
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
|
||||
if("node1")
|
||||
var/value = text2num(params["concentration"])
|
||||
src.node1_concentration = max(0, min(1, src.node1_concentration + value))
|
||||
src.node2_concentration = max(0, min(1, src.node2_concentration - value))
|
||||
node1_concentration = max(0, min(1, node1_concentration + value))
|
||||
node2_concentration = max(0, min(1, node2_concentration - value))
|
||||
investigate_log("was set to [node1_concentration] % on node 1 by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("node2")
|
||||
var/value = text2num(params["concentration"])
|
||||
src.node2_concentration = max(0, min(1, src.node2_concentration + value))
|
||||
src.node1_concentration = max(0, min(1, src.node1_concentration - value))
|
||||
node2_concentration = max(0, min(1, node2_concentration + value))
|
||||
node1_concentration = max(0, min(1, node1_concentration - value))
|
||||
investigate_log("was set to [node2_concentration] % on node 2 by [key_name(usr)]", "atmos")
|
||||
update_icon()
|
||||
return 1
|
||||
. = TRUE
|
||||
update_icon()
|
||||
@@ -230,23 +230,25 @@
|
||||
/obj/machinery/atmospherics/components/unary/cryo_cell/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
switch(action)
|
||||
if("power")
|
||||
if(on)
|
||||
on = FALSE
|
||||
else if(!state_open)
|
||||
on = TRUE
|
||||
. = TRUE
|
||||
if("door")
|
||||
if(state_open)
|
||||
close_machine()
|
||||
else
|
||||
open_machine()
|
||||
. = TRUE
|
||||
if("autoeject")
|
||||
autoeject = !autoeject
|
||||
. = TRUE
|
||||
if("ejectbeaker")
|
||||
if(beaker)
|
||||
beaker.loc = loc
|
||||
beaker = null
|
||||
. = TRUE
|
||||
update_icon()
|
||||
return 1
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/thermomachine/process_atmos()
|
||||
..()
|
||||
if(!on)
|
||||
return 0
|
||||
if(!on || !NODE1)
|
||||
return
|
||||
var/datum/gas_mixture/air_contents = AIR1
|
||||
|
||||
var/air_heat_capacity = air_contents.heat_capacity()
|
||||
@@ -100,7 +100,7 @@
|
||||
data["min"] = min_temperature
|
||||
data["max"] = max_temperature
|
||||
data["target"] = target_temperature
|
||||
data["initial"] = T20C
|
||||
data["initial"] = initial(target_temperature)
|
||||
|
||||
var/datum/gas_mixture/air1 = AIR1
|
||||
data["temperature"] = air1.temperature
|
||||
@@ -114,15 +114,24 @@
|
||||
if("power")
|
||||
on = !on
|
||||
use_power = 1 + on
|
||||
update_icon()
|
||||
return 1
|
||||
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
|
||||
. = TRUE
|
||||
if("target")
|
||||
target_temperature += text2num(params["adjust"])
|
||||
if(min_temperature)
|
||||
target_temperature = Clamp(target_temperature, min_temperature, T20C)
|
||||
else if(max_temperature)
|
||||
target_temperature = Clamp(target_temperature, T20C, max_temperature)
|
||||
return 1
|
||||
var/target = params["target"]
|
||||
var/adjust = text2num(params["adjust"])
|
||||
if(target == "input")
|
||||
target = input("Set new target ([min_temperature]-[max_temperature] K):", name, target_temperature) as num|null
|
||||
. = .(action, list("target" = target))
|
||||
else if(text2num(target) != null)
|
||||
target_temperature = text2num(target)
|
||||
. = TRUE
|
||||
else if(adjust)
|
||||
target_temperature += adjust
|
||||
. = TRUE
|
||||
if(.)
|
||||
target_temperature = Clamp(target_temperature, min_temperature, max_temperature)
|
||||
investigate_log("was set to [target_temperature] K by [key_name(usr)]", "atmos")
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/thermomachine/freezer
|
||||
name = "freezer"
|
||||
@@ -130,6 +139,8 @@
|
||||
icon_state = "freezer"
|
||||
icon_state_on = "freezer_1"
|
||||
icon_state_open = "freezer-o"
|
||||
max_temperature = T20C
|
||||
min_temperature = 170
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/thermomachine/freezer/New()
|
||||
..()
|
||||
@@ -140,7 +151,7 @@
|
||||
var/L
|
||||
for(var/obj/item/weapon/stock_parts/micro_laser/M in component_parts)
|
||||
L += M.rating
|
||||
min_temperature = max(T0C - (170 + L * 15), TCMB)
|
||||
min_temperature = max(T0C - (initial(min_temperature) + L * 15), TCMB)
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/thermomachine/heater
|
||||
name = "heater"
|
||||
@@ -148,6 +159,8 @@
|
||||
icon_state = "heater"
|
||||
icon_state_on = "heater_1"
|
||||
icon_state_open = "heater-o"
|
||||
max_temperature = 140
|
||||
min_temperature = T20C
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/thermomachine/heater/New()
|
||||
..()
|
||||
@@ -158,4 +171,4 @@
|
||||
var/L
|
||||
for(var/obj/item/weapon/stock_parts/micro_laser/M in component_parts)
|
||||
L += M.rating
|
||||
max_temperature = T20C + (140 * L)
|
||||
max_temperature = T20C + (initial(max_temperature) * L)
|
||||
|
||||
Reference in New Issue
Block a user