Wires nano-ui.

This commit is contained in:
davipatury
2017-02-25 21:51:28 -03:00
parent 2bc95dfd34
commit a3a1775696
18 changed files with 192 additions and 186 deletions
+14 -14
View File
@@ -21,9 +21,9 @@ var/const/AIRLOCK_WIRE_SAFETY = 512
var/const/AIRLOCK_WIRE_SPEED = 1024
var/const/AIRLOCK_WIRE_LIGHT = 2048
/datum/wires/airlock/CanUse(var/mob/living/L)
/datum/wires/airlock/CanUse(mob/living/L)
var/obj/machinery/door/airlock/A = holder
if(!istype(L, /mob/living/silicon))
if(!issilicon(L))
if(A.isElectrified())
if(A.shock(L, 100))
return 0
@@ -31,20 +31,20 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
return 1
return 0
/datum/wires/airlock/GetInteractWindow()
/datum/wires/airlock/get_status()
. = ..()
var/obj/machinery/door/airlock/A = holder
var/haspower = A.arePowerSystemsOn()
. += ..()
. += 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 && haspower) ? "The door bolt lights are on." : "The door bolt lights are off!"),
((haspower) ? "The test light is on." : "The test light is off!"),
((A.aiControlDisabled==0 && !A.emagged && haspower) ? "The 'AI control allowed' light is on." : "The 'AI control allowed' light is off."),
((A.safe==0 && haspower) ? "The 'Check Wiring' light is on." : "The 'Check Wiring' light is off."),
((A.normalspeed==0 && haspower) ? "The 'Check Timing Mechanism' light is on." : "The 'Check Timing Mechanism' light is off."),
((A.emergency && haspower) ? "The emergency lights are on." : "The emergency lights are off."))
/datum/wires/airlock/UpdateCut(var/index, var/mended)
. += "The door bolts [A.locked ? "have fallen!" : "look up."]"
. += "The door bolt lights are [(A.lights && haspower) ? "on." : "off!"]"
. += "The test light is [haspower ? "on." : "off!"]"
. += "The 'AI control allowed' light is [(A.aiControlDisabled == 0 && !A.emagged && haspower) ? "on" : "off"]."
. += "The 'Check Wiring' light is [(A.safe == 0 && haspower) ? "on" : "off"]."
. += "The 'Check Timing Mechanism' light is [(A.normalspeed == 0 && haspower) ? "on" : "off"]."
. += "The emergency lights are [(A.emergency && haspower) ? "on" : "off"]."
/datum/wires/airlock/UpdateCut(index, mended)
var/obj/machinery/door/airlock/A = holder
switch(index)
@@ -114,7 +114,7 @@ var/const/AIRLOCK_WIRE_LIGHT = 2048
A.lights = mended
A.update_icon()
/datum/wires/airlock/UpdatePulsed(var/index)
/datum/wires/airlock/UpdatePulsed(index)
var/obj/machinery/door/airlock/A = holder
switch(index)
+8 -6
View File
@@ -10,18 +10,20 @@ var/const/AALARM_WIRE_AI_CONTROL = 8
var/const/AALARM_WIRE_AALARM = 16
/datum/wires/alarm/CanUse(var/mob/living/L)
/datum/wires/alarm/CanUse(mob/living/L)
var/obj/machinery/alarm/A = holder
if(A.wiresexposed)
return 1
return 0
/datum/wires/alarm/GetInteractWindow()
/datum/wires/alarm/get_status()
. = ..()
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.")]")
. += "The Air Alarm is [A.locked ? "" : "un"]locked."
. += "The Air Alarm is [(A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "offline." : "working properly!"]"
. += "The 'AI control allowed' light is [A.aidisabled ? "off" : "on"]."
/datum/wires/alarm/UpdateCut(var/index, var/mended)
/datum/wires/alarm/UpdateCut(index, mended)
var/obj/machinery/alarm/A = holder
switch(index)
if(AALARM_WIRE_IDSCAN)
@@ -51,7 +53,7 @@ var/const/AALARM_WIRE_AALARM = 16
A.post_alert(2)
A.update_icon()
/datum/wires/alarm/UpdatePulsed(var/index)
/datum/wires/alarm/UpdatePulsed(index)
var/obj/machinery/alarm/A = holder
switch(index)
if(AALARM_WIRE_IDSCAN)
+8 -6
View File
@@ -7,19 +7,21 @@ 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()
/datum/wires/apc/get_status()
. = ..()
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.")]")
. += "The APC is [A.locked ? "" : "un"]locked."
. += A.shorted ? "The APCs power has been shorted." : "The APC is working properly!"
. += "The 'AI control allowed' light is [A.aidisabled ? "off" : "on"]."
/datum/wires/apc/CanUse(var/mob/living/L)
/datum/wires/apc/CanUse(mob/living/L)
var/obj/machinery/power/apc/A = holder
if(A.wiresexposed)
return 1
return 0
/datum/wires/apc/UpdatePulsed(var/index)
/datum/wires/apc/UpdatePulsed(index)
var/obj/machinery/power/apc/A = holder
@@ -53,7 +55,7 @@ var/const/APC_WIRE_AI_CONTROL = 8
A.updateDialog()
/datum/wires/apc/UpdateCut(var/index, var/mended)
/datum/wires/apc/UpdateCut(index, mended)
var/obj/machinery/power/apc/A = holder
switch(index)
+5 -4
View File
@@ -1,5 +1,4 @@
/datum/wires/autolathe
holder_type = /obj/machinery/autolathe
wire_count = 10
@@ -7,10 +6,12 @@ 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/get_status()
. = ..()
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>")
. += "The red light is [A.disabled ? "off" : "on"]."
. += "The green light is [A.shocked ? "off" : "on"]."
. += "The blue light is [A.hacked ? "off" : "on"]."
/datum/wires/autolathe/CanUse()
var/obj/machinery/autolathe/A = holder
+8 -10
View File
@@ -5,17 +5,15 @@
holder_type = /obj/machinery/camera
wire_count = 6
/datum/wires/camera/GetInteractWindow()
/datum/wires/camera/get_status()
. = ..()
var/obj/machinery/camera/C = holder
. += "<br>\n[(C.view_range == initial(C.view_range) ? "The focus light is on." : "The focus light is off.")]"
. += "<br>\n[(C.can_use() ? "The power link light is on." : "The power link light is off.")]"
. += "<br>\n[(C.light_disabled ? "The camera light is off." : "The camera light is on.")]"
. += "<br>\n[(C.alarm_on ? "The alarm light is on." : "The alarm light is off.")]"
return .
. += "The focus light is [(C.view_range == initial(C.view_range)) ? "on" : "off"]."
. += "The power link light is [C.can_use() ? "on" : "off"]."
. += "The camera light is [C.light_disabled ? "off" : "on"]."
. += "The alarm light is [C.alarm_on ? "on" : "off"]."
/datum/wires/camera/CanUse(var/mob/living/L)
/datum/wires/camera/CanUse(mob/living/L)
var/obj/machinery/camera/C = holder
if(!C.panel_open)
return 0
@@ -28,7 +26,7 @@ var/const/CAMERA_WIRE_ALARM = 8
var/const/CAMERA_WIRE_NOTHING1 = 16
var/const/CAMERA_WIRE_NOTHING2 = 32
/datum/wires/camera/UpdateCut(var/index, var/mended)
/datum/wires/camera/UpdateCut(index, mended)
var/obj/machinery/camera/C = holder
switch(index)
@@ -50,7 +48,7 @@ var/const/CAMERA_WIRE_NOTHING2 = 32
C.cancelCameraAlarm()
return
/datum/wires/camera/UpdatePulsed(var/index)
/datum/wires/camera/UpdatePulsed(index)
var/obj/machinery/camera/C = holder
if(IsIndexCut(index))
return
+4 -4
View File
@@ -6,12 +6,12 @@ var/const/WIRE_EXPLODE = 1
/datum/wires/explosive/proc/explode()
return
/datum/wires/explosive/UpdatePulsed(var/index)
/datum/wires/explosive/UpdatePulsed(index)
switch(index)
if(WIRE_EXPLODE)
explode()
/datum/wires/explosive/UpdateCut(var/index, var/mended)
/datum/wires/explosive/UpdateCut(index, mended)
switch(index)
if(WIRE_EXPLODE)
if(!mended)
@@ -20,10 +20,10 @@ var/const/WIRE_EXPLODE = 1
/datum/wires/explosive/gibtonite
holder_type = /obj/item/weapon/twohanded/required/gibtonite
/datum/wires/explosive/gibtonite/CanUse(var/mob/living/L)
/datum/wires/explosive/gibtonite/CanUse(mob/living/L)
return 1
/datum/wires/explosive/gibtonite/UpdateCut(var/index, var/mended)
/datum/wires/explosive/gibtonite/UpdateCut(index, mended)
return
/datum/wires/explosive/gibtonite/explode()
+2 -8
View File
@@ -13,19 +13,13 @@ var/const/WIRE_REMOTE_RX = 64 // remote recv functions
var/const/WIRE_REMOTE_TX = 128 // remote trans status
var/const/WIRE_BEACON_RX = 256 // beacon ping recv
/datum/wires/mulebot/CanUse(var/mob/living/L)
/datum/wires/mulebot/CanUse(mob/living/L)
var/mob/living/simple_animal/bot/mulebot/M = holder
if(M.open)
return 1
return 0
// So the wires do not open a new window, handle the interaction ourselves.
/datum/wires/mulebot/Interact(var/mob/living/user)
if(CanUse(user))
var/mob/living/simple_animal/bot/mulebot/M = holder
M.interact(user)
/datum/wires/mulebot/UpdatePulsed(var/index)
/datum/wires/mulebot/UpdatePulsed(index)
switch(index)
if(WIRE_POWER1, WIRE_POWER2)
holder.visible_message("\blue [bicon(holder)] The charge light flickers.")
+8 -8
View File
@@ -7,20 +7,20 @@ var/const/NUCLEARBOMB_WIRE_LIGHT = 1
var/const/NUCLEARBOMB_WIRE_TIMING = 2
var/const/NUCLEARBOMB_WIRE_SAFETY = 4
/datum/wires/nuclearbomb/CanUse(var/mob/living/L)
/datum/wires/nuclearbomb/CanUse(mob/living/L)
var/obj/machinery/nuclearbomb/N = holder
if(N.panel_open)
return 1
return 0
/datum/wires/nuclearbomb/GetInteractWindow()
/datum/wires/nuclearbomb/get_status()
. = ..()
var/obj/machinery/nuclearbomb/N = holder
. += ..()
. += "<BR>The device is [N.timing ? "shaking!" : "still."]<BR>"
. += "The device is is [N.safety ? "quiet" : "whirring"].<BR>"
. += "The lights are [N.lighthack ? "static" : "functional"].<BR>"
. += "The device is [N.timing ? "shaking!" : "still."]"
. += "The device is is [N.safety ? "quiet" : "whirring"]."
. += "The lights are [N.lighthack ? "static" : "functional"]."
/datum/wires/nuclearbomb/UpdatePulsed(var/index)
/datum/wires/nuclearbomb/UpdatePulsed(index)
var/obj/machinery/nuclearbomb/N = holder
switch(index)
if(NUCLEARBOMB_WIRE_LIGHT)
@@ -45,7 +45,7 @@ var/const/NUCLEARBOMB_WIRE_SAFETY = 4
N.icon_state = "nuclearbomb1"
else
N.visible_message("\blue The [N] emits a quiet whirling noise!")
/datum/wires/nuclearbomb/UpdateCut(var/index, var/mended)
var/obj/machinery/nuclearbomb/N = holder
switch(index)
+3 -3
View File
@@ -8,13 +8,13 @@ var/const/PARTICLE_INTERFACE_WIRE = 4 // Determines the interface showing up.
var/const/PARTICLE_LIMIT_POWER_WIRE = 8 // Determines how strong the PA can be.
//var/const/PARTICLE_NOTHING_WIRE = 16 // Blank wire
/datum/wires/particle_acc/control_box/CanUse(var/mob/living/L)
/datum/wires/particle_acc/control_box/CanUse(mob/living/L)
var/obj/machinery/particle_accelerator/control_box/C = holder
if(C.construction_state == 2)
return 1
return 0
/datum/wires/particle_acc/control_box/UpdatePulsed(var/index)
/datum/wires/particle_acc/control_box/UpdatePulsed(index)
var/obj/machinery/particle_accelerator/control_box/C = holder
switch(index)
@@ -30,7 +30,7 @@ var/const/PARTICLE_LIMIT_POWER_WIRE = 8 // Determines how strong the PA can be.
if(PARTICLE_LIMIT_POWER_WIRE)
C.visible_message("[bicon(C)]<b>[C]</b> makes a large whirring noise.")
/datum/wires/particle_acc/control_box/UpdateCut(var/index, var/mended)
/datum/wires/particle_acc/control_box/UpdateCut(index, mended)
var/obj/machinery/particle_accelerator/control_box/C = holder
switch(index)
+3 -3
View File
@@ -6,13 +6,13 @@ var/const/WIRE_SIGNAL = 1
var/const/WIRE_RECEIVE = 2
var/const/WIRE_TRANSMIT = 4
/datum/wires/radio/CanUse(var/mob/living/L)
/datum/wires/radio/CanUse(mob/living/L)
var/obj/item/device/radio/R = holder
if(R.b_stat)
return 1
return 0
/datum/wires/radio/UpdatePulsed(var/index)
/datum/wires/radio/UpdatePulsed(index)
var/obj/item/device/radio/R = holder
switch(index)
if(WIRE_SIGNAL)
@@ -25,7 +25,7 @@ var/const/WIRE_TRANSMIT = 4
if(WIRE_TRANSMIT)
R.broadcasting = !R.broadcasting && !IsIndexCut(WIRE_SIGNAL)
/datum/wires/radio/UpdateCut(var/index, var/mended)
/datum/wires/radio/UpdateCut(index, mended)
var/obj/item/device/radio/R = holder
switch(index)
if(WIRE_SIGNAL)
+8 -9
View File
@@ -19,16 +19,15 @@ var/const/BORG_WIRE_CAMERA = 4
var/const/BORG_WIRE_AI_CONTROL = 8 // Not used on MoMMIs
var/const/BORG_WIRE_LAWCHECK = 16 // Not used on MoMMIs
/datum/wires/robot/GetInteractWindow()
/datum/wires/robot/get_status()
. = ..()
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 .
. += "The LawSync light is [R.lawupdate ? "on" : "off"]."
. += "The AI link light is [R.connected_ai ? "on" : "off"]."
. += "The Camera light is [(R.camera && R.camera.status == 1) ? "on" : "off"]."
. += "The lockdown light is [R.lockcharge ? "on" : "off"]."
/datum/wires/robot/UpdateCut(var/index, var/mended)
/datum/wires/robot/UpdateCut(index, mended)
var/mob/living/silicon/robot/R = holder
switch(index)
@@ -59,7 +58,7 @@ var/const/BORG_WIRE_LAWCHECK = 16 // Not used on MoMMIs
R.SetLockdown(!mended)
/datum/wires/robot/UpdatePulsed(var/index)
/datum/wires/robot/UpdatePulsed(index)
var/mob/living/silicon/robot/R = holder
switch(index)
@@ -77,7 +76,7 @@ var/const/BORG_WIRE_LAWCHECK = 16 // Not used on MoMMIs
if(BORG_WIRE_LOCKED_DOWN)
R.SetLockdown(!R.lockcharge) // Toggle
/datum/wires/robot/CanUse(var/mob/living/L)
/datum/wires/robot/CanUse(mob/living/L)
var/mob/living/silicon/robot/R = holder
if(R.wiresexposed)
return 1
+9 -9
View File
@@ -10,9 +10,9 @@ var/const/SMARTFRIDGE_WIRE_ELECTRIFY = 1
var/const/SMARTFRIDGE_WIRE_THROW = 2
var/const/SMARTFRIDGE_WIRE_IDSCAN = 4
/datum/wires/smartfridge/CanUse(var/mob/living/L)
/datum/wires/smartfridge/CanUse(mob/living/L)
var/obj/machinery/smartfridge/S = holder
if(!istype(L, /mob/living/silicon))
if(!issilicon(L))
if(S.seconds_electrified)
if(S.shock(L, 100))
return 0
@@ -20,14 +20,14 @@ var/const/SMARTFRIDGE_WIRE_IDSCAN = 4
return 1
return 0
/datum/wires/smartfridge/GetInteractWindow()
/datum/wires/smartfridge/get_status()
. = ..()
var/obj/machinery/smartfridge/S = holder
. += ..()
. += "<BR>The orange light is [S.seconds_electrified ? "off" : "on"].<BR>"
. += "The red light is [S.shoot_inventory ? "off" : "blinking"].<BR>"
. += "A [S.scan_id ? "purple" : "yellow"] light is on.<BR>"
. += "The orange light is [S.seconds_electrified ? "off" : "on"]."
. += "The red light is [S.shoot_inventory ? "off" : "blinking"]."
. += "A [S.scan_id ? "purple" : "yellow"] light is on."
/datum/wires/smartfridge/UpdatePulsed(var/index)
/datum/wires/smartfridge/UpdatePulsed(index)
var/obj/machinery/smartfridge/S = holder
switch(index)
if(SMARTFRIDGE_WIRE_THROW)
@@ -37,7 +37,7 @@ var/const/SMARTFRIDGE_WIRE_IDSCAN = 4
if(SMARTFRIDGE_WIRE_IDSCAN)
S.scan_id = !S.scan_id
/datum/wires/smartfridge/UpdateCut(var/index, var/mended)
/datum/wires/smartfridge/UpdateCut(index, mended)
var/obj/machinery/smartfridge/S = holder
switch(index)
if(SMARTFRIDGE_WIRE_THROW)
+3 -3
View File
@@ -10,13 +10,13 @@ var/const/WIRE_PROCEED = 8 // Lowers the timer, explodes if cut while the bomb
var/const/WIRE_ACTIVATE = 16 // Will start a bombs timer if pulsed, will hint if pulsed while already active, will stop a timer a bomb on cut
/datum/wires/syndicatebomb/CanUse(var/mob/living/L)
/datum/wires/syndicatebomb/CanUse(mob/living/L)
var/obj/machinery/syndicatebomb/P = holder
if(P.open_panel)
return 1
return 0
/datum/wires/syndicatebomb/UpdatePulsed(var/index)
/datum/wires/syndicatebomb/UpdatePulsed(index)
var/obj/machinery/syndicatebomb/P = holder
switch(index)
if(WIRE_BOOM)
@@ -48,7 +48,7 @@ var/const/WIRE_ACTIVATE = 16 // Will start a bombs timer if pulsed, will hint if
P.loc.visible_message("<span class='notice'>[bicon(holder)] The bomb seems to hesitate for a moment.</span>")
P.timer += 5
/datum/wires/syndicatebomb/UpdateCut(var/index, var/mended)
/datum/wires/syndicatebomb/UpdateCut(index, mended)
var/obj/machinery/syndicatebomb/P = holder
switch(index)
if(WIRE_EXPLODE)
+9 -9
View File
@@ -9,7 +9,7 @@ var/const/VENDING_WIRE_CONTRABAND = 2
var/const/VENDING_WIRE_ELECTRIFY = 4
var/const/VENDING_WIRE_IDSCAN = 8
/datum/wires/vending/CanUse(var/mob/living/L)
/datum/wires/vending/CanUse(mob/living/L)
var/obj/machinery/vending/V = holder
if(!istype(L, /mob/living/silicon))
if(V.seconds_electrified)
@@ -19,15 +19,15 @@ var/const/VENDING_WIRE_IDSCAN = 8
return 1
return 0
/datum/wires/vending/GetInteractWindow()
/datum/wires/vending/get_status()
. = ..()
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.categories & CAT_HIDDEN) ? "on" : "off"].<BR>"
. += "A [V.scan_id ? "purple" : "yellow"] light is on.<BR>"
. += "The orange light is [V.seconds_electrified ? "on" : "off"]."
. += "The red light is [V.shoot_inventory ? "off" : "blinking"]."
. += "The green light is [(V.categories & CAT_HIDDEN) ? "on" : "off"]."
. += "A [V.scan_id ? "purple" : "yellow"] light is on."
/datum/wires/vending/UpdatePulsed(var/index)
/datum/wires/vending/UpdatePulsed(index)
var/obj/machinery/vending/V = holder
switch(index)
if(VENDING_WIRE_THROW)
@@ -39,7 +39,7 @@ var/const/VENDING_WIRE_IDSCAN = 8
if(VENDING_WIRE_IDSCAN)
V.scan_id = !V.scan_id
/datum/wires/vending/UpdateCut(var/index, var/mended)
/datum/wires/vending/UpdateCut(index, mended)
var/obj/machinery/vending/V = holder
switch(index)
if(VENDING_WIRE_THROW)
+75 -84
View File
@@ -26,7 +26,7 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
var/window_x = 370
var/window_y = 470
/datum/wires/New(var/atom/holder)
/datum/wires/New(atom/holder)
..()
src.holder = holder
if(!istype(holder, holder_type))
@@ -68,106 +68,97 @@ var/list/wireColours = list("red", "blue", "green", "black", "orange", "brown",
src.wires[colour] = index
//wires = shuffle(wires)
/datum/wires/proc/get_status()
return list()
/datum/wires/proc/Interact(var/mob/living/user)
/datum/wires/proc/Interact(mob/living/user)
if(user && istype(user) && holder && CanUse(user))
ui_interact(user)
var/html = null
if(holder && CanUse(user))
html = GetInteractWindow()
if(html)
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/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
ui = nanomanager.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "wires.tmpl", holder.name, window_x, window_y)
ui.open()
/datum/wires/proc/GetInteractWindow()
var/html = "<div class='block'>"
html += "<h3>Exposed Wires</h3>"
html += "<table[table_options]>"
/datum/wires/ui_data(mob/user, ui_key = "main", datum/topic_state/state = default_state)
var/data[0]
var/list/W[0]
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=[UID()];action=1;cut=[colour]'>[IsColourCut(colour) ? "Mend" : "Cut"]</A>"
html += " <A href='?src=[UID()];action=1;pulse=[colour]'>Pulse</A>"
html += " <A href='?src=[UID()];action=1;attach=[colour]'>[IsAttached(colour) ? "Detach" : "Attach"] Signaller</A></td></tr>"
html += "</table>"
html += "</div>"
W[++W.len] = list("colour" = capitalize(colour), "cut" = IsColourCut(colour), "attached" = IsAttached(colour))
return html
if(W.len > 0)
data["wires"] = W
var/list/status = get_status()
data["status_len"] = status.len
data["status"] = status
return data
/datum/wires/nano_host()
return holder
/datum/wires/Topic(href, href_list)
..()
if(..())
return 1
if(in_range(holder, usr) && isliving(usr))
var/mob/living/L = usr
if(CanUse(L) && href_list["action"])
var/obj/item/I = L.get_active_hand()
var/colour = lowertext(href_list["wire"])
holder.add_hiddenprint(L)
if(href_list["cut"]) // Toggles the cut/mend status
if(istype(I, /obj/item/weapon/wirecutters))
playsound(holder, 'sound/items/Wirecutter.ogg', 20, 1)
var/colour = href_list["cut"]
CutWireColour(colour)
else
to_chat(L, "<span class='error'>You need wirecutters!</span>")
else if(href_list["pulse"])
if(istype(I, /obj/item/device/multitool))
playsound(holder, 'sound/weapons/empty.ogg', 20, 1)
var/colour = href_list["pulse"]
PulseColour(colour)
else
to_chat(L, "<span class='error'>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/signaler))
L.drop_item()
Attach(colour, I)
switch(href_list["action"])
if("cut") // Toggles the cut/mend status
if(istype(I, /obj/item/weapon/wirecutters))
playsound(holder, 'sound/items/Wirecutter.ogg', 20, 1)
CutWireColour(colour)
else
to_chat(L, "<span class='error'>You need a remote signaller!</span>")
to_chat(L, "<span class='error'>You need wirecutters!</span>")
if("pulse")
if(istype(I, /obj/item/device/multitool))
playsound(holder, 'sound/weapons/empty.ogg', 20, 1)
PulseColour(colour)
else
to_chat(L, "<span class='error'>You need a multitool!</span>")
if("attach")
if(IsAttached(colour))
var/obj/item/O = Detach(colour)
if(O)
L.put_in_hands(O)
else
if(istype(I, /obj/item/device/assembly/signaler))
L.drop_item()
Attach(colour, I)
else
to_chat(L, "<span class='error'>You need a remote signaller!</span>")
// Update Window
Interact(usr)
if(href_list["close"])
usr << browse(null, "window=wires")
usr.unset_machine(holder)
nanomanager.update_uis(src)
return 1
//
// Overridable Procs
//
// Called when wires cut/mended.
/datum/wires/proc/UpdateCut(var/index, var/mended)
/datum/wires/proc/UpdateCut(index, mended)
return
// Called when wire pulsed. Add code here.
/datum/wires/proc/UpdatePulsed(var/index)
/datum/wires/proc/UpdatePulsed(index)
return
/datum/wires/proc/CanUse(var/mob/living/L)
/datum/wires/proc/CanUse(mob/living/L)
return 1
/datum/wires/CanUseTopic(mob/user, datum/topic_state/state)
if(!CanUse(user))
return STATUS_CLOSE
return ..()
// Example of use:
/*
@@ -194,15 +185,15 @@ var/const/POWER = 8
// Helper Procs
//
/datum/wires/proc/PulseColour(var/colour)
/datum/wires/proc/PulseColour(colour)
PulseIndex(GetIndex(colour))
/datum/wires/proc/PulseIndex(var/index)
/datum/wires/proc/PulseIndex(index)
if(IsIndexCut(index))
return
UpdatePulsed(index)
/datum/wires/proc/GetIndex(var/colour)
/datum/wires/proc/GetIndex(colour)
if(wires[colour])
var/index = wires[colour]
return index
@@ -213,28 +204,28 @@ var/const/POWER = 8
// Is Index/Colour Cut procs
//
/datum/wires/proc/IsColourCut(var/colour)
/datum/wires/proc/IsColourCut(colour)
var/index = GetIndex(colour)
return IsIndexCut(index)
/datum/wires/proc/IsIndexCut(var/index)
/datum/wires/proc/IsIndexCut(index)
return (index & wires_status)
//
// Signaller Procs
//
/datum/wires/proc/IsAttached(var/colour)
/datum/wires/proc/IsAttached(colour)
if(signallers[colour])
return 1
return 0
/datum/wires/proc/GetAttached(var/colour)
/datum/wires/proc/GetAttached(colour)
if(signallers[colour])
return signallers[colour]
return null
/datum/wires/proc/Attach(var/colour, var/obj/item/device/assembly/signaler/S)
/datum/wires/proc/Attach(colour, obj/item/device/assembly/signaler/S)
if(colour && S)
if(!IsAttached(colour))
signallers[colour] = S
@@ -242,7 +233,7 @@ var/const/POWER = 8
S.connected = src
return S
/datum/wires/proc/Detach(var/colour)
/datum/wires/proc/Detach(colour)
if(colour)
var/obj/item/device/assembly/signaler/S = GetAttached(colour)
if(S)
@@ -252,7 +243,7 @@ var/const/POWER = 8
return S
/datum/wires/proc/Pulse(var/obj/item/device/assembly/signaler/S)
/datum/wires/proc/Pulse(obj/item/device/assembly/signaler/S)
for(var/colour in signallers)
if(S == signallers[colour])
@@ -264,11 +255,11 @@ var/const/POWER = 8
// Cut Wire Colour/Index procs
//
/datum/wires/proc/CutWireColour(var/colour)
/datum/wires/proc/CutWireColour(colour)
var/index = GetIndex(colour)
CutWireIndex(index)
/datum/wires/proc/CutWireIndex(var/index)
/datum/wires/proc/CutWireIndex(index)
if(IsIndexCut(index))
wires_status &= ~index
UpdateCut(index, 1)
@@ -180,11 +180,6 @@ var/global/list/default_medbay_channels = list(
/mob/dead/observer/has_internal_radio_channel_access(var/mob/user, var/list/req_one_accesses)
return can_admin_interact()
/obj/item/device/radio/proc/text_wires()
if(b_stat)
return wires.GetInteractWindow()
return
/obj/item/device/radio/proc/ToggleBroadcast()
broadcasting = !broadcasting && !(wires.IsIndexCut(WIRE_TRANSMIT) || wires.IsIndexCut(WIRE_SIGNAL))
@@ -311,7 +311,7 @@
else
dat += "<A href='?src=[UID()];op=cellinsert'>Removed</A><BR>"
dat += wires.GetInteractWindow()
wires.ui_interact(user)
else
dat += "<div class='notice'>The bot is in maintenance mode and cannot be controlled.</div><BR>"
+24
View File
@@ -0,0 +1,24 @@
<div class="statusDisplay">
<table style='width:100%;'>
{{for data.wires}}
<tr>
<td style='color: {{:value.colour}};'>{{:value.colour}}</a>
<td class='floatRight'>
{{:helper.link(value.cut ? 'Mend' : 'Cut', null, {'action' : 'cut', 'wire' : value.colour})}}
{{:helper.link('Pulse', null, {'action' : 'pulse', 'wire' : value.colour})}}
{{:helper.link(value.attached ? 'Detach' : 'Attach', null, {'action' : 'attach', 'wire' : value.colour})}}
</td>
</tr>
{{/for}}
</table>
</div>
{{if data.status_len}}
<hr>
<div class="statusDisplay">
<div class="item">
{{for data.status}}
<div class='line'>{{:value}}</div>
{{/for}}
</div>
</div>
{{/if}}