mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Scrubber NanoUI interface.
Ports https://github.com/d3athrow/vgstation13/pull/4142 with added Bay-flavor. To operate once must be adjacent to the scrubber. Silicons can view the status panel from any distance they are able to access the scrubber from. This preserves the current behavior.
This commit is contained in:
@@ -1297,6 +1297,7 @@
|
||||
#include "code\modules\nano\interaction\contained.dm"
|
||||
#include "code\modules\nano\interaction\default.dm"
|
||||
#include "code\modules\nano\interaction\inventory.dm"
|
||||
#include "code\modules\nano\interaction\physical.dm"
|
||||
#include "code\modules\nano\interaction\zlevel.dm"
|
||||
#include "code\modules\nano\modules\alarm_monitor.dm"
|
||||
#include "code\modules\nano\modules\crew_monitor.dm"
|
||||
|
||||
@@ -13,12 +13,19 @@
|
||||
power_rating = 7500 //7500 W ~ 10 HP
|
||||
power_losses = 150
|
||||
|
||||
var/minrate = 0
|
||||
var/maxrate = 10 * ONE_ATMOSPHERE
|
||||
|
||||
var/list/scrubbing_gas = list("phoron", "carbon_dioxide", "sleeping_agent", "oxygen_agent_b")
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/New()
|
||||
..()
|
||||
cell = new/obj/item/weapon/cell(src)
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/Destroy()
|
||||
qdel(holding)
|
||||
..()
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/emp_act(severity)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
..(severity)
|
||||
@@ -82,63 +89,55 @@
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/return_air()
|
||||
return air_contents
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/attack_ai(var/mob/user as mob)
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/attack_ai(var/mob/user)
|
||||
src.add_hiddenprint(user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/attack_hand(var/mob/user as mob)
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/attack_ghost(var/mob/user)
|
||||
return src.attack_hand(user)
|
||||
|
||||
user.set_machine(src)
|
||||
var/holding_text
|
||||
|
||||
if(holding)
|
||||
holding_text = {"<BR><B>Tank Pressure</B>: [round(holding.air_contents.return_pressure(), 0.01)] kPa<BR>
|
||||
<A href='?src=\ref[src];remove_tank=1'>Remove Tank</A>
|
||||
"}
|
||||
var/output_text = {"<TT><B>[name]</B><BR>
|
||||
Pressure: [round(air_contents.return_pressure(), 0.01)] kPa<BR>
|
||||
Flow Rate: [round(last_flow_rate, 0.1)] L/s<BR>
|
||||
Port Status: [(connected_port)?("Connected"):("Disconnected")]
|
||||
[holding_text]<BR>
|
||||
<BR>
|
||||
Cell Charge: [cell? "[round(cell.percent())]%" : "N/A"] | Load: [round(last_power_draw)] W<BR>
|
||||
Power Switch: <A href='?src=\ref[src];power=1'>[on?("On"):("Off")]</A><BR>
|
||||
Flow Rate Regulator: <A href='?src=\ref[src];volume_adj=-1000'>-</A> <A href='?src=\ref[src];volume_adj=-100'>-</A> <A href='?src=\ref[src];volume_adj=-10'>-</A> <A href='?src=\ref[src];volume_adj=-1'>-</A> [volume_rate] L/s <A href='?src=\ref[src];volume_adj=1'>+</A> <A href='?src=\ref[src];volume_adj=10'>+</A> <A href='?src=\ref[src];volume_adj=100'>+</A> <A href='?src=\ref[src];volume_adj=1000'>+</A><BR>
|
||||
|
||||
<HR>
|
||||
<A href='?src=\ref[user];mach_close=scrubber'>Close</A><BR>
|
||||
"}
|
||||
|
||||
user << browse(output_text, "window=scrubber;size=600x300")
|
||||
onclose(user, "scrubber")
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/attack_hand(var/mob/user)
|
||||
ui_interact(user)
|
||||
return
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/ui_interact(mob/user, ui_key = "rcon", datum/nanoui/ui=null, force_open=1)
|
||||
var/list/data[0]
|
||||
data["portConnected"] = connected_port ? 1 : 0
|
||||
data["tankPressure"] = round(air_contents.return_pressure() > 0 ? air_contents.return_pressure() : 0)
|
||||
data["rate"] = round(volume_rate)
|
||||
data["minrate"] = round(minrate)
|
||||
data["maxrate"] = round(maxrate)
|
||||
data["on"] = on ? 1 : 0
|
||||
|
||||
data["hasHoldingTank"] = holding ? 1 : 0
|
||||
if (holding)
|
||||
data["holdingTank"] = list("name" = holding.name, "tankPressure" = round(holding.air_contents.return_pressure() > 0 ? holding.air_contents.return_pressure() : 0))
|
||||
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "portscrubber.tmpl", "Portable Scrubber", 480, 400, state = physical_state)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/powered/scrubber/Topic(href, href_list)
|
||||
..()
|
||||
if (usr.stat || usr.restrained())
|
||||
return
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if (((get_dist(src, usr) <= 1) && istype(src.loc, /turf)))
|
||||
usr.set_machine(src)
|
||||
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
|
||||
if (href_list["remove_tank"])
|
||||
if(holding)
|
||||
holding.loc = loc
|
||||
holding = null
|
||||
|
||||
if (href_list["volume_adj"])
|
||||
var/diff = text2num(href_list["volume_adj"])
|
||||
volume_rate = min(initial(volume_rate), max(0, volume_rate+diff))
|
||||
|
||||
src.updateUsrDialog()
|
||||
src.add_fingerprint(usr)
|
||||
update_icon()
|
||||
else
|
||||
usr << browse(null, "window=scrubber")
|
||||
return
|
||||
return
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
. = 1
|
||||
if (href_list["remove_tank"])
|
||||
if(holding)
|
||||
holding.loc = loc
|
||||
holding = null
|
||||
. = 1
|
||||
if (href_list["volume_adj"])
|
||||
var/diff = text2num(href_list["volume_adj"])
|
||||
volume_rate = Clamp(volume_rate+diff, minrate, maxrate)
|
||||
. = 1
|
||||
update_icon()
|
||||
|
||||
|
||||
//Huge scrubber
|
||||
|
||||
@@ -89,15 +89,15 @@
|
||||
|
||||
/mob/living/default_can_use_topic(var/src_object)
|
||||
. = shared_nano_interaction(src_object)
|
||||
if(. == STATUS_INTERACTIVE)
|
||||
if(. != STATUS_CLOSE)
|
||||
if(loc)
|
||||
. = loc.contents_nano_distance(src_object, src)
|
||||
. = min(., loc.contents_nano_distance(src_object, src))
|
||||
if(STATUS_INTERACTIVE)
|
||||
return STATUS_UPDATE
|
||||
|
||||
/mob/living/carbon/human/default_can_use_topic(var/src_object)
|
||||
. = shared_nano_interaction(src_object)
|
||||
if(. == STATUS_INTERACTIVE)
|
||||
. = shared_living_nano_distance(src_object)
|
||||
if(. != STATUS_CLOSE)
|
||||
. = min(., shared_living_nano_distance(src_object))
|
||||
if(. == STATUS_UPDATE && (TK in mutations)) // If we have telekinesis and remain close enough, allow interaction.
|
||||
return STATUS_INTERACTIVE
|
||||
|
||||
18
code/modules/nano/interaction/physical.dm
Normal file
18
code/modules/nano/interaction/physical.dm
Normal file
@@ -0,0 +1,18 @@
|
||||
/var/global/datum/topic_state/physical/physical_state = new()
|
||||
|
||||
/datum/topic_state/physical/can_use_topic(var/src_object, var/mob/user)
|
||||
. = user.shared_nano_interaction(src_object)
|
||||
if(. > STATUS_CLOSE)
|
||||
return min(., user.check_physical_distance(src_object))
|
||||
|
||||
/mob/proc/check_physical_distance(var/src_object)
|
||||
return STATUS_CLOSE
|
||||
|
||||
/mob/dead/observer/check_physical_distance(var/src_object)
|
||||
return default_can_use_topic(src_object)
|
||||
|
||||
/mob/living/check_physical_distance(var/src_object)
|
||||
return shared_living_nano_distance(src_object)
|
||||
|
||||
/mob/living/silicon/check_physical_distance(var/src_object)
|
||||
return max(STATUS_UPDATE, shared_living_nano_distance(src_object))
|
||||
73
nano/templates/portscrubber.tmpl
Normal file
73
nano/templates/portscrubber.tmpl
Normal file
@@ -0,0 +1,73 @@
|
||||
<h3>Scrubber Status</h3>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Tank Pressure:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.tankPressure}} kPa
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Port Status:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.portConnected ? '<span class="good">Connected</span>' : '<span class="average">Disconnected</span>'}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Holding Tank Status</h3>
|
||||
{{if data.hasHoldingTank}}
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Tank Label:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
<div style="float: left; width: 180px;">{{:data.holdingTank.name}}</div> {{:helper.link('Eject', 'eject', {'remove_tank' : 1})}}
|
||||
</div>
|
||||
</div>q
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Tank Pressure:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:data.holdingTank.tankPressure}} kPa
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="item"><span class="average"><i>No holding tank inserted.</i></span></div>
|
||||
<div class="item"> </div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
<h3>Power Regulator Status</h3>
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Volume Rate:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.displayBar(data.rate, data.minrate, data.maxrate)}}
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
{{:helper.link('-', null, {'volume_adj' : -1000}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -100}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -10}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
{{:helper.link('-', null, {'volume_adj' : -1}, (data.rate > data.minrate) ? null : 'disabled')}}
|
||||
<div style="float: left; width: 80px; text-align: center;"> {{:data.rate}} kPa </div>
|
||||
{{:helper.link('+', null, {'volume_adj' : 1}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 10}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 100}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
{{:helper.link('+', null, {'volume_adj' : 1000}, (data.rate < data.maxrate) ? null : 'disabled')}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Power Switch:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{:helper.link('On', 'unlocked', {'power' : 1}, data.on ? 'selected' : null)}}{{:helper.link('Off', 'locked', {'power' : 1}, data.on ? null : 'selected')}}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user