mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-27 14:08:44 +01:00
APC NanoUI
* Created new APC UI * Tweaked Chem Master UI width.
This commit is contained in:
+90
-133
@@ -520,129 +520,87 @@
|
||||
user << browse(t1, "window=apcwires")
|
||||
onclose(user, "apcwires")
|
||||
|
||||
user.set_machine(src)
|
||||
var/t = "<html><head><title>[area.name] APC</title></head><body><TT><B>Area Power Controller</B> ([area.name])<HR>"
|
||||
|
||||
//This goes after the wire stuff. They should be able to fix a physical problem when a wire is cut
|
||||
if ( (get_dist(src, user) > 1 ))
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=apc")
|
||||
return
|
||||
else if (istype(user, /mob/living/silicon) && src.aidisabled && !src.malfhack)
|
||||
user << "AI control for this APC interface has been disabled."
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=apc")
|
||||
return
|
||||
else if (src.malfai)
|
||||
if ((src.malfai != user && src.malfai != user:parent) && !islinked(user, malfai))
|
||||
user << "AI control for this APC interface has been disabled."
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=apc")
|
||||
return
|
||||
|
||||
|
||||
if(locked && (!istype(user, /mob/living/silicon)))
|
||||
t += "<I>(Swipe ID card to unlock inteface.)</I><BR>"
|
||||
t += "Main breaker : <B>[operating ? "On" : "Off"]</B><BR>"
|
||||
t += "External power : <B>[ main_status ? (main_status ==2 ? "<FONT COLOR=#004000>Good</FONT>" : "<FONT COLOR=#D09000>Low</FONT>") : "<FONT COLOR=#F00000>None</FONT>"]</B><BR>"
|
||||
t += "Power cell: <B>[cell ? "[round(cell.percent())]%" : "<FONT COLOR=red>Not connected.</FONT>"]</B>"
|
||||
if(cell)
|
||||
t += " ([charging ? ( charging == 1 ? "Charging" : "Fully charged" ) : "Not charging"])"
|
||||
t += " ([chargemode ? "Auto" : "Off"])"
|
||||
|
||||
t += "<BR><HR>Power channels<BR><PRE>"
|
||||
|
||||
var/list/L = list ("Off","Off (Auto)", "On", "On (Auto)")
|
||||
|
||||
t += "Equipment: [add_lspace(lastused_equip, 6)] W : <B>[L[equipment+1]]</B><BR>"
|
||||
t += "Lighting: [add_lspace(lastused_light, 6)] W : <B>[L[lighting+1]]</B><BR>"
|
||||
t += "Environmental:[add_lspace(lastused_environ, 6)] W : <B>[L[environ+1]]</B><BR>"
|
||||
|
||||
t += "<BR>Total load: [lastused_light + lastused_equip + lastused_environ] W</PRE>"
|
||||
t += "<HR>Cover lock: <B>[coverlocked ? "Engaged" : "Disengaged"]</B>"
|
||||
|
||||
else
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
t += "<I>(Swipe ID card to lock interface.)</I><BR>"
|
||||
t += "Main breaker: [operating ? "<B>On</B> <A href='?src=\ref[src];breaker=1'>Off</A>" : "<A href='?src=\ref[src];breaker=1'>On</A> <B>Off</B>" ]<BR>"
|
||||
t += "External power : <B>[ main_status ? (main_status ==2 ? "<FONT COLOR=#004000>Good</FONT>" : "<FONT COLOR=#D09000>Low</FONT>") : "<FONT COLOR=#F00000>None</FONT>"]</B><BR>"
|
||||
if(cell)
|
||||
t += "Power cell: <B>[round(cell.percent())]%</B>"
|
||||
t += " ([charging ? ( charging == 1 ? "Charging" : "Fully charged" ) : "Not charging"])"
|
||||
t += " ([chargemode ? "<A href='?src=\ref[src];cmode=1'>Off</A> <B>Auto</B>" : "<B>Off</B> <A href='?src=\ref[src];cmode=1'>Auto</A>"])"
|
||||
|
||||
else
|
||||
t += "Power cell: <B><FONT COLOR=red>Not connected.</FONT></B>"
|
||||
|
||||
t += "<BR><HR>Power channels<BR><PRE>"
|
||||
|
||||
|
||||
t += "Equipment: [add_lspace(lastused_equip, 6)] W : "
|
||||
switch(equipment)
|
||||
if(0)
|
||||
t += "<B>Off</B> <A href='?src=\ref[src];eqp=2'>On</A> <A href='?src=\ref[src];eqp=3'>Auto</A>"
|
||||
if(1)
|
||||
t += "<A href='?src=\ref[src];eqp=1'>Off</A> <A href='?src=\ref[src];eqp=2'>On</A> <B>Auto (Off)</B>"
|
||||
if(2)
|
||||
t += "<A href='?src=\ref[src];eqp=1'>Off</A> <B>On</B> <A href='?src=\ref[src];eqp=3'>Auto</A>"
|
||||
if(3)
|
||||
t += "<A href='?src=\ref[src];eqp=1'>Off</A> <A href='?src=\ref[src];eqp=2'>On</A> <B>Auto (On)</B>"
|
||||
t +="<BR>"
|
||||
|
||||
t += "Lighting: [add_lspace(lastused_light, 6)] W : "
|
||||
|
||||
switch(lighting)
|
||||
if(0)
|
||||
t += "<B>Off</B> <A href='?src=\ref[src];lgt=2'>On</A> <A href='?src=\ref[src];lgt=3'>Auto</A>"
|
||||
if(1)
|
||||
t += "<A href='?src=\ref[src];lgt=1'>Off</A> <A href='?src=\ref[src];lgt=2'>On</A> <B>Auto (Off)</B>"
|
||||
if(2)
|
||||
t += "<A href='?src=\ref[src];lgt=1'>Off</A> <B>On</B> <A href='?src=\ref[src];lgt=3'>Auto</A>"
|
||||
if(3)
|
||||
t += "<A href='?src=\ref[src];lgt=1'>Off</A> <A href='?src=\ref[src];lgt=2'>On</A> <B>Auto (On)</B>"
|
||||
t +="<BR>"
|
||||
|
||||
|
||||
t += "Environmental:[add_lspace(lastused_environ, 6)] W : "
|
||||
switch(environ)
|
||||
if(0)
|
||||
t += "<B>Off</B> <A href='?src=\ref[src];env=2'>On</A> <A href='?src=\ref[src];env=3'>Auto</A>"
|
||||
if(1)
|
||||
t += "<A href='?src=\ref[src];env=1'>Off</A> <A href='?src=\ref[src];env=2'>On</A> <B>Auto (Off)</B>"
|
||||
if(2)
|
||||
t += "<A href='?src=\ref[src];env=1'>Off</A> <B>On</B> <A href='?src=\ref[src];env=3'>Auto</A>"
|
||||
if(3)
|
||||
t += "<A href='?src=\ref[src];env=1'>Off</A> <A href='?src=\ref[src];env=2'>On</A> <B>Auto (On)</B>"
|
||||
|
||||
|
||||
|
||||
t += "<BR>Total load: [lastused_light + lastused_equip + lastused_environ] W</PRE>"
|
||||
t += "<HR>Cover lock: [coverlocked ? "<B><A href='?src=\ref[src];lock=1'>Engaged</A></B>" : "<B><A href='?src=\ref[src];lock=1'>Disengaged</A></B>"]"
|
||||
|
||||
|
||||
if (istype(user, /mob/living/silicon))
|
||||
t += "<BR><HR><A href='?src=\ref[src];overload=1'><I>Overload lighting circuit</I></A><BR>"
|
||||
if (ticker && ticker.mode)
|
||||
// world << "there's a ticker"
|
||||
if(user.mind in ticker.mode.malf_ai)
|
||||
// world << "ticker says its malf"
|
||||
if (!src.malfai)
|
||||
t += "<BR><HR><A href='?src=\ref[src];malfhack=1'><I>Override Programming</I></A><BR>"
|
||||
else
|
||||
t += "<BR><HR><I>APC Hacked</I><BR>"
|
||||
/*if(!src.occupant)
|
||||
t += "<A href='?src=\ref[src];occupyapc=1'><I>Shunt Core Processes</I></A><BR>"
|
||||
else
|
||||
t += "<I>Core Processes Uploaded</I><BR>"*/
|
||||
|
||||
t += "<BR><HR><A href='?src=\ref[src];close=1'>Close</A>"
|
||||
|
||||
t += "</TT></body></html>"
|
||||
user << browse(t, "window=apc")
|
||||
onclose(user, "apc")
|
||||
// Open the APC NanoUI
|
||||
ui_interact(user)
|
||||
return
|
||||
|
||||
/obj/machinery/power/apc/proc/get_malf_status(mob/user)
|
||||
if (ticker && ticker.mode && (user.mind in ticker.mode.malf_ai) && istype(user, /mob/living/silicon/ai))
|
||||
if (src.malfai == (user:parent ? user:parent : user))
|
||||
if (src.occupant == user)
|
||||
return 3 // 3 = User is shunted in this APC
|
||||
else if (istype(user.loc, /obj/machinery/power/apc))
|
||||
return 4 // 4 = User is shunted in another APC
|
||||
else
|
||||
return 2 // 2 = APC hacked by user, and user is in its core.
|
||||
else
|
||||
return 1 // 1 = APC not hacked.
|
||||
else
|
||||
return 0 // 0 = User is not a Malf AI
|
||||
|
||||
/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||
if(!user)
|
||||
return
|
||||
|
||||
var/list/data = list(
|
||||
"locked" = locked,
|
||||
"isOperating" = operating,
|
||||
"externalPower" = main_status,
|
||||
"powerCellStatus" = cell ? cell.percent() : null,
|
||||
"chargeMode" = chargemode,
|
||||
"chargingStatus" = charging,
|
||||
"totalLoad" = lastused_equip + lastused_light + lastused_environ,
|
||||
"coverLocked" = coverlocked,
|
||||
"siliconUser" = istype(user, /mob/living/silicon),
|
||||
"malfStatus" = get_malf_status(user),
|
||||
|
||||
"powerChannels" = list(
|
||||
list(
|
||||
"title" = "Equipment",
|
||||
"powerLoad" = lastused_equip,
|
||||
"status" = equipment,
|
||||
"topicParams" = list(
|
||||
"auto" = list("eqp" = 3),
|
||||
"on" = list("eqp" = 2),
|
||||
"off" = list("eqp" = 1)
|
||||
)
|
||||
),
|
||||
list(
|
||||
"title" = "Lighting",
|
||||
"powerLoad" = lastused_light,
|
||||
"status" = lighting,
|
||||
"topicParams" = list(
|
||||
"auto" = list("lgt" = 3),
|
||||
"on" = list("lgt" = 2),
|
||||
"off" = list("lgt" = 1)
|
||||
)
|
||||
),
|
||||
list(
|
||||
"title" = "Environment",
|
||||
"powerLoad" = lastused_environ,
|
||||
"status" = environ,
|
||||
"topicParams" = list(
|
||||
"auto" = list("env" = 3),
|
||||
"on" = list("env" = 2),
|
||||
"off" = list("env" = 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "apc.tmpl", "[area.name] - APC", 520, data["siliconUser"] ? 465 : 440)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/power/apc/proc/report()
|
||||
return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
|
||||
|
||||
@@ -754,8 +712,8 @@
|
||||
istype(user, /mob/living/silicon) || \
|
||||
istype(user, /mob/living/carbon/monkey) /*&& ticker && ticker.mode.name == "monkey"*/) )
|
||||
user << "\red You don't have the dexterity to use this [src]!"
|
||||
user << browse(null, "window=apc")
|
||||
user.unset_machine()
|
||||
nanomanager.close_user_uis(user, src)
|
||||
|
||||
return 0
|
||||
if(user.restrained())
|
||||
user << "\red You must have free hands to use this [src]"
|
||||
@@ -776,13 +734,13 @@
|
||||
)
|
||||
if(!loud)
|
||||
user << "\red \The [src] have AI control disabled!"
|
||||
user << browse(null, "window=apc")
|
||||
user.unset_machine()
|
||||
nanomanager.close_user_uis(user, src)
|
||||
|
||||
return 0
|
||||
else
|
||||
if ((!in_range(src, user) || !istype(src.loc, /turf)))
|
||||
user << browse(null, "window=apc")
|
||||
user.unset_machine()
|
||||
nanomanager.close_user_uis(user, src)
|
||||
|
||||
return 0
|
||||
|
||||
var/mob/living/carbon/human/H = user
|
||||
@@ -800,9 +758,8 @@
|
||||
if(!(isrobot(usr) && (href_list["apcwires"] || href_list["pulse"])))
|
||||
if(!can_use(usr, 1))
|
||||
return
|
||||
src.add_fingerprint(usr)
|
||||
if(usingUI) // If we set their machine and they're not using the UI, it'll cause the UI to pop up.
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
if (href_list["apcwires"])
|
||||
var/t1 = text2num(href_list["apcwires"])
|
||||
if (!( istype(usr.get_active_hand(), /obj/item/weapon/wirecutters) ))
|
||||
@@ -864,12 +821,12 @@
|
||||
update_icon()
|
||||
update()
|
||||
else if( href_list["close"] )
|
||||
usr << browse(null, "window=apc")
|
||||
usr.unset_machine()
|
||||
nanomanager.close_user_uis(usr, src)
|
||||
|
||||
return
|
||||
else if (href_list["close2"])
|
||||
usr << browse(null, "window=apcwires")
|
||||
usr.unset_machine()
|
||||
|
||||
return
|
||||
|
||||
else if (href_list["overload"])
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
if (!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "chem_dispenser.tmpl", ui_title, 370, 605)
|
||||
ui = new(user, src, ui_key, "chem_dispenser.tmpl", ui_title, 380, 650)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
<div class='notice'>
|
||||
{{if siliconUser}}
|
||||
<div class="itemContentSmall">
|
||||
Interface Lock:
|
||||
</div>
|
||||
<div class="itemContentFull">
|
||||
{{:~link('Engaged', 'locked', {'toggleaccess' : 1}, locked ? 'selected' : null)}}{{:~link('Disengaged', 'unlocked', {'toggleaccess' : 1}, malfStatus >= 2 ? 'linkOff' : (locked ? null : 'selected'))}}
|
||||
</div>
|
||||
<div class="clearBoth"></div>
|
||||
{{else}}
|
||||
{{if locked}}
|
||||
Swipe an ID card to unlock this interface.
|
||||
{{else}}
|
||||
Swipe an ID card to lock this interface.
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div style="min-width: 480px">
|
||||
|
||||
<h3>Power Status</h3>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Main Breaker:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{if locked && !siliconUser}}
|
||||
{{if isOperating}}
|
||||
<span class='good'>On</span>
|
||||
{{else}}
|
||||
<span class='bad'>Off</span>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:~link('On', 'power', {'breaker' : 1}, isOperating ? 'selected' : null)}}{{:~link('Off', 'close', {'breaker' : 1}, isOperating ? null : 'selected')}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
External Power:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{if externalPower == 2}}
|
||||
<span class='good'>Good</span>
|
||||
{{else externalPower == 1}}
|
||||
<span class='average'>Low</span>
|
||||
{{else}}
|
||||
<span class='bad'>None</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Power Cell:
|
||||
</div>
|
||||
{{if powerCellStatus == null}}
|
||||
<div class="itemContent bad">
|
||||
Power cell removed.
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="itemContent" style="width: 60px">
|
||||
{{:~round(powerCellStatus*10)/10}}%
|
||||
</div>
|
||||
{{:~displayBar(powerCellStatus, 0, 100, powerCellStatus >= 50 ? 'good' : powerCellStatus >= 25 ? 'average' : 'bad')}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{if powerCellStatus != null}}
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Charge Mode:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{if locked && !siliconUser}}
|
||||
{{if chargeMode}}
|
||||
<span class='good'>Auto</span>
|
||||
{{else}}
|
||||
<span class='bad'>Off</span>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:~link('Auto', 'refresh', {'cmode' : 1}, chargeMode ? 'selected' : null)}}{{:~link('Off', 'close', {'cmode' : 1}, chargeMode ? null : 'selected')}}
|
||||
{{/if}}
|
||||
|
||||
{{if chargingStatus > 1}}
|
||||
[<span class='good'>Fully Charged</span>]
|
||||
{{else chargingStatus == 1}}
|
||||
[<span class='average'>Charging</span>]
|
||||
{{else}}
|
||||
[<span class='bad'>Not Charging</span>]
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
<h3>Power Channels</h3>
|
||||
|
||||
{{for powerChannels}}
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
{{:title}}:
|
||||
</div>
|
||||
<div class="itemContent" style="width: 70px; text-align: right">
|
||||
{{:powerLoad}} W
|
||||
</div>
|
||||
<div class="itemContent" style="width: 105px">
|
||||
|
||||
{{if status <= 1}}
|
||||
<span class='bad'>Off</span>
|
||||
{{else status >= 2}}
|
||||
<span class='good'>On</span>
|
||||
{{/if}}
|
||||
{{if status == 1 || status == 3}}
|
||||
[Auto]
|
||||
{{else}}
|
||||
[Manual]
|
||||
{{/if}}
|
||||
</div>
|
||||
{{if !~root.locked || ~root.siliconUser}}
|
||||
<div class="itemContentFull">
|
||||
{{:~link('Auto', 'refresh', topicParams.auto, (status == 1 || status == 3) ? 'selected' : null)}}
|
||||
{{:~link('On', 'power', topicParams.on, (status == 2) ? 'selected' : null)}}
|
||||
{{:~link('Off', 'close', topicParams.off, (status == 0) ? 'selected' : null)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/for}}
|
||||
|
||||
<div class="item" style="font-weight: bold">
|
||||
<div class="itemLabel">
|
||||
Total Load:
|
||||
</div>
|
||||
<div class="itemContent" style="width: 70px; text-align: right">
|
||||
{{:totalLoad}} W
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item"> </div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Cover Lock:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{if locked && !siliconUser}}
|
||||
{{if coverLocked}}
|
||||
<span class='good'>Engaged</span>
|
||||
{{else}}
|
||||
<span class='bad'>Disengaged</span>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{:~link('Engaged', 'locked', {'lock' : 1}, coverLocked ? 'selected' : null)}}{{:~link('Disengaged', 'unlocked', {'lock' : 1}, coverLocked ? null : 'selected')}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if siliconUser}}
|
||||
<h3>System Overrides</h3>
|
||||
|
||||
<div class="item">
|
||||
{{:~link('Overload Lighting Circuit', 'lightbulb', {'overload' : 1})}}
|
||||
{{if malfStatus == 1}}
|
||||
{{:~link('Override Programming', 'script', {'malfhack' : 1})}}
|
||||
{{else malfStatus > 1}}
|
||||
<div class='notice'>APC Hacked</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user