Re-structure tgui's ui_act

This commit is contained in:
Bjorn Neergaard
2016-01-22 18:03:30 -06:00
parent 4c192d705a
commit 1599742f7e
47 changed files with 713 additions and 621 deletions
+5 -1
View File
@@ -226,12 +226,16 @@ var/global/image/fire_overlay = image("icon" = 'icons/effects/fire.dmi', "icon_s
interact(user)
/obj/item/interact(mob/user)
add_fingerprint(user)
if(hidden_uplink && hidden_uplink.active)
hidden_uplink.interact(user)
return 1
add_fingerprint(user)
ui_interact(user)
/obj/item/ui_act(action, params)
..()
add_fingerprint(usr)
/obj/item/attack_hand(mob/user)
if(!user)
return
+25 -13
View File
@@ -117,7 +117,7 @@
datum/tgui/master_ui = null, datum/ui_state/state = inventory_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "radio", name, 830, 275, master_ui, state)
ui = new(user, src, ui_key, "radio", name, 370, 220 + channels.len * 22, master_ui, state)
ui.open()
/obj/item/device/radio/get_ui_data(mob/user)
@@ -141,27 +141,37 @@
return data
/obj/item/device/radio/ui_act(action, params)
if(..())
return
switch(action)
if("frequency")
if(!freqlock)
switch(params["change"])
if("custom")
var/min = format_frequency(freerange ? MIN_FREE_FREQ : MIN_FREQ)
var/max = format_frequency(freerange ? MAX_FREE_FREQ : MAX_FREQ)
var/custom = input(usr, "Adjust frequency ([min]-[max]):", name) as null|num
if(custom)
frequency = custom * 10
else
frequency = frequency + text2num(params["change"])
if(freqlock)
return
var/tune = params["tune"]
var/adjust = text2num(params["adjust"])
if(tune == "input")
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
else if(adjust)
frequency += adjust * 10
. = TRUE
if(.)
frequency = sanitize_frequency(frequency, freerange)
set_frequency(frequency)
if(hidden_uplink && (frequency == traitor_frequency))
if(frequency == traitor_frequency && hidden_uplink)
hidden_uplink.interact(usr)
SStgui.close_uis(src)
if("listen")
listening = !listening
. = TRUE
if("broadcast")
broadcasting = !broadcasting
. = TRUE
if("channel")
var/channel = params["channel"]
if(!(channel in channels))
@@ -170,8 +180,10 @@
channels[channel] &= ~FREQ_LISTENING
else
channels[channel] |= FREQ_LISTENING
. = TRUE
if("command")
use_command = !use_command
. = TRUE
if("subspace")
if(subspace_switchable)
subspace_transmission = !subspace_transmission
@@ -179,7 +191,7 @@
channels = list()
else
recalculateChannels()
return 1
. = TRUE
/obj/item/device/radio/talk_into(atom/movable/M, message, channel, list/spans)
if(!on) return // the device has to be on
+48 -51
View File
@@ -114,71 +114,68 @@
ui.open()
/obj/item/weapon/tank/get_ui_data()
var/mob/living/carbon/location = null
if(istype(loc, /mob/living/carbon))
location = loc
else if(istype(loc.loc, /mob/living/carbon))
location = loc.loc
var/data = list()
var/list/data = list()
data["tankPressure"] = round(air_contents.return_pressure() ? air_contents.return_pressure() : 0)
data["releasePressure"] = round(distribute_pressure ? distribute_pressure : 0)
data["defaultReleasePressure"] = round(TANK_DEFAULT_RELEASE_PRESSURE)
data["minReleasePressure"] = round(TANK_MIN_RELEASE_PRESSURE)
data["maxReleasePressure"] = round(TANK_MAX_RELEASE_PRESSURE)
data["valveOpen"] = 0
data["maskConnected"] = 0
data["valveOpen"] = FALSE
data["maskConnected"] = FALSE
if(istype(location))
var/mask_check = 0
if(location.internal == src) // if tank is current internal
mask_check = 1
data["valveOpen"] = 1
else if(src in location) // or if tank is in the mobs possession
if(!location.internal) // and they do not have any active internals
mask_check = 1
if(mask_check)
if(location.wear_mask && (location.wear_mask.flags & MASKINTERNALS))
data["maskConnected"] = 1
var/mob/living/carbon/user = loc
var/mask = FALSE
if(!istype(user))
user = loc.loc
if(!istype(user))
user = null
if(!isnull(user) && user.internal == src)
mask = TRUE
data["valveOpen"] = TRUE
else if(src in user && !user.internal)
mask = TRUE
if(mask && user.wear_mask && (user.wear_mask.flags & MASKINTERNALS))
data["maskConnected"] = TRUE
return data
/obj/item/weapon/tank/ui_act(action, params)
if (..())
if(..())
return
switch(action)
if("pressure")
switch(params["pressure"])
if("custom")
var/custom = input(usr, "What rate do you set the regulator to? The dial reads from 0 to [TANK_MAX_RELEASE_PRESSURE].") as null|num
if(isnum(custom))
distribute_pressure = custom
if("reset")
distribute_pressure = TANK_DEFAULT_RELEASE_PRESSURE
if("min")
distribute_pressure = TANK_MIN_RELEASE_PRESSURE
if("max")
distribute_pressure = TANK_MAX_RELEASE_PRESSURE
distribute_pressure = Clamp(round(distribute_pressure), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE)
var/pressure = params["pressure"]
if(pressure == "reset")
distribute_pressure = TANK_DEFAULT_RELEASE_PRESSURE
. = TRUE
else if(pressure == "min")
distribute_pressure = TANK_MIN_RELEASE_PRESSURE
. = TRUE
else if(pressure == "max")
distribute_pressure = TANK_MAX_RELEASE_PRESSURE
. = TRUE
else if(pressure == "input")
pressure = input("New release pressure ([TANK_MIN_RELEASE_PRESSURE]-[TANK_MAX_RELEASE_PRESSURE] kPa):", name, distribute_pressure) as num|null
. = .(action, list("pressure" = pressure))
else if(text2num(pressure) != null)
distribute_pressure = Clamp(round(text2num(pressure)), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE)
. = TRUE
if("valve")
if(istype(loc,/mob/living/carbon))
var/mob/living/carbon/location = loc
if(location.internal == src)
location.internal = null
location.internals.icon_state = "internal0"
usr << "<span class='notice'>You close the tank release valve.</span>"
if (location.internals)
location.internals.icon_state = "internal0"
var/mob/living/carbon/user = loc
if(!istype(user))
return
if(user.internal == src)
user.internal = null
user.internals.icon_state = "internal0"
usr << "<span class='notice'>You close the tank release valve.</span>"
. = TRUE
else
if(user.wear_mask && (user.wear_mask.flags & MASKINTERNALS))
user.internal = src
user.internals.icon_state = "internal1"
usr << "<span class='notice'>You open [src] valve.</span>"
. = TRUE
else
if(location.wear_mask && (location.wear_mask.flags & MASKINTERNALS))
location.internal = src
usr << "<span class='notice'>You open \the [src] valve.</span>"
if (location.internals)
location.internals.icon_state = "internal1"
else
usr << "<span class='warning'>You need something to connect to \the [src]!</span>"
return 1
usr << "<span class='warning'>You need something to connect to [src]!</span>"
/obj/item/weapon/tank/remove_air(amount)