Skip to content

Commit

Permalink
Merge pull request tgstation#14928 from neersighted/tgui
Browse files Browse the repository at this point in the history
Fix tgui recursion being broken
  • Loading branch information
Cheridan committed Jan 27, 2016
2 parents 41a9a90 + 5e2e295 commit 5609bd0
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 149 deletions.
8 changes: 5 additions & 3 deletions code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,17 @@ Passive gate is similar to the regular pump except:
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
target_pressure = MAX_OUTPUT_PRESSURE
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))
if(pressure && !..())
. = TRUE
else if(text2num(pressure) != null)
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()

Expand Down
10 changes: 6 additions & 4 deletions code/ATMOSPHERICS/components/binary_devices/pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Thus, the two variables affect pump operation are set in New():

var/output_starting_pressure = air2.return_pressure()

if( (target_pressure - output_starting_pressure) < 0.01)
if((target_pressure - output_starting_pressure) < 0.01)
//No need to pump gas if target is already reached!
return 1

Expand Down Expand Up @@ -123,15 +123,17 @@ Thus, the two variables affect pump operation are set in New():
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
target_pressure = MAX_OUTPUT_PRESSURE
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))
if(pressure && !..())
. = TRUE
else if(text2num(pressure) != null)
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
update_icon()

Expand Down
14 changes: 7 additions & 7 deletions code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,17 @@ Thus, the two variables affect pump operation are set in New():
if("rate")
var/rate = params["rate"]
if(rate == "max")
transfer_rate = MAX_TRANSFER_RATE
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))
if(rate && !..())
. = TRUE
else if(text2num(rate) != null)
transfer_rate = Clamp(text2num(rate), 0, MAX_TRANSFER_RATE)
rate = text2num(rate)
. = TRUE
if(.)
transfer_rate = Clamp(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", "atmos")
update_icon()

Expand All @@ -156,12 +158,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()
broadcast_status()
return //do not update_icon

spawn(2)
broadcast_status()
broadcast_status()
update_icon()
return

Expand Down
8 changes: 5 additions & 3 deletions code/ATMOSPHERICS/components/trinary_devices/filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
target_pressure = MAX_OUTPUT_PRESSURE
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))
if(pressure && !..())
. = TRUE
else if(text2num(pressure) != null)
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if("filter")
filter_type = ""
Expand Down
32 changes: 17 additions & 15 deletions code/ATMOSPHERICS/components/trinary_devices/mixer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@
var/transfer_moles2 = 0

if(air1.temperature > 0)
transfer_moles1 = (node1_concentration*pressure_delta)*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
transfer_moles1 = (node1_concentration * pressure_delta) * air3.volume / (air1.temperature * R_IDEAL_GAS_EQUATION)

if(air2.temperature > 0)
transfer_moles2 = (node2_concentration*pressure_delta)*air3.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
transfer_moles2 = (node2_concentration * pressure_delta) * air3.volume / (air2.temperature * R_IDEAL_GAS_EQUATION)

var/air1_moles = air1.total_moles()
var/air2_moles = air2.total_moles()

if((air1_moles < transfer_moles1) || (air2_moles < transfer_moles2))
var/ratio = 0
if (( transfer_moles1 > 0 ) && (transfer_moles2 >0 ))
ratio = min(air1_moles/transfer_moles1, air2_moles/transfer_moles2)
if (( transfer_moles2 == 0 ) && ( transfer_moles1 > 0 ))
ratio = air1_moles/transfer_moles1
if (( transfer_moles1 == 0 ) && ( transfer_moles2 > 0 ))
ratio = air2_moles/transfer_moles2
if((transfer_moles1 > 0 ) && (transfer_moles2 > 0))
ratio = min(air1_moles / transfer_moles1, air2_moles / transfer_moles2)
if((transfer_moles2 == 0 ) && ( transfer_moles1 > 0))
ratio = air1_moles / transfer_moles1
if((transfer_moles1 == 0 ) && ( transfer_moles2 > 0))
ratio = air2_moles / transfer_moles2

transfer_moles1 *= ratio
transfer_moles2 *= ratio
Expand All @@ -105,16 +105,16 @@

if(transfer_moles1)
var/datum/pipeline/parent1 = PARENT1
parent1.update = 1
parent1.update = TRUE

if(transfer_moles2)
var/datum/pipeline/parent2 = PARENT2
parent2.update = 1
parent2.update = TRUE

var/datum/pipeline/parent3 = PARENT3
parent3.update = 1
parent3.update = TRUE

