diff --git a/code/datums/wires/airlock.dm b/code/datums/wires/airlock.dm index 96d55e05518..2f647c435f2 100644 --- a/code/datums/wires/airlock.dm +++ b/code/datums/wires/airlock.dm @@ -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("
\n[]
\n[]
\n[]
\n[]
\n[]
\n[]
\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) diff --git a/code/datums/wires/alarm.dm b/code/datums/wires/alarm.dm index 32290d20bb0..3d8446299bd 100644 --- a/code/datums/wires/alarm.dm +++ b/code/datums/wires/alarm.dm @@ -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("
\n[(A.locked ? "The Air Alarm is locked." : "The Air Alarm is unlocked.")]
\n[((A.shorted || (A.stat & (NOPOWER|BROKEN))) ? "The Air Alarm is offline." : "The Air Alarm is working properly!")]
\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 diff --git a/code/datums/wires/apc.dm b/code/datums/wires/apc.dm index e37ad8241d3..02a50e3716e 100644 --- a/code/datums/wires/apc.dm +++ b/code/datums/wires/apc.dm @@ -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("
\n[(A.locked ? "The APC is locked." : "The APC is unlocked.")]
\n[(A.shorted ? "The APCs power has been shorted." : "The APC is working properly!")]
\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 diff --git a/code/datums/wires/autolathe.dm b/code/datums/wires/autolathe.dm index c6487f4cefb..91e28015930 100644 --- a/code/datums/wires/autolathe.dm +++ b/code/datums/wires/autolathe.dm @@ -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("
The red light is [A.disabled ? "off" : "on"].
The green light is [A.shocked ? "off" : "on"].
The blue light is [A.hacked ? "off" : "on"].
") + 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) diff --git a/code/datums/wires/pizza_bomb.dm b/code/datums/wires/pizza_bomb.dm index d3c64225e54..415f7c5ba23 100644 --- a/code/datums/wires/pizza_bomb.dm +++ b/code/datums/wires/pizza_bomb.dm @@ -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("
The red light is [P.primed ? "on" : "off"].
") - . += text("The green light is [P.disarmed ? "on": "off"].
") + 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 diff --git a/code/datums/wires/r_n_d.dm b/code/datums/wires/r_n_d.dm index 3f91c08da62..7e071258903 100644 --- a/code/datums/wires/r_n_d.dm +++ b/code/datums/wires/r_n_d.dm @@ -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("
The red light is [R.disabled ? "off" : "on"].
") - . += text("The green light is [R.shocked ? "off" : "on"].
") - . += text("The blue light is [R.hacked ? "off" : "on"].
") + 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 diff --git a/code/datums/wires/robot.dm b/code/datums/wires/robot.dm index a01efe58d21..79a418f01d5 100644 --- a/code/datums/wires/robot.dm +++ b/code/datums/wires/robot.dm @@ -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("
\n[(R.lawupdate ? "The LawSync light is on." : "The LawSync light is off.")]
\n[(R.connected_ai ? "The AI link light is on." : "The AI link light is off.")]") - . += text("
\n[((!isnull(R.camera) && R.camera.status == 1) ? "The Camera light is on." : "The Camera light is off.")]
\n") - . += text("
\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) diff --git a/code/datums/wires/vending.dm b/code/datums/wires/vending.dm index 505b99b3cf1..9f898f8ede1 100644 --- a/code/datums/wires/vending.dm +++ b/code/datums/wires/vending.dm @@ -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 - . += ..() - . += "
The orange light is [V.seconds_electrified ? "on" : "off"].
" - . += "The red light is [V.shoot_inventory ? "off" : "blinking"].
" - . += "The green light is [V.extended_inventory ? "on" : "off"].
" - . += "A [V.scan_id ? "purple" : "yellow"] light is on.
" + 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 \ No newline at end of file + V.scan_id = 1 + if(VENDING_WIRE_SPEAKER) + V.shut_up = mended \ No newline at end of file diff --git a/code/datums/wires/wires.dm b/code/datums/wires/wires.dm index d8f3cefe45c..90bb4a0a21c 100644 --- a/code/datums/wires/wires.dm +++ b/code/datums/wires/wires.dm @@ -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 = "
" - html += "

Exposed Wires

" - html += "" - - for(var/colour in wires) - html += "" - html += "[capitalize(colour)]" - html += "" - html += "[IsColourCut(colour) ? "Mend" : "Cut"]" - html += " Pulse" - html += " [IsAttached(colour) ? "Detach" : "Attach"] Signaller" - html += "" - html += "
" - - 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 << "You need wirecutters!" - - else if(href_list["pulse"]) - if(istype(I, /obj/item/device/multitool)) - var/colour = href_list["pulse"] - PulseColour(colour) - else - L << "You need a multitool!" - - 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 << "You need a attachable assembly!" - - - - - // 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() \ No newline at end of file + 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 << "You need wirecutters!" + if("pulse") + if(istype(I, /obj/item/device/multitool)) + PulseColour(target_wire) + else + L << "You need a multitool!" + 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 << "You need an attachable assembly!" + return 1 \ No newline at end of file diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm index 727527b47d3..b35bf348200 100644 --- a/code/game/machinery/autolathe.dm +++ b/code/game/machinery/autolathe.dm @@ -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) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index eefcecbc806..11098f7a075 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -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"]. Toggle" + 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 diff --git a/code/modules/tgui/states/wire.dm b/code/modules/tgui/states/wire.dm new file mode 100644 index 00000000000..41b247d9131 --- /dev/null +++ b/code/modules/tgui/states/wire.dm @@ -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 \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index 6476aa5b045..5271b015e52 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -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" diff --git a/tgui/src/interfaces/wires.ract b/tgui/src/interfaces/wires.ract new file mode 100644 index 00000000000..73181c00ee8 --- /dev/null +++ b/tgui/src/interfaces/wires.ract @@ -0,0 +1,13 @@ + + {{#each data.wires}} + + {{colour}} + {{isCut ? "Mend" : "Cut"}} + Pulse + {{hasAttachment ? "Detach" : "Attach"}} + + {{/each}} + {{#each data.holderInfo}} + {{.}} + {{/each}} + \ No newline at end of file