From d624f0e077d43e8bf77a3881798393326fd952aa Mon Sep 17 00:00:00 2001 From: Interception&? <137328283+intercepti0n@users.noreply.github.com> Date: Fri, 20 Oct 2023 20:02:12 +0300 Subject: [PATCH] convert assembly-related UIs to TGUI (#8342) * replace ugly type-checking procs with macro * replace NanoUI state check with TGUI * add basic TGUI support to assembly * convert timer UI to TGUI * convert signaler UI to TGUI * convert proximity sensor UI to TGUI * convert transfer valve UI to TGUI * update TGUI bundle * fix signaler component export --- cev_eris.dme | 3 +- code/__DEFINES/is_helpers.dm | 13 ++ code/game/machinery/portable_turret.dm | 2 +- .../objects/items/devices/transfer_valve.dm | 96 +++++----- .../items/weapons/grenades/chem_grenade.dm | 14 +- code/modules/assembly/assembly.dm | 32 ++-- code/modules/assembly/bomb.dm | 2 +- code/modules/assembly/helpers.dm | 29 ---- code/modules/assembly/proximity.dm | 120 ++++++------- code/modules/assembly/signaler.dm | 94 +++++----- code/modules/assembly/timer.dm | 74 ++++---- code/modules/mob/living/bot/ed209bot.dm | 2 +- code/modules/mob/living/bot/farmbot.dm | 2 +- code/modules/mob/living/bot/floorbot.dm | 2 +- code/modules/mob/living/bot/medbot.dm | 2 +- code/modules/mob/living/bot/secbot.dm | 4 +- code/modules/nano/interaction/hands.dm | 23 --- .../reagent_containers/glass/beaker.dm | 2 +- code/modules/tgui/states/hands.dm | 7 +- .../tgui/interfaces/ProximitySensor.js | 72 -------- .../tgui/interfaces/ProximitySensor.tsx | 115 ++++++++++++ tgui/packages/tgui/interfaces/Signaler.js | 106 ----------- tgui/packages/tgui/interfaces/Signaler.tsx | 164 ++++++++++++++++++ tgui/packages/tgui/interfaces/Timer.tsx | 91 +++++----- .../{TransferValve.js => TransferValve.tsx} | 62 +++++-- tgui/public/tgui.bundle.js | 2 +- 26 files changed, 612 insertions(+), 523 deletions(-) delete mode 100644 code/modules/assembly/helpers.dm delete mode 100644 code/modules/nano/interaction/hands.dm delete mode 100644 tgui/packages/tgui/interfaces/ProximitySensor.js create mode 100644 tgui/packages/tgui/interfaces/ProximitySensor.tsx delete mode 100644 tgui/packages/tgui/interfaces/Signaler.js create mode 100644 tgui/packages/tgui/interfaces/Signaler.tsx rename tgui/packages/tgui/interfaces/{TransferValve.js => TransferValve.tsx} (59%) diff --git a/cev_eris.dme b/cev_eris.dme index 7ae1726112e..eff9506c3c3 100644 --- a/cev_eris.dme +++ b/cev_eris.dme @@ -1453,7 +1453,6 @@ #include "code\modules\alarm\power_alarm.dm" #include "code\modules\assembly\assembly.dm" #include "code\modules\assembly\bomb.dm" -#include "code\modules\assembly\helpers.dm" #include "code\modules\assembly\holder.dm" #include "code\modules\assembly\igniter.dm" #include "code\modules\assembly\infrared.dm" @@ -2271,7 +2270,6 @@ #include "code\modules\nano\interaction\contained.dm" #include "code\modules\nano\interaction\default.dm" #include "code\modules\nano\interaction\exosuits.dm" -#include "code\modules\nano\interaction\hands.dm" #include "code\modules\nano\interaction\interactive.dm" #include "code\modules\nano\interaction\inventory.dm" #include "code\modules\nano\interaction\inventory_deep.dm" @@ -2749,6 +2747,7 @@ #include "code\modules\tgui\tgui.dm" #include "code\modules\tgui\tgui_window.dm" #include "code\modules\tgui\states\always.dm" +#include "code\modules\tgui\states\hands.dm" #include "code\modules\tgui\states\machinery.dm" #include "code\modules\tgui\states\notcontained.dm" #include "code\modules\tips_and_tricks\gameplay.dm" diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index f42d8e2313a..691523c118f 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -97,3 +97,16 @@ #define ismachinery(A) (istype(A, /obj/machinery)) #define isProjectile(A) (istype(A, /obj/item/projectile)) + +// Assembly specific checks +#define isassembly(A) (istype(A, /obj/item/device/assembly)) + +#define isigniter(A) (istype(A, /obj/item/device/assembly/igniter)) + +#define isinfrared(A) (istype(A, /obj/item/device/assembly/infra)) + +#define isproxsensor(A) (istype(A, /obj/item/device/assembly/prox_sensor)) + +#define issignaler(A) (istype(A, /obj/item/device/assembly/signaler)) + +#define istimer(A) (istype(A, /obj/item/device/assembly/timer)) diff --git a/code/game/machinery/portable_turret.dm b/code/game/machinery/portable_turret.dm index 658c89fa059..6207c80612b 100644 --- a/code/game/machinery/portable_turret.dm +++ b/code/game/machinery/portable_turret.dm @@ -902,7 +902,7 @@ var/list/turret_icons //attack_hand() removes the gun if(4) - if(is_proximity_sensor(I)) + if(isproxsensor(I)) build_step = 5 if(!user.unEquip(I)) to_chat(user, SPAN_NOTICE("\the [I] is stuck to your hand, you cannot put it in \the [src]")) diff --git a/code/game/objects/items/devices/transfer_valve.dm b/code/game/objects/items/devices/transfer_valve.dm index 0df064d8d10..e45824b2114 100644 --- a/code/game/objects/items/devices/transfer_valve.dm +++ b/code/game/objects/items/devices/transfer_valve.dm @@ -35,9 +35,8 @@ log_game("[key_name_admin(user)] attached both tanks to a transfer valve.") update_icon() - SSnano.update_uis(src) // update all UIs attached to src //TODO: Have this take an assemblyholder - else if(is_assembly(item)) + else if(isassembly(item)) var/obj/item/device/assembly/A = item if(A.secured) to_chat(user, SPAN_NOTICE("The device is secured.")) @@ -56,7 +55,6 @@ message_admins("[key_name_admin(user)] attached a [item] to a transfer valve. (JMP)") log_game("[key_name_admin(user)] attached a [item] to a transfer valve.") attacher = user - SSnano.update_uis(src) // update all UIs attached to src return @@ -66,53 +64,48 @@ return -/obj/item/device/transfer_valve/attack_self(mob/user as mob) - nano_ui_interact(user) +/obj/item/device/transfer_valve/attack_self(mob/user) + ui_interact(user) -/obj/item/device/transfer_valve/nano_ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = NANOUI_FOCUS) +/obj/item/device/transfer_valve/ui_state(mob/user) + return GLOB.hands_state - // this is the data which will be sent to the ui - var/data[0] - data["attachmentOne"] = tank_one ? tank_one.name : null - data["attachmentTwo"] = tank_two ? tank_two.name : null - data["valveAttachment"] = attached_device ? attached_device.name : null - data["valveOpen"] = valve_open ? 1 : 0 - - // update the ui if it exists, returns null if no ui is passed/found - ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open) - 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, "transfer_valve.tmpl", "Tank Transfer Valve", 460, 280) - // when the ui is first opened this is the data it will use - ui.set_initial_data(data) - // open the new ui window +/obj/item/device/transfer_valve/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "TransferValve", name) ui.open() - // auto update every Master Controller tick - //ui.set_auto_update(1) - -/obj/item/device/transfer_valve/Topic(href, href_list) - ..() - if ( usr.stat || usr.restrained() ) - return 0 - if (src.loc != usr) - return 0 - if(tank_one && href_list["tankone"]) - remove_tank(tank_one) - else if(tank_two && href_list["tanktwo"]) - remove_tank(tank_two) - else if(href_list["open"]) - toggle_valve() - else if(attached_device) - if(href_list["rem_device"]) - attached_device.loc = get_turf(src) - attached_device:holder = null - attached_device = null - update_icon() - if(href_list["device"]) - attached_device.attack_self(usr) - src.add_fingerprint(usr) - return 1 // Returning 1 sends an update to attached UIs + +/obj/item/device/transfer_valve/ui_data(mob/user) + var/list/data = list( + "attachmentOne" = tank_one ? tank_one.name : null, + "attachmentTwo" = tank_two ? tank_two.name : null, + "attachment" = attached_device ? attached_device.name : null, + "isOpen" = valve_open + ) + return data + +/obj/item/device/transfer_valve/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return + + switch(action) + if("toggle") + toggle_valve() + . = TRUE + if("device") + attached_device?.attack_self(usr) + . = TRUE + if("remove_device") + remove_device() + . = TRUE + if("tankone") + remove_tank(tank_one) + . = TRUE + if("tanktwo") + remove_tank(tank_two) + . = TRUE /obj/item/device/transfer_valve/process_activation(var/obj/item/device/D) if(toggle) @@ -139,6 +132,15 @@ if(attached_device) overlays += "device" +/obj/item/device/transfer_valve/proc/remove_device() + if(isnull(attached_device)) + return + + attached_device.forceMove(get_turf(src)) + attached_device:holder = null // Very-very bad, somebody fix. + attached_device = null + update_icon() + /obj/item/device/transfer_valve/proc/remove_tank(obj/item/tank/T) if(tank_one == T) split_gases() diff --git a/code/game/objects/items/weapons/grenades/chem_grenade.dm b/code/game/objects/items/weapons/grenades/chem_grenade.dm index ba89798572b..af682aeb279 100644 --- a/code/game/objects/items/weapons/grenades/chem_grenade.dm +++ b/code/game/objects/items/weapons/grenades/chem_grenade.dm @@ -58,7 +58,7 @@ return if(istype(W,/obj/item/device/assembly_holder) && stage != READY && path != 2) var/obj/item/device/assembly_holder/det = W - if(istype(det.left_assembly,det.right_assembly.type) || (!is_igniter(det.left_assembly) && !is_igniter(det.right_assembly))) + if(istype(det.left_assembly,det.right_assembly.type) || (!isigniter(det.left_assembly) && !isigniter(det.right_assembly))) to_chat(user, SPAN_WARNING("Assembly must contain one igniter.")) return if(!det.secured) @@ -70,10 +70,10 @@ user.remove_from_mob(det) det.loc = src detonator = det - if(is_timer(detonator.left_assembly)) + if(istimer(detonator.left_assembly)) var/obj/item/device/assembly/timer/T = detonator.left_assembly det_time = 10*T.time - if(is_timer(detonator.right_assembly)) + if(istimer(detonator.right_assembly)) var/obj/item/device/assembly/timer/T = detonator.right_assembly det_time = 10*T.time icon_state = initial(icon_state) +"_ass" @@ -128,11 +128,11 @@ if(active) return if(detonator) - if(!is_igniter(detonator.left_assembly)) + if(!isigniter(detonator.left_assembly)) detonator.left_assembly.activate() active = TRUE log_and_message_admins("primed via detonator \a [src]") - if(!is_igniter(detonator.right_assembly)) + if(!isigniter(detonator.right_assembly)) detonator.right_assembly.activate() active = TRUE log_and_message_admins("primed via detonator \a [src]") @@ -160,10 +160,10 @@ icon_state = initial(icon_state) +"_locked" playsound(loc, 'sound/items/Screwdriver2.ogg', 50, 1) spawn(0) //Otherwise det_time is erroneously set to 0 after this - if(is_timer(detonator.left_assembly)) //Make sure description reflects that the timer has been reset + if(istimer(detonator.left_assembly)) //Make sure description reflects that the timer has been reset var/obj/item/device/assembly/timer/T = detonator.left_assembly det_time = 10*T.time - if(is_timer(detonator.right_assembly)) + if(istimer(detonator.right_assembly)) var/obj/item/device/assembly/timer/T = detonator.right_assembly det_time = 10*T.time return diff --git a/code/modules/assembly/assembly.dm b/code/modules/assembly/assembly.dm index 02429922ac7..916254647f5 100644 --- a/code/modules/assembly/assembly.dm +++ b/code/modules/assembly/assembly.dm @@ -74,7 +74,7 @@ /obj/item/device/assembly/attackby(obj/item/I, mob/user) - if(is_assembly(I)) + if(isassembly(I)) var/obj/item/device/assembly/A = I if((!A.secured) && (!secured)) attach_assembly(A, user) @@ -103,24 +103,34 @@ /obj/item/device/assembly/attack_self(mob/user) if(!user) - return 0 - user.set_machine(src) - interact(user) - return 1 + return FALSE + interact(user) + return TRUE /obj/item/device/assembly/interact(mob/user) - return //HTML MENU FOR WIRES GOES HERE + return ui_interact(user) /obj/item/device/assembly/proc/holder_movement() return -/obj/item/device/assembly/nano_host() - if(istype(loc, /obj/item/device/assembly_holder)) - return loc.nano_host() - return ..() - /obj/item/device/assembly/proc/is_attachable() if(secured) return FALSE return TRUE + +/obj/item/device/assembly/proc/is_secured(mob/user) + if(!secured) + to_chat(user, SPAN_WARNING("The [name] is unsecured!")) + return FALSE + + return TRUE + +/obj/item/device/assembly/ui_host(mob/user) + if(holder) + return holder + + return ..() + +/obj/item/device/assembly/ui_state(mob/user) + return GLOB.hands_state diff --git a/code/modules/assembly/bomb.dm b/code/modules/assembly/bomb.dm index df7d41712ff..d240660a2cd 100644 --- a/code/modules/assembly/bomb.dm +++ b/code/modules/assembly/bomb.dm @@ -93,7 +93,7 @@ var/mob/M = user if(!S.secured) //Check if the assembly is secured return - if(is_igniter(S.left_assembly) == is_igniter(S.right_assembly)) //Check if either part of the assembly has an igniter, but if both parts are igniters, then fuck it + if(isigniter(S.left_assembly) == isigniter(S.right_assembly)) //Check if either part of the assembly has an igniter, but if both parts are igniters, then fuck it return var/obj/item/device/onetankbomb/R = new /obj/item/device/onetankbomb(loc) diff --git a/code/modules/assembly/helpers.dm b/code/modules/assembly/helpers.dm deleted file mode 100644 index 221bd123b50..00000000000 --- a/code/modules/assembly/helpers.dm +++ /dev/null @@ -1,29 +0,0 @@ -/proc/is_assembly(O) - if(istype(O, /obj/item/device/assembly)) - return TRUE - return FALSE - -/proc/is_igniter(O) - if(istype(O, /obj/item/device/assembly/igniter)) - return TRUE - return FALSE - -/proc/is_infrared(O) - if(istype(O, /obj/item/device/assembly/infra)) - return TRUE - return FALSE - -/proc/is_proximity_sensor(O) - if(istype(O, /obj/item/device/assembly/prox_sensor)) - return TRUE - return FALSE - -/proc/is_signaler(O) - if(istype(O, /obj/item/device/assembly/signaler)) - return TRUE - return FALSE - -/proc/is_timer(O) - if(istype(O, /obj/item/device/assembly/timer)) - return TRUE - return FALSE diff --git a/code/modules/assembly/proximity.dm b/code/modules/assembly/proximity.dm index d7c0cdb486e..a981f79d4bf 100644 --- a/code/modules/assembly/proximity.dm +++ b/code/modules/assembly/proximity.dm @@ -9,14 +9,10 @@ secured = FALSE - var/scanning = 0 - var/timing = 0 - var/time = 10 - + var/scanning = FALSE var/range = 2 - -/obj/item/device/assembly/prox_sensor/proc/toggle_scan() - sense() + var/timing = FALSE + var/time = 10 /obj/item/device/assembly/prox_sensor/activate() @@ -81,12 +77,6 @@ sense() -/obj/item/device/assembly/prox_sensor/toggle_scan() - if(!secured) return 0 - scanning = !scanning - update_icon() - - /obj/item/device/assembly/prox_sensor/update_icon() overlays.Cut() attached_overlays = list() @@ -108,56 +98,68 @@ sense() -/obj/item/device/assembly/prox_sensor/interact(mob/user as mob)//TODO: Change this to the wires thingy - if(!secured) - to_chat(user, SPAN_WARNING("The [name] is unsecured!")) - return - var/second = time % 60 - var/minute = (time - second) / 60 - var/dat = {" - Proximity Sensor
[minute]:[second]
- - - - - + - +
-
[timing ? "Arming" : "Not Arming"] -
Range: - [range] + -
[scanning ? "Armed" : "Unarmed"] (Movement sensor active when armed!) -

Refresh -

Close - "} - user << browse(dat, "window=prox") - onclose(user, "prox") - - -/obj/item/device/assembly/prox_sensor/Topic(href, href_list) - if(..()) - return TRUE - if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) - usr << browse(null, "window=prox") - onclose(usr, "prox") - return +/obj/item/device/assembly/prox_sensor/ui_status(mob/user) + if(is_secured(user)) + return ..() + + return UI_CLOSE + + +/obj/item/device/assembly/prox_sensor/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "ProximitySensor", name) + ui.open() - if(href_list["scanning"]) - toggle_scan() - if(href_list["time"]) - timing = text2num(href_list["time"]) - update_icon() +/obj/item/device/assembly/prox_sensor/ui_data(mob/user) + var/list/data = list( + "isScanning" = scanning, + "isTiming" = timing, + "range" = range + ) - if(href_list["tp"]) - var/tp = text2num(href_list["tp"]) - time += tp - time = min(max(round(time), 0), 600) + data["minutes"] = round((time - data["seconds"]) / 60) + data["seconds"] = round(time % 60) - if(href_list["range"]) - var/r = text2num(href_list["range"]) - range += r - range = min(max(range, 1), 5) + return data - if(href_list["close"]) - usr << browse(null, "window=prox") + +/obj/item/device/assembly/prox_sensor/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) return - if(usr) - attack_self(usr) + switch(action) + if("sense") + toggle_scan() + . = TRUE + if("time") + toggle_time() + . = TRUE + if("adjust") + if(params["range"]) + var/value = text2num(params["range"]) + range = clamp(range + value, 1, 5) + . = TRUE + else if(params["time"]) + var/value = text2num(params["time"]) + time = clamp(time + value, 0, 600) + . = TRUE + + +/obj/item/device/assembly/prox_sensor/proc/toggle_scan() + if(!secured) + return FALSE + + scanning = !scanning + update_icon() + sense() + + +/obj/item/device/assembly/prox_sensor/proc/toggle_time() + if(!secured) + return FALSE + + timing = !timing + update_icon() diff --git a/code/modules/assembly/signaler.dm b/code/modules/assembly/signaler.dm index 2ea27639a47..a1a646d5275 100644 --- a/code/modules/assembly/signaler.dm +++ b/code/modules/assembly/signaler.dm @@ -1,3 +1,6 @@ +#define SIGNALER_DEFAULT_CODE 30 +#define SIGNALER_DEFAULT_FREQUENCY 1457 + /obj/item/device/assembly/signaler name = "remote signaling device" desc = "Used to remotely activate devices." @@ -33,70 +36,70 @@ signal() return 1 + /obj/item/device/assembly/signaler/update_icon() if(holder) holder.update_icon() return + /obj/item/device/assembly/signaler/proc/set_code(new_code) code = clamp(round(new_code), 1, 100) + /obj/item/device/assembly/signaler/proc/set_freq(new_freq) set_frequency(sanitize_frequency(round(new_freq), RADIO_LOW_FREQ, RADIO_HIGH_FREQ)) -/obj/item/device/assembly/signaler/interact(mob/user, flag1) - nano_ui_interact(user) -/obj/item/device/assembly/signaler/nano_ui_data() - var/list/data = list( - "freq" = frequency, - "code" = code - ) - return data - -/obj/item/device/assembly/signaler/nano_ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = NANOUI_FOCUS, datum/nano_topic_state/state = GLOB.default_state) - var/list/data = nano_ui_data(user) - - ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open) - if (!ui) - ui = new(user, src, ui_key, "mpc_signaller.tmpl", name, 350, 200, state = state) - ui.set_initial_data(data) - ui.open() +/obj/item/device/assembly/signaler/ui_status(mob/user) + if(is_secured(user)) + return ..() -/obj/item/device/assembly/signaler/Topic(href, href_list) - if(..()) - return 1 + return UI_CLOSE - if(href_list["signal"]) - set_freq(text2num(href_list["freq"])) - set_code(text2num(href_list["code"])) - spawn(0) - signal() - return 1 +/obj/item/device/assembly/signaler/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "Signaler", name) + ui.open() - if(href_list["change_code"]) - set_code(code + text2num(href_list["change_code"])) - return 1 - if(href_list["edit_code"]) - var/input_code = input("Enter signal code (1-100):", "Signal parameters", code) as num|null - if(input_code && CanUseTopic(usr)) - set_code(input_code) - return 1 +/obj/item/device/assembly/signaler/ui_data(mob/user) + var/list/data = list( + "maxFrequency" = RADIO_HIGH_FREQ, + "minFrequency" = RADIO_LOW_FREQ, + "frequency" = frequency, + "code" = code + ) + return data - if(href_list["change_freq"]) - set_freq(frequency + text2num(href_list["change_freq"])) - return 1 - if(href_list["edit_freq"]) - var/input_freq = input("Enter signal frequency ([RADIO_LOW_FREQ]-[RADIO_HIGH_FREQ]):", "Signal parameters", frequency) as num|null - if(input_freq && CanUseTopic(usr)) - if(input_freq < RADIO_LOW_FREQ) // A decimal input maybe? - input_freq *= 10 +/obj/item/device/assembly/signaler/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) + return - set_freq(input_freq) - return 1 + switch(action) + if("signal") + signal() + . = TRUE + if("adjust") + if(params["freq"]) + var/value = params["freq"] + set_freq(frequency + value) + . = TRUE + else if(params["code"]) + var/value = params["code"] + set_code(code + value) + . = TRUE + if("reset") + if(params["freq"]) + frequency = SIGNALER_DEFAULT_FREQUENCY + . = TRUE + else if(params["code"]) + code = SIGNALER_DEFAULT_CODE + . = TRUE /obj/item/device/assembly/signaler/proc/signal() @@ -169,3 +172,6 @@ SSradio.remove_object(src,frequency) frequency = 0 . = ..() + +#undef SIGNALER_DEFAULT_FREQUENCY +#undef SIGNALER_DEFAULT_CODE diff --git a/code/modules/assembly/timer.dm b/code/modules/assembly/timer.dm index bff7db776ca..a66c2a9bf42 100644 --- a/code/modules/assembly/timer.dm +++ b/code/modules/assembly/timer.dm @@ -5,11 +5,10 @@ origin_tech = list(TECH_MAGNET = 1) matter = list(MATERIAL_PLASTIC = 1) + secured = FALSE wires = WIRE_PULSE - secured = 0 - - var/timing = 0 + var/timing = FALSE var/time = 10 @@ -61,47 +60,40 @@ if(holder) holder.update_icon() +/obj/item/device/assembly/timer/ui_status(mob/user) + if(is_secured(user)) + return ..() -/obj/item/device/assembly/timer/interact(mob/user as mob)//TODO: Have this use the wires - if(!secured) - to_chat(user, SPAN_WARNING("The [name] is unsecured!")) - return - var/second = time % 60 - var/minute = (time - second) / 60 - - var/dat = {" - Timing Unit
[minute]:[second]
- - - - - + - +
- [timing ? "Timing" : "Not Timing"] -

Refresh -

Close - "} - user << browse(dat, "window=timer") - onclose(user, "timer") - - -/obj/item/device/assembly/timer/Topic(href, href_list) - if(..()) return 1 - if(!usr.canmove || usr.stat || usr.restrained() || !in_range(loc, usr)) - usr << browse(null, "window=timer") - onclose(usr, "timer") - return + return UI_CLOSE - if(href_list["time"]) - timing = text2num(href_list["time"]) - update_icon() +/obj/item/device/assembly/timer/ui_interact(mob/user, datum/tgui/ui) + ui = SStgui.try_update_ui(user, src, ui) + if(!ui) + ui = new(user, src, "Timer", name) + ui.open() - if(href_list["tp"]) - var/tp = text2num(href_list["tp"]) - time += tp - time = min(max(round(time), 0), 600) +/obj/item/device/assembly/timer/ui_data(mob/user) + var/list/data = list( + "isTiming" = timing, + ) - if(href_list["close"]) - usr << browse(null, "window=timer") + data["minutes"] = round((time - data["seconds"]) / 60) + data["seconds"] = round(time % 60) + + return data + +/obj/item/device/assembly/timer/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) + . = ..() + if(.) return - if(usr) - attack_self(usr) + switch(action) + if("time") + timing = !timing + . = TRUE + if("adjust") + if(params["value"]) + var/value = text2num(params["value"]) + time = clamp(time + value, 0, 600) + . = TRUE + diff --git a/code/modules/mob/living/bot/ed209bot.dm b/code/modules/mob/living/bot/ed209bot.dm index 393e70ff27f..b2060857438 100644 --- a/code/modules/mob/living/bot/ed209bot.dm +++ b/code/modules/mob/living/bot/ed209bot.dm @@ -158,7 +158,7 @@ icon_state = "ed209_hat" if(5) - if(is_proximity_sensor(I)) + if(isproxsensor(I)) user.drop_item() qdel(I) build_step++ diff --git a/code/modules/mob/living/bot/farmbot.dm b/code/modules/mob/living/bot/farmbot.dm index 80e755c6ee9..d3ed5fec4cb 100644 --- a/code/modules/mob/living/bot/farmbot.dm +++ b/code/modules/mob/living/bot/farmbot.dm @@ -363,7 +363,7 @@ user.remove_from_mob(W) qdel(W) - else if((is_proximity_sensor(W)) && (build_step == 3)) + else if((isproxsensor(W)) && (build_step == 3)) build_step++ to_chat(user, "You complete the Farmbot! Beep boop.") playsound(src.loc, 'sound/effects/insert.ogg', 50, 1) diff --git a/code/modules/mob/living/bot/floorbot.dm b/code/modules/mob/living/bot/floorbot.dm index 1863b8cb3ce..fea4726402a 100644 --- a/code/modules/mob/living/bot/floorbot.dm +++ b/code/modules/mob/living/bot/floorbot.dm @@ -381,7 +381,7 @@ /obj/item/toolbox_tiles/attackby(var/obj/item/W, mob/user as mob) ..() - if(is_proximity_sensor(W)) + if(isproxsensor(W)) qdel(W) var/obj/item/toolbox_tiles_sensor/B = new /obj/item/toolbox_tiles_sensor() B.created_name = created_name diff --git a/code/modules/mob/living/bot/medbot.dm b/code/modules/mob/living/bot/medbot.dm index 320d41572de..963e3419713 100644 --- a/code/modules/mob/living/bot/medbot.dm +++ b/code/modules/mob/living/bot/medbot.dm @@ -355,7 +355,7 @@ overlays += image('icons/obj/aibots.dmi', "na_scanner") if(1) - if(is_proximity_sensor(W)) + if(isproxsensor(W)) user.drop_item() qdel(W) to_chat(user, SPAN_NOTICE("You complete the Medibot! Beep boop.")) diff --git a/code/modules/mob/living/bot/secbot.dm b/code/modules/mob/living/bot/secbot.dm index 9ad4229f729..814dadfa5a2 100644 --- a/code/modules/mob/living/bot/secbot.dm +++ b/code/modules/mob/living/bot/secbot.dm @@ -479,7 +479,7 @@ /obj/item/clothing/head/armor/helmet/attackby(var/obj/item/device/assembly/signaler/S, mob/user as mob) ..() - if(!is_signaler(S)) + if(!issignaler(S)) ..() return @@ -514,7 +514,7 @@ overlays += image('icons/obj/aibots.dmi', "hs_hole") to_chat(user, "You weld a hole in \the [src].") - else if(is_proximity_sensor(I) && (build_step == 1)) + else if(isproxsensor(I) && (build_step == 1)) user.drop_item() build_step = 2 to_chat(user, "You add \the [I] to [src].") diff --git a/code/modules/nano/interaction/hands.dm b/code/modules/nano/interaction/hands.dm deleted file mode 100644 index 0791f8b8c23..00000000000 --- a/code/modules/nano/interaction/hands.dm +++ /dev/null @@ -1,23 +0,0 @@ -/* - This state only checks if user is conscious. -*/ -GLOBAL_DATUM_INIT(hands_state, /datum/nano_topic_state/hands, new) - -/datum/nano_topic_state/hands/can_use_topic(src_object, mob/user) - . = user.shared_nano_interaction(src_object) - if(. > STATUS_CLOSE) - . = min(., user.hands_can_use_topic(src_object)) - -/mob/proc/hands_can_use_topic(src_object) - return STATUS_CLOSE - -/mob/living/hands_can_use_topic(src_object) - if(src_object in get_both_hands(src)) - return STATUS_INTERACTIVE - return STATUS_CLOSE - -/mob/living/silicon/robot/hands_can_use_topic(src_object) - for(var/obj/item/gripper/active_gripper in list(module_state_1, module_state_2, module_state_3)) - if(active_gripper.contains(src_object)) - return STATUS_INTERACTIVE - return STATUS_CLOSE diff --git a/code/modules/reagents/reagent_containers/glass/beaker.dm b/code/modules/reagents/reagent_containers/glass/beaker.dm index 7505b3202d3..db35a3b2d66 100644 --- a/code/modules/reagents/reagent_containers/glass/beaker.dm +++ b/code/modules/reagents/reagent_containers/glass/beaker.dm @@ -204,7 +204,7 @@ /obj/item/reagent_containers/glass/bucket/attackby(obj/D, mob/user) - if(is_proximity_sensor(D)) + if(isproxsensor(D)) to_chat(user, "You add [D] to [src].") qdel(D) user.put_in_hands(new /obj/item/bucket_sensor) diff --git a/code/modules/tgui/states/hands.dm b/code/modules/tgui/states/hands.dm index e8cb844bf7f..9b4b7b1c811 100644 --- a/code/modules/tgui/states/hands.dm +++ b/code/modules/tgui/states/hands.dm @@ -20,11 +20,12 @@ GLOBAL_DATUM_INIT(hands_state, /datum/ui_state/hands_state, new) return UI_CLOSE /mob/living/hands_can_use_topic(src_object) - if(is_holding(src_object)) + if(src_object in get_both_hands(src)) return UI_INTERACTIVE return UI_CLOSE /mob/living/silicon/robot/hands_can_use_topic(src_object) - if(activated(src_object)) - return UI_INTERACTIVE + for(var/obj/item/gripper/active_gripper in list(module_state_1, module_state_2, module_state_3)) + if(active_gripper.contains(src_object)) + return UI_INTERACTIVE return UI_CLOSE diff --git a/tgui/packages/tgui/interfaces/ProximitySensor.js b/tgui/packages/tgui/interfaces/ProximitySensor.js deleted file mode 100644 index bf7b1502e7b..00000000000 --- a/tgui/packages/tgui/interfaces/ProximitySensor.js +++ /dev/null @@ -1,72 +0,0 @@ -import { useBackend } from '../backend'; -import { Button, LabeledList, Section } from '../components'; -import { Window } from '../layouts'; - -export const ProximitySensor = (props, context) => { - const { act, data } = useBackend(context); - const { minutes, seconds, timing, scanning, sensitivity } = data; - return ( - - -
- - -
-
act('time')} - /> - }> -
-
-
- ); -}; diff --git a/tgui/packages/tgui/interfaces/ProximitySensor.tsx b/tgui/packages/tgui/interfaces/ProximitySensor.tsx new file mode 100644 index 00000000000..d0bc4f45c6d --- /dev/null +++ b/tgui/packages/tgui/interfaces/ProximitySensor.tsx @@ -0,0 +1,115 @@ +import { useBackend } from '../backend'; +import { Box, Button, Section, Stack } from '../components'; +import { Window } from '../layouts'; + +interface ProximitySensorData { + isScanning: boolean; + isTiming: boolean; + minutes: number; + seconds: number; + range: number; +} + +export const ProximitySensor = (props: any, context: any) => { + return ( + + + + + + ); +}; + +const ProximitySensorContent = (props: any, context: any) => { + const { act, data } = useBackend(context); + const { isScanning, isTiming, minutes, seconds, range } = data; + + return ( + <> +
act('sense')} + /> + }> + +
+
act('time')} + /> + }> + +
+ + ); +}; + +const RangeContent = (props: any, context: any) => { + const { act, data } = useBackend(context); + const { isScanning, range } = data; + + return ( + + + Detection Range: + + +