return 1
return TRUE

/obj/machinery/atmospherics/components/trinary/mixer/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = default_state)
Expand Down Expand Up @@ -143,15 +143,17 @@
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
target_pressure = MAX_OUTPUT_PRESSURE
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))
if(pressure && !..())
. = TRUE
else if(text2num(pressure) != null)
target_pressure = Clamp(text2num(pressure), 0, MAX_OUTPUT_PRESSURE)
pressure = text2num(pressure)
. = TRUE
if(.)
target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", "atmos")
if("node1")
var/value = text2num(params["concentration"])
Expand Down
20 changes: 13 additions & 7 deletions code/ATMOSPHERICS/components/unary_devices/thermomachine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
build_network()
return 1

/obj/machinery/atmospherics/components/unary/thermomachine/ui_status(mob/user)
if(interactive)
return ..()
return UI_CLOSE

/obj/machinery/atmospherics/components/unary/thermomachine/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
Expand All @@ -126,7 +131,7 @@
return data

/obj/machinery/atmospherics/components/unary/thermomachine/ui_act(action, params)
if(..() || !interactive)
if(..())
return
switch(action)
if("power")
Expand All @@ -139,15 +144,16 @@
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
if(target && !..())
. = TRUE
else if(adjust)
target_temperature += adjust
target = target_temperature + adjust
. = TRUE
else if(text2num(target) != null)
target = text2num(target)
. = TRUE
if(.)
target_temperature = Clamp(target_temperature, min_temperature, max_temperature)
target_temperature = Clamp(target, min_temperature, max_temperature)
investigate_log("was set to [target_temperature] K by [key_name(usr)]", "atmos")
update_icon()

Expand Down
6 changes: 2 additions & 4 deletions code/datums/wires/wires.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var/list/wire_colors = list( // http://www.crockford.com/wrrrld/color.html
"aqua",
"aquamarine",
"beige",
"black",
"blanchedalmond",
"blue",
"blueviolet",
Expand Down Expand Up @@ -154,12 +153,11 @@ var/list/wire_color_directory = list()
if(randomize)
randomize()
else
var/list/global_colors = wire_color_directory[holder_type]
if(!wire_color_directory[holder_type])
randomize()
global_colors = colors.Copy()
wire_color_directory[holder_type] = colors
else
colors = global_colors.Copy()
colors = wire_color_directory[holder_type]

/datum/wires/Destroy()
holder = null
Expand Down
16 changes: 5 additions & 11 deletions code/game/machinery/airalarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -343,32 +343,26 @@
send_signal(device_id, list("checks" = text2num(params["val"])^2))
. = TRUE
if("set_external_pressure")
var/value = text2num(params["value"])
if(value != null)
send_signal(device_id, list("set_external_pressure" = value))
var/target = input("New target pressure:", name, alarm_area.air_vent_info[device_id]["external"]) as num|null
if(target && !..())
send_signal(device_id, list("set_external_pressure" = target))
. = TRUE
else
value = input("New target pressure:", name, alarm_area.air_vent_info[device_id]["external"]) as num|null
. = .(action, params + list("value" = value))
if("reset_external_pressure")
send_signal(device_id, list("reset_external_pressure"))
. = TRUE
if("threshold")
var/env = params["env"]
var/name = params["var"]
var/value = text2num(params["value"])
var/datum/tlv/tlv = TLV[env]
if(isnull(tlv))
return
if(value != null)
var/value = input("New [name] for [env]:", name, tlv.vars[name]) as num|null
if(value && !..())
if(value < 0)
tlv.vars[name] = -1
else
tlv.vars[name] = round(value, 0.01)
. = TRUE
else
value = input("New [name] for [env]:", name, tlv.vars[name]) as num|null
. = .(action, params + list("value" = value))
if("screen")
screen = text2num(params["screen"])
. = TRUE
Expand Down
21 changes: 11 additions & 10 deletions code/game/machinery/atmoalter/canister.dm
Original file line number Diff line number Diff line change
Expand Up @@ -296,35 +296,36 @@ update_flag
return
switch(action)
if("relabel")
var/label = params["label"]
if(label)
var/label = input("New canister label:", name) as null|anything in label2types
if(label && !..())
var/newtype = label2types[label]
if(newtype)
var/obj/machinery/portable_atmospherics/canister/replacement = new newtype(loc)
replacement.air_contents.copy_from(air_contents)
replacement.update_icon()
replacement.interact(usr)
qdel(src)
else
label = input("New canister label:", name) as null|anything in label2types
.(action, list("label" = label))
if("pressure")
var/pressure = params["pressure"]
if(pressure == "reset")
release_pressure = CAN_DEFAULT_RELEASE_PRESSURE
pressure = CAN_DEFAULT_RELEASE_PRESSURE
. = TRUE
else if(pressure == "min")
release_pressure = CAN_MIN_RELEASE_PRESSURE
pressure = CAN_MIN_RELEASE_PRESSURE
. = TRUE
else if(pressure == "max")
release_pressure = CAN_MAX_RELEASE_PRESSURE
pressure = CAN_MAX_RELEASE_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New release pressure ([CAN_MIN_RELEASE_PRESSURE]-[CAN_MAX_RELEASE_PRESSURE] kPa):", name, release_pressure) as num|null
. = .(action, list("pressure" = pressure))
if(pressure && !..())
. = TRUE
else if(text2num(pressure) != null)
release_pressure = Clamp(round(text2num(pressure)), CAN_MIN_RELEASE_PRESSURE, CAN_MAX_RELEASE_PRESSURE)
pressure = text2num(pressure)
. = TRUE
if(.)
release_pressure = Clamp(round(pressure), CAN_MIN_RELEASE_PRESSURE, CAN_MAX_RELEASE_PRESSURE)
investigate_log("was set to [release_pressure] kPa by [key_name(usr)]", "atmos")
if("valve")
var/logmsg
valve_open = !valve_open
Expand Down
11 changes: 4 additions & 7 deletions code/game/machinery/computer/atmos_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,11 @@
signal.data += list("tag" = output_tag, "power_toggle" = TRUE)
. = TRUE
if("pressure")
var/pressure = text2num(params["pressure"])
if(pressure != null)
pressure = Clamp(pressure, 0, 50 * ONE_ATMOSPHERE)
signal.data += list("tag" = output_tag, "set_internal_pressure" = pressure)
var/target = input("New target pressure:", name, output_info["internal"]) as num|null
if(target && !..())
target = Clamp(target, 0, 50 * ONE_ATMOSPHERE)
signal.data += list("tag" = output_tag, "set_internal_pressure" = target)
. = TRUE
else
pressure = input("New output pressure:", name, input_info["internal"]) as num|null
. = .(action, params + list("pressure" = pressure))
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA)

