Merge pull request #1747 from YotaXP/NanoUI-APC

Implements NanoUI for APCs
This commit is contained in:
Cheridan
2013-11-11 11:38:36 -08:00
10 changed files with 212 additions and 172 deletions
+2
View File
@@ -75,6 +75,8 @@ datum/mind
if(new_character.mind) //disassociate any mind currently in our new body's mind variable
new_character.mind.current = null
nanomanager.user_transferred(current, new_character)
current = new_character //associate ourself with our new body
new_character.mind = src //and associate our new body with ourself
+1
View File
@@ -236,6 +236,7 @@ var/next_external_rsc = 0
'nano/css/shared.css',
'nano/css/icons.css',
'nano/templates/chem_dispenser.tmpl',
'nano/templates/apc.tmpl',
'nano/templates/cryo.tmpl',
'nano/images/uiBackground.png',
'nano/images/uiIcons16.png',
+21
View File
@@ -112,5 +112,26 @@
for (var/datum/nanoui/ui in user.open_uis)
ui.close();
/**
* This is called when a player transfers from one mob to another
* Transfers all open UIs to the new mob
*
* @param oldMob /mob The user's old mob
* @param newMob /mob The user's new mob
*
* @return nothing
*/
/datum/nanomanager/proc/user_transferred(var/mob/oldMob, var/mob/newMob)
if (isnull(oldMob.open_uis) || !istype(oldMob.open_uis, /list) || open_uis.len == 0)
return 0 // has no open uis
if (isnull(newMob.open_uis) || !istype(newMob.open_uis, /list))
newMob.open_uis = list()
for (var/datum/nanoui/ui in oldMob.open_uis)
ui.user = newMob
newMob.open_uis.Add(ui)
oldMob.open_uis.Cut()
+1
View File
@@ -349,6 +349,7 @@ nanoui is used to open and update nano browser uis
window_size = "size=[width]x[height];"
update_status(0)
user << browse(get_html(), "window=[window_id];[window_size][window_options]")
winset(user, "mapwindow.map", "focus=true") // Return keyboard focus to map.
on_close_winset()
//onclose(user, window_id)
nanomanager.ui_opened(src)
+90 -128
View File
@@ -485,134 +485,87 @@
if(wiresexposed /*&& (!istype(user, /mob/living/silicon))*/) //Commented out the typecheck to allow engiborgs to repair damaged apcs.
wires.Interact(user)
user.set_machine(src)
var/t = "" //"<B>Area Power Controller</B> ([area.name])"
//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 (!issilicon(user))
user.unset_machine()
user << browse(null, "window=apc")
return
else if (issilicon(user) && 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 && isAI(user))
var/mob/living/silicon/ai/AI = user
if ((src.malfai != AI && src.malfai != AI.parent) && !islinked(AI, malfai))
user << "AI control for this APC interface has been disabled."
user.unset_machine()
user << browse(null, "window=apc")
return
return ui_interact(user)
if(locked && (!istype(user, /mob/living/silicon)))
t += "<div class='notice icon'>Swipe ID card to unlock interface</div>"
t += "<h3>Status</h3>"
t += "Main Breaker: <B>[operating ? "<font class='good'>On</font>" : "<font class='bad'>Off</font>"]</B><br />"
t += "External Power: <B>[ main_status ? (main_status ==2 ? "<font class='good'>Good</font>" : "<font class='average'>Low</font>") : "<font class='bad'>None</font>"]</B><br />"
t += "Power Cell: <B>[cell ? "[round(cell.percent())]%" : "<font COLOR=red>Not connected.</font>"]</B>"
if(cell)
t += "<BR/>Charge Mode: [chargemode ? "Auto" : "Off"]"
t += " ([charging ? ( charging == 1 ? "Charging" : "Fully charged" ) : "Not charging"])"
/obj/machinery/power/apc/ui_interact(mob/user, ui_key = "main")
if(!user)
return
t += "<h3>Power Channels</h3><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 += "<br />Cover Lock: <B>[coverlocked ? "Engaged" : "Disengaged"]</B>"
else
if (!istype(user, /mob/living/silicon))
t += "<div class='notice icon'>Swipe ID card to lock interface</div>"
t += "<h3>Status</h3>"
t += "Main Breaker: [operating ? "<span class='linkOn'>On</span> <A href='?src=\ref[src];breaker=1'>Off</A>" : "<A href='?src=\ref[src];breaker=1'>On</A> <span class='linkOn'>Off</span>" ]<br />"
t += "External power : <B>[ main_status ? (main_status ==2 ? "<font class='good'>Good</font>" : "<font class='average'>Low</font>") : "<font class='bad'>None</font>"]</B><br />"
if(cell)
t += "Power cell: <B>[round(cell.percent())]%</B>"
t += "<BR/>Charge mode: [chargemode ? "<A href='?src=\ref[src];cmode=1'>Off</A> <span class='linkOn'>Auto</span>" : "<span class='linkOn'>Off</span> <A href='?src=\ref[src];cmode=1'>Auto</A>"]"
t += " ([charging ? ( charging == 1 ? "Charging" : "Fully charged" ) : "Not charging"])"
var/malfStatus
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)
malfStatus = 3 // 3 = User is shunted in this APC
else if (istype(user.loc, /obj/machinery/power/apc))
malfStatus = 4 // 4 = User is shunted in another APC
else
malfStatus = 2 // 2 = APC hacked by user, and user is in its core.
else
t += "Power cell: <B><font COLOR=red>Not connected.</font></B>"
malfStatus = 1 // 1 = APC not hacked.
else
malfStatus = 0 // 0 = User is not a Malf AI
t += "<br /><h3>Power channels</h3><PRE>"
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" = malfStatus,
t += "Equipment: [add_lspace(lastused_equip, 6)] W : "
var/key = "eqp"
switch(equipment)
if(0)
t += "<span class='linkOn'>Off</span> <A href='?src=\ref[src];[key]=2'>On</A> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(1)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (Off)</span>"
if(2)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <span class='linkOn'>On</span> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(3)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (On)</span>"
t +="<br />"
"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)
)
)
)
)
t += "Lighting: [add_lspace(lastused_light, 6)] W : "
key = "lgt"
switch(lighting)
if(0)
t += "<span class='linkOn'>Off</span> <A href='?src=\ref[src];[key]=2'>On</A> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(1)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (Off)</span>"
if(2)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <span class='linkOn'>On</span> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(3)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (On)</span>"
t +="<br />"
t += "Environmental:[add_lspace(lastused_environ, 6)] W : "
key = "env"
switch(environ)
if(0)
t += "<span class='linkOn'>Off</span> <A href='?src=\ref[src];[key]=2'>On</A> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(1)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (Off)</span>"
if(2)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <span class='linkOn'>On</span> <A href='?src=\ref[src];[key]=3'>Auto</A>"
if(3)
t += "<A href='?src=\ref[src];[key]=1'>Off</A> <A href='?src=\ref[src];[key]=2'>On</A> <span class='linkOn'>Auto (On)</span>"
t += "<br />Total Load: [lastused_light + lastused_equip + lastused_environ] W</PRE>"
t += "<br />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 /><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 /><A href='?src=\ref[src];malfhack=1'><I>Override Programming</I></A><br />"
else
t += "<br /><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>"
//user << browse(t, "window=apc")
//onclose(user, "apc")
var/datum/browser/popup = new(user, "apc", "[area.name] APC")
popup.set_content(t)
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
popup.open()
return
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, ui_key)
if (!ui)
// the ui does not exist, so we'll create a new one
ui = new(user, src, ui_key, "apc.tmpl", "[area.name] - APC", 500, data["siliconUser"] ? 465 : 390)
// When the UI is first opened this is the data it will use
ui.set_initial_data(data)
ui.open()
// Auto update every Master Controller tick
ui.set_auto_update(1)
else
// The UI is already open so push the new data to it
ui.push_data(data)
return
//user.set_machine(src)
/obj/machinery/power/apc/proc/report()
return "[area.name] : [equipment]/[lighting]/[environ] ([lastused_equip+lastused_light+lastused_environ]) : [cell? cell.percent() : "N/C"] ([charging])"
@@ -691,11 +644,11 @@
/obj/machinery/power/apc/Topic(href, href_list)
if(..())
return
return 0
if(!isrobot(usr))
if(!can_use(usr, 1))
return
return 0
usr.set_machine(src)
@@ -735,11 +688,11 @@
else if( href_list["close"] )
usr << browse(null, "window=apc")
usr.unset_machine()
return
return 0
else if (href_list["close2"])
usr << browse(null, "window=apcwires")
usr.unset_machine()
return
return 0
else if (href_list["overload"])
if( istype(usr, /mob/living/silicon) && !src.aidisabled )
@@ -747,10 +700,10 @@
else if (href_list["malfhack"])
var/mob/living/silicon/ai/malfai = usr
if( istype(malfai, /mob/living/silicon/ai) && !src.aidisabled )
if( istype(malfai, /mob/living/silicon/ai) && !src.aidisabled && (ticker && ticker.mode && (malfai.mind in ticker.mode.malf_ai)) )
if (malfai.malfhacking)
malfai << "You are already hacking an APC."
return
return 1
malfai << "Beginning override of APC systems. This takes some time, and you cannot perform other actions during the process."
malfai.malfhack = src
malfai.malfhacking = 1
@@ -759,6 +712,7 @@
if (!src.aidisabled)
malfai.malfhack = null
malfai.malfhacking = 0
locked = 1
if (ticker.mode.config_tag == "malfunction")
if (src.z == 1) //if (is_type_in_list(get_area(src), the_station_areas))
ticker.mode:apcs++
@@ -775,9 +729,17 @@
else if (href_list["deoccupyapc"])
malfvacate()
else if (href_list["toggleaccess"])
if (istype(usr, /mob/living/silicon/ai) && !src.aidisabled)
if(emagged || (stat & (BROKEN|MAINT)))
usr << "The APC does not respond to the command."
else
locked = !locked
update_icon()
src.updateDialog()
return
return 1
/obj/machinery/power/apc/proc/toggle_breaker()
operating = !operating
+9
View File
@@ -61,6 +61,15 @@ should be listed in the changelog upon commit tho. Thanks. -->
<ul class='changes bgimages16'>
<li class='rscadd'>Added Telescience! I would explain how it works but then it wouldn't be very sciencey! Have fun figuring it out. The room is near Xenobiology.</li>
</ul>
</div>
<div class='commit sansserif'>
<h2 class='date'>9 November 2013</h2>
<h3 class='author'>Yota updated:</h3>
<ul class='changes bgimages16'>
<li class='rscadd'>Along with a NanoUI upgrade, the human interface lock of APCs can now be toggled by the AI.</li>
<li class='tweak'>NanoUI dialogs will no longer steal keyboard focus when opened.</li>
</ul>
</div>
+9 -3
View File
@@ -7,6 +7,7 @@ body
line-height: 170%;
font-family: Verdana, Geneva, sans-serif;
background: #272727 url(uiBackground.png) 50% 0 repeat-x;
overflow-x: hidden;
}
hr
@@ -191,7 +192,7 @@ h4
.good
{
color: #4f7529;
color: #79B33F; /*#4f7529;*/
font-weight: bold;
}
@@ -220,7 +221,7 @@ h4
.notice
{
position: relative;
background: url(uiNoticeBackground.jpg) 50% 50% no-repeat;
background: url(uiNoticeBackground.jpg) 50% 50% repeat;
color: #15345A;
font-size: 12px;
font-style: italic;
@@ -251,6 +252,7 @@ div.notice
.item
{
width: 100%;
min-height: 22px;
clear: both;
}
@@ -261,6 +263,10 @@ div.notice
color: #e9c183;
}
.itemContentFull
{
float: left;
}
.itemContent
{
float: left;
@@ -269,7 +275,7 @@ div.notice
.itemContentSmall
{
float: left;
width: 33%;
width: 30%;
}
.statusDisplay
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.
+79 -41
View File
@@ -1,26 +1,38 @@
<div class='notice'>
{^{if locked}}
Swipe ID card to unlock interface
{^{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}}
Swipe ID card to lock interface
{^{if locked}}
Swipe an ID card to unlock this interface.
{{else}}
Swipe an ID card to lock this interface.
{{/if}}
{{/if}}
</div>
<h3>Status</h3>
<div style="min-width: 480px">
<h3>Power Status</h3>
<div class="item">
<div class="itemLabel">
Main Breaker:
</div>
<div class="itemContent">
{^{if locked}}
{^{if locked && !siliconUser}}
{^{if isOperating}}
<span class='good'>On</span>
{{else}}
<span class='bad'>Off</span>
{{/if}}
{{else}}
{^{:~link('On', {'breaker' : 1}, isOperating ? 'selected' : null)}}{^{:~link('Off', {'breaker' : 1}, isOperating ? null : 'selected')}}
{^{:~link('On', 'power', {'breaker' : 1}, isOperating ? 'selected' : null)}}{^{:~link('Off', 'close', {'breaker' : 1}, isOperating ? null : 'selected')}}
{{/if}}
</div>
</div>
@@ -44,13 +56,16 @@
<div class="itemLabel">
Power Cell:
</div>
<div class="itemContent">
{^{if powerCellStatus == null}}
<span class='bad'>Not connected.</span>
{{else}}
{^{:powerCellStatus}}%
{{/if}}
</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}}
@@ -59,83 +74,106 @@
Charge Mode:
</div>
<div class="itemContent">
{^{if locked}}
{^{if locked && !siliconUser}}
{^{if chargeMode}}
<span class='good'>Auto</span>
{{else}}
<span class='bad'>Off</span>
{{/if}}
{{else}}
{^{:~link('Auto', {'cmode' : 1}, chargeMode ? 'selected' : null)}}{^{:~link('Off', {'cmode' : 1}, chargeMode ? null : 'selected')}}
{^{:~link('Auto', 'refresh', {'cmode' : 1}, chargeMode ? 'selected' : null)}}{^{:~link('Off', 'close', {'cmode' : 1}, chargeMode ? null : 'selected')}}
{{/if}}
&nbsp;
{^{if chargingStatus > 1}}
(<span class='good'>Fully Charged</span>)
[<span class='good'>Fully Charged</span>]
{{else chargingStatus == 1}}
(<span class='average'>Charging</span>)
[<span class='average'>Charging</span>]
{{else}}
(<span class='bad'>Not Charging</span>)
[<span class='bad'>Not Charging</span>]
{{/if}}
</div>
</div>
{{/if}}
<h3>Power Channels</h3>
{^{for powerChannels}}
<div class="item">
<div class="itemLabel">
{^{:title}}
{^{:title}}:
</div>
<div class="itemContentSmall" style="width: 26%;">
<div class="itemContent" style="width: 70px; text-align: right">
{^{:powerLoad}} W
</div>
<div class="itemContentSmall" style="width: 40%;">
{^{if !~root.locked}}
{^{:~link('Auto', topicParams.auto, (status == 1 || status == 3) ? 'selected' : null)}}
{^{:~link('On', topicParams.on, (status == 2) ? 'selected' : null)}}
{^{:~link('Off', topicParams.off, (status == 0) ? 'selected' : null)}}
{{/if}}
<div class="itemContent" style="width: 105px">
&nbsp;&nbsp;
{^{if status <= 1}}
<span class='bad'>Off</span>
{{else status >= 2}}
<span class='good'>On</span>
{{/if}}
{^{if ~root.locked}}
{^{if status == 1 || status == 3}}
(Auto)
{{else}}
(Manual)
{{/if}}
{{/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">&nbsp;</div>
<div class="item">
<div class="item" style="font-weight: bold">
<div class="itemLabel">
Total Load:
</div>
<div class="itemContent">
{{:totalLoad}} W
<div class="itemContent" style="width: 70px; text-align: right">
{^{:totalLoad}} W
</div>
</div>
<div class="item">&nbsp;</div>
<div class="item">
<div class="itemLabel">
Cover Lock:
</div>
<div class="itemContent">
{^{if locked}}
{^{if locked && !siliconUser}}
{^{if coverLocked}}
<span class='good'>Engaged</span>
{{else}}
<span class='bad'>Disengaged</span>
{{/if}}
{{else}}
{^{:~link('Engaged', {'lock' : 1}, coverLocked ? 'selected' : null)}}{^{:~link('Disengaged', {'lock' : 1}, coverLocked ? null : 'selected')}}
{^{:~link('Engaged', 'locked', {'lock' : 1}, coverLocked ? 'selected' : null)}}{^{:~link('Disengaged', 'unlocked', {'lock' : 1}, coverLocked ? null : 'selected')}}
{{/if}}
</div>
</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 == 2}}
{^{:~link('Shunt Core Processes', 'arrowreturn-1-s', {'occupyapc' : 1})}}
{{else malfStatus == 3}}
{^{:~link('Return to Main Core', 'arrowreturn-1-w', {'deoccupyapc' : 1})}}
{{else malfStatus == 4}}
{^{:~link('Shunt Core Processes', 'arrowreturn-1-s', {'occupyapc' : 1}, 'linkOff')}}
{{/if}}
</div>
{{/if}}
</div>