tgui wires initial

This commit is contained in:
AnturK
2016-01-22 19:13:23 -06:00
committed by Bjorn Neergaard
parent 14f90d8f1e
commit cda2f26d56
14 changed files with 160 additions and 164 deletions
+9 -9
View File
@@ -31,16 +31,16 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
return 1
return 0
/datum/wires/airlock/GetInteractWindow()
/datum/wires/airlock/getStatus()
var/obj/machinery/door/airlock/A = holder
. += ..()
. += text("<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]<br>\n[]", (A.locked ? "The door bolts have fallen!" : "The door bolts look up."),
(A.lights ? "The door bolt lights are on." : "The door bolt lights are off!"),
((A.hasPower()) ? "The test light is on." : "The test light is off!"),
((A.aiControlDisabled==0 && !A.emagged) ? "The 'AI control allowed' light is on." : "The 'AI control allowed' light is off."),
(A.safe==0 ? "The 'Check Wiring' light is on." : "The 'Check Wiring' light is off."),
(A.normalspeed==0 ? "The 'Check Timing Mechanism' light is on." : "The 'Check Timing Mechanism' light is off."),
(A.emergency==0 ? "The emergency lights are off." : "The emergency lights are on."))
var/list/status = list()
status.Add(A.locked ? "The door bolts have fallen!" : "The door bolts look up.")
status.Add(A.hasPower() ? "The test light is on." : "The test light is off!")
status.Add((A.aiControlDisabled==0 && !A.emagged) ? "The 'AI control allowed' light is on." : "The 'AI control allowed' light is off.")
status.Add(A.safe==0 ? "The 'Check Wiring' light is on." : "The 'Check Wiring' light is off.")
status.Add(A.normalspeed==0 ? "The 'Check Timing Mechanism' light is on." : "The 'Check Timing Mechanism' light is off.")
status.Add(A.emergency==0 ? "The emergency lights are off." : "The emergency lights are on.")
return status
/datum/wires/airlock/UpdateCut(var/index, var/mended)
+6 -3
View File
@@ -15,10 +15,13 @@ var/const/AALARM_WIRE_AALARM = 16
return 1
return 0
/datum/wires/alarm/GetInteractWindow()
/datum/wires/alarm/getStatus()
var/obj/machinery/alarm/A = holder
. += ..()
. += text("<br>\n[(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")]<br>\n[((A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")]<br>\n[(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")
var/list/status = list()
status.Add(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")
status.Add((A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")
status.Add(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")
return status
/datum/wires/alarm/UpdateCut(index, mended)
var/obj/machinery/alarm/A = holder
+7 -4
View File
@@ -7,11 +7,14 @@ var/const/APC_WIRE_MAIN_POWER1 = 2
var/const/APC_WIRE_MAIN_POWER2 = 4
var/const/APC_WIRE_AI_CONTROL = 8
/datum/wires/apc/GetInteractWindow()
var/obj/machinery/power/apc/A = holder
. += ..()
. += text("<br>\n[(A.locked ? "The APC is locked." : "The APC is unlocked.")]<br>\n[(A.shorted ? "The APCs power has been shorted." : "The APC is working properly!")]<br>\n[(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")]")
/datum/wires/apc/getStatus()
var/obj/machinery/power/apc/A = holder
var/list/status = list()
status.Add(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")
status.Add(A.shorted ? "The APCs power has been shorted." : "The APC is working properly!")
status.Add(A.aidisabled ? "The 'AI control allowed' light is off." : "The 'AI control allowed' light is on.")
return status
/datum/wires/apc/CanUse(mob/living/L)
var/obj/machinery/power/apc/A = holder
+6 -8
View File
@@ -7,10 +7,13 @@ var/const/AUTOLATHE_HACK_WIRE = 1
var/const/AUTOLATHE_SHOCK_WIRE = 2
var/const/AUTOLATHE_DISABLE_WIRE = 4
/datum/wires/autolathe/GetInteractWindow()
/datum/wires/autolathe/getStatus()
var/obj/machinery/autolathe/A = holder
. += ..()
. += text("<BR>The red light is [A.disabled ? "off" : "on"].<BR>The green light is [A.shocked ? "off" : "on"].<BR>The blue light is [A.hacked ? "off" : "on"].<BR>")
var/list/status = list()
status.Add("The red light is [A.disabled ? "off" : "on"].")
status.Add("The blue light is [A.hacked ? "off" : "on"].")
return status
/datum/wires/autolathe/CanUse()
var/obj/machinery/autolathe/A = holder
@@ -18,11 +21,6 @@ var/const/AUTOLATHE_DISABLE_WIRE = 4
return 1
return 0
/datum/wires/autolathe/Interact(mob/living/user)
if(CanUse(user))
var/obj/machinery/autolathe/V = holder
V.attack_hand(user)
/datum/wires/autolathe/UpdateCut(index, mended)
var/obj/machinery/autolathe/A = holder
switch(index)
+5 -5
View File
@@ -38,9 +38,9 @@ var/const/PIZZA_WIRE_DISARM = 1 // No boom
log_game("a pizza bomb ([P.loc.x],[P.loc.y],[P.loc.z]) armed by [key_name(P.armer)] has exploded via wire pulsing.")
P.go_boom()
/datum/wires/pizza_bomb/GetInteractWindow()
. = ..()
/datum/wires/pizza_bomb/getStatus()
var/obj/item/device/pizza_bomb/P = holder
. += text("<br>The red light is [P.primed ? "on" : "off"].<br>")
. += text("The green light is [P.disarmed ? "on": "off"].<br>")
var/list/status = list()
status.Add("The red light is [P.primed ? "on" : "off"].")
status.Add("The green light is [P.disarmed ? "on": "off"].")
return status
+6 -6
View File
@@ -41,11 +41,11 @@ var/const/RD_WIRE_DISABLE = 4 // Disables the machine
if(RD_WIRE_SHOCK)
R.shocked = !mended
/datum/wires/r_n_d/GetInteractWindow()
. = ..()
/datum/wires/r_n_d/getStatus()
var/obj/machinery/r_n_d/R = holder
. += text("<br>The red light is [R.disabled ? "off" : "on"].<br>")
. += text("The green light is [R.shocked ? "off" : "on"].<br>")
. += text("The blue light is [R.hacked ? "off" : "on"].<br>")
var/list/status = list()
status.Add("The red light is [R.disabled ? "off" : "on"].")
status.Add("The green light is [R.shocked ? "off" : "on"].")
status.Add("The blue light is [R.hacked ? "off" : "on"].")
return status
+7 -6
View File
@@ -9,14 +9,15 @@ var/const/BORG_WIRE_LOCKED_DOWN = 4
var/const/BORG_WIRE_AI_CONTROL = 8
var/const/BORG_WIRE_CAMERA = 16
/datum/wires/robot/GetInteractWindow()
. = ..()
/datum/wires/robot/getStatus()
var/mob/living/silicon/robot/R = holder
. += text("<br>\n[(R.lawupdate ? "The LawSync light is on." : "The LawSync light is off.")]<br>\n[(R.connected_ai ? "The AI link light is on." : "The AI link light is off.")]")
. += text("<br>\n[((!isnull(R.camera) && R.camera.status == 1) ? "The Camera light is on." : "The Camera light is off.")]<br>\n")
. += text("<br>\n[(R.lockcharge ? "The lockdown light is on." : "The lockdown light is off.")]")
return .
var/list/status = list()
status.Add(R.lawupdate ? "The LawSync light is on." : "The LawSync light is off.")
status.Add(R.connected_ai ? "The AI link light is on." : "The AI link light is off.")
status.Add((!isnull(R.camera) && R.camera.status == 1) ? "The Camera light is on." : "The Camera light is off.")
status.Add(R.lockcharge ? "The lockdown light is on." : "The lockdown light is off.")
return status
/datum/wires/robot/UpdateCut(index, mended)
+15 -13
View File
@@ -1,11 +1,12 @@
/datum/wires/vending
holder_type = /obj/machinery/vending
wire_count = 4
wire_count = 5
var/const/VENDING_WIRE_THROW = 1
var/const/VENDING_WIRE_CONTRABAND = 2
var/const/VENDING_WIRE_ELECTRIFY = 4
var/const/VENDING_WIRE_IDSCAN = 8
var/const/VENDING_WIRE_SPEAKER = 16
/datum/wires/vending/CanUse(mob/living/L)
var/obj/machinery/vending/V = holder
@@ -17,18 +18,15 @@ var/const/VENDING_WIRE_IDSCAN = 8
return 1
return 0
/datum/wires/vending/Interact(mob/living/user)
if(CanUse(user))
var/obj/machinery/vending/V = holder
V.attack_hand(user)
/datum/wires/vending/GetInteractWindow()
/datum/wires/vending/getStatus()
var/obj/machinery/vending/V = holder
. += ..()
. += "<BR>The orange light is [V.seconds_electrified ? "on" : "off"].<BR>"
. += "The red light is [V.shoot_inventory ? "off" : "blinking"].<BR>"
. += "The green light is [V.extended_inventory ? "on" : "off"].<BR>"
. += "A [V.scan_id ? "purple" : "yellow"] light is on.<BR>"
var/list/status = list()
status.Add("The orange light is [V.seconds_electrified ? "on" : "off"].")
status.Add("The red light is [V.shoot_inventory ? "off" : "blinking"].")
status.Add("The green light is [V.extended_inventory ? "on" : "off"].")
status.Add("A [V.scan_id ? "purple" : "yellow"] light is on.")
status.Add("The speaker light is [V.shut_up ? "off" : "on"].")
return status
/datum/wires/vending/UpdatePulsed(index)
var/obj/machinery/vending/V = holder
@@ -41,6 +39,8 @@ var/const/VENDING_WIRE_IDSCAN = 8
V.seconds_electrified = 30
if(VENDING_WIRE_IDSCAN)
V.scan_id = !V.scan_id
if(VENDING_WIRE_SPEAKER)
V.shut_up = !V.shut_up
/datum/wires/vending/UpdateCut(index, mended)
var/obj/machinery/vending/V = holder
@@ -55,4 +55,6 @@ var/const/VENDING_WIRE_IDSCAN = 8
else
V.seconds_electrified = -1
if(VENDING_WIRE_IDSCAN)
V.scan_id = 1
V.scan_id = 1
if(VENDING_WIRE_SPEAKER)
V.shut_up = mended
+65 -90
View File
@@ -82,97 +82,26 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
return 0
/datum/wires/ui_interact(mob/user, ui_key = "wires", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = wire_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if (!ui)
ui = new(user, src, ui_key, "wires", holder.name, 200 + wire_count*50, 470, master_ui, state)
ui.open()
/datum/wires/proc/Interact(mob/living/user)
var/html = null
if(holder && CanUse(user))
html = GetInteractWindow()
if(html)
if(user.machine != holder)
for(var/A in signallers)
if(istype(signallers[A], /obj/item))
var/obj/item/I = signallers[A]
if(I.on_found(user))
return
if(holder && CanUse(user)) //remove this
ui_interact(user)
//Active prox sensors and similar on wires
for(var/A in signallers)
if(istype(signallers[A], /obj/item))
var/obj/item/I = signallers[A]
if(I.on_found(user))
return
user.set_machine(holder)
else
user.unset_machine()
// No content means no window.
user << browse(null, "window=wires")
return
var/datum/browser/popup = new(user, "wires", holder.name, window_x, window_y)
popup.set_content(html)
popup.set_title_image(user.browse_rsc_icon(holder.icon, holder.icon_state))
popup.open()
/datum/wires/proc/GetInteractWindow()
var/html = "<div class='block'>"
html += "<h3>Exposed Wires</h3>"
html += "<table[table_options]>"
for(var/colour in wires)
html += "<tr>"
html += "<td[row_options1]><font color='[colour]'>[capitalize(colour)]</font></td>"
html += "<td[row_options2]>"
html += "<A href='?src=\ref[src];action=1;cut=[colour]'>[IsColourCut(colour) ? "Mend" : "Cut"]</A>"
html += " <A href='?src=\ref[src];action=1;pulse=[colour]'>Pulse</A>"
html += " <A href='?src=\ref[src];action=1;attach=[colour]'>[IsAttached(colour) ? "Detach" : "Attach"] Signaller</A></td></tr>"
html += "</table>"
html += "</div>"
return html
/datum/wires/Topic(href, href_list)
..()
if(usr.Adjacent(holder) && isliving(usr))
var/mob/living/L = usr
if(CanUse(L) && href_list["action"])
var/obj/item/I = L.get_active_hand()
holder.add_hiddenprint(L)
if(href_list["cut"]) // Toggles the cut/mend status
if(istype(I, /obj/item/weapon/wirecutters))
var/colour = href_list["cut"]
CutWireColour(colour)
else
L << "<span class='warning'>You need wirecutters!</span>"
else if(href_list["pulse"])
if(istype(I, /obj/item/device/multitool))
var/colour = href_list["pulse"]
PulseColour(colour)
else
L << "<span class='warning'>You need a multitool!</span>"
else if(href_list["attach"])
var/colour = href_list["attach"]
// Detach
if(IsAttached(colour))
var/obj/item/O = Detach(colour)
if(O)
L.put_in_hands(O)
// Attach
else
if(istype(I, /obj/item/device/assembly))
var/obj/item/device/assembly/A = I;
if(A.attachable)
if(!L.drop_item())
return
Attach(colour, A)
else
L << "<span class='warning'>You need a attachable assembly!</span>"
// Update Window
Interact(usr)
if(href_list["close"])
usr << browse(null, "window=wires")
usr.unset_machine(holder)
/datum/wires/proc/getStatus()
return
//
// Overridable Procs
@@ -279,7 +208,6 @@ var/const/POWER = 8
/datum/wires/proc/Pulse(obj/item/device/assembly/S)
for(var/colour in signallers)
if(S == signallers[colour])
PulseColour(colour)
@@ -321,4 +249,51 @@ var/const/POWER = 8
/datum/wires/proc/Shuffle()
wires_status = 0
GenerateWires()
GenerateWires()
/datum/wires/get_ui_data()
var/list/data = list()
var/list/payload = list()
for(var/colour in wires)
payload.Add(list(list("colour"=colour,"isCut"=IsColourCut(colour),"hasAttachment"=IsAttached(colour))))
data["wires"] = payload
data["holderInfo"] = getStatus()
return data
/datum/wires/ui_act(action, params)
if(..())
return
var/target_wire = params["wire"]
var/mob/living/L = usr
if(!istype(L) || !CanUse(L)) //only physical beings can touch these. Sorry admins, maybe later
return
var/obj/item/I = L.get_active_hand()
switch(action)
if("cut")
if(istype(I, /obj/item/weapon/wirecutters))
CutWireColour(target_wire)
else
L << "<span class='warning'>You need wirecutters!</span>"
if("pulse")
if(istype(I, /obj/item/device/multitool))
PulseColour(target_wire)
else
L << "<span class='warning'>You need a multitool!</span>"
if("attach")
//Detach
if(IsAttached(target_wire))
var/obj/item/O = Detach(target_wire)
if(O)
L.put_in_hands(O)
// Attach
else
if(istype(I, /obj/item/device/assembly))
var/obj/item/device/assembly/A = I;
if(A.attachable)
if(!L.drop_item())
return
Attach(target_wire, A)
else
L << "<span class='warning'>You need an attachable assembly!</span>"
return 1
+9 -11
View File
@@ -76,17 +76,13 @@
var/dat
if(panel_open)
dat = wires.GetInteractWindow()
else
switch(screen)
if(AUTOLATHE_MAIN_MENU)
dat = main_win(user)
if(AUTOLATHE_CATEGORY_MENU)
dat = category_win(user,selected_category)
if(AUTOLATHE_SEARCH_MENU)
dat = search_win(user)
switch(screen)
if(AUTOLATHE_MAIN_MENU)
dat = main_win(user)
if(AUTOLATHE_CATEGORY_MENU)
dat = category_win(user,selected_category)
if(AUTOLATHE_SEARCH_MENU)
dat = search_win(user)
var/datum/browser/popup = new(user, "autolathe", name, 400, 500)
popup.set_content(dat)
@@ -149,6 +145,8 @@
return attack_hand(user)
/obj/machinery/autolathe/attack_hand(mob/user)
if(panel_open && !isAI(user))
return wires.Interact(user)
if(..(user, 0))
return
interact(user)
+2 -9
View File
@@ -315,10 +315,8 @@
/obj/machinery/vending/attack_hand(mob/user)
var/dat = ""
if(panel_open)
dat += wires()
if(product_slogans != "")
dat += "The speaker switch is [shut_up ? "off" : "on"]. <a href='?src=\ref[src];togglevoice=[1]'>Toggle</a>"
if(panel_open && !isAI(user))
return wires.Interact(user)
else
if(stat & (BROKEN|NOPOWER))
return
@@ -375,11 +373,6 @@
popup.open()
// returns the wire panel text
/obj/machinery/vending/proc/wires()
return wires.GetInteractWindow()
/obj/machinery/vending/Topic(href, href_list)
if(..())
return
+9
View File
@@ -0,0 +1,9 @@
/var/global/datum/ui_state/wire_state/wire_state = new()
/datum/ui_state/wire_state/can_use_topic(src_object, mob/user)
var/datum/wires/W = src_object
if(!istype(W))
return UI_CLOSE
if(!user.Adjacent(W.holder))
return UI_CLOSE
return W.CanUse(user) ? UI_INTERACTIVE : UI_CLOSE
+1
View File
@@ -1604,6 +1604,7 @@
#include "code\modules\tgui\states\physical.dm"
#include "code\modules\tgui\states\self.dm"
#include "code\modules\tgui\states\states.dm"
#include "code\modules\tgui\states\wire.dm"
#include "code\modules\tgui\states\zlevel.dm"
#include "code\modules\tooltip\tooltip.dm"
#include "code\modules\uplink\uplink.dm"
+13
View File
@@ -0,0 +1,13 @@
<ui-display title="Exposed Wires">
{{#each data.wires}}
<ui-section style='text-align:center'>
<span style='color:{{colour}};display:inline-block;width:50px;'>{{colour}}</span>
<ui-button action='cut' params='{"wire":"{{colour}}"}'>{{isCut ? "Mend" : "Cut"}}</ui-button>
<ui-button action='pulse' params='{"wire":"{{colour}}"}'>Pulse</ui-button>
<ui-button action='attach' params='{"wire":"{{colour}}"}'>{{hasAttachment ? "Detach" : "Attach"}}</ui-button>
</ui-section>
{{/each}}
{{#each data.holderInfo}}
<ui-section>{{.}}</ui-section>
{{/each}}
</ui-display>