/obj/machinery/computer/atmos_control/tank/receive_signal(datum/signal/signal)
Expand Down
15 changes: 8 additions & 7 deletions code/game/machinery/spaceheater.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,17 @@
var/target = params["target"]
var/adjust = text2num(params["adjust"])
if(target == "input")
target = input("New target temperature", name, round(targetTemperature - T0C, 1)) as num|null
. = .(action, list("target" = target))
else if(text2num(target) != null)
targetTemperature = text2num(target) + T0C
. = TRUE
target = input("New target temperature:", name, round(targetTemperature - T0C, 1)) as num|null
if(target && !..())
. = TRUE
else if(adjust)
targetTemperature += adjust
target = targetTemperature + adjust
. = TRUE
else if(text2num(target) != null)
target= text2num(target) + T0C
. = TRUE
if(.)
targetTemperature = Clamp(round(targetTemperature, 1),
targetTemperature = Clamp(round(target),
max(settableTemperatureMedian - settableTemperatureRange, TCMB),
settableTemperatureMedian + settableTemperatureRange)
if("eject")
Expand Down
13 changes: 7 additions & 6 deletions code/game/objects/items/devices/radio/radio.dm
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,16 @@
var/min = format_frequency(freerange ? MIN_FREE_FREQ : MIN_FREQ)
var/max = format_frequency(freerange ? MAX_FREE_FREQ : MAX_FREQ)
tune = input("Tune frequency ([min]-[max]):", name, format_frequency(frequency)) as null|num
. = .(action, list("tune" = tune))
else if(text2num(tune) != null)
frequency = tune * 10
. = TRUE
if(tune && !..())
. = TRUE
else if(adjust)
frequency += adjust * 10
tune = frequency + adjust * 10
. = TRUE
else if(text2num(tune) != null)
tune = tune * 10
. = TRUE
if(.)
frequency = sanitize_frequency(frequency, freerange)
frequency = sanitize_frequency(tune, freerange)
set_frequency(frequency)
if(frequency == traitor_frequency && hidden_uplink)
hidden_uplink.interact(usr)
Expand Down
Loading

0 comments on commit 5609bd0

Please sign in to comment.