From 9ffe6f5fcb30cdf83502bfe7fe454dad1b19239e Mon Sep 17 00:00:00 2001 From: CHOMPStation2StaffMirrorBot <94713762+CHOMPStation2StaffMirrorBot@users.noreply.github.com> Date: Fri, 14 Feb 2025 21:32:35 -0700 Subject: [PATCH] [MIRROR] cleans up some left over things (#10168) Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> --- code/game/gamemodes/events/dust.dm | 31 ++++++++-------- code/game/machinery/cloning.dm | 2 +- code/game/objects/items/falling_object_vr.dm | 3 +- code/game/objects/items/toys/toys_vr.dm | 3 +- code/modules/projectiles/gun.dm | 11 ++++-- .../modules/projectiles/projectile/special.dm | 4 +- code/modules/shuttles/crashes.dm | 9 +++-- code/modules/shuttles/shuttle.dm | 31 ++++++++-------- code/modules/tgui_input/say_modal/modal.dm | 8 ++-- tgui/packages/common/storage.js | 12 +++++- tgui/packages/tgui-say/TguiSay.tsx | 26 +++++++++++-- tgui/packages/tgui-say/helpers.ts | 2 +- tgui/packages/tgui-say/timers.ts | 11 ++++-- tgui/packages/tgui/backend.ts | 37 ------------------- 14 files changed, 94 insertions(+), 96 deletions(-) diff --git a/code/game/gamemodes/events/dust.dm b/code/game/gamemodes/events/dust.dm index bcf038693f..22a7043e18 100644 --- a/code/game/gamemodes/events/dust.dm +++ b/code/game/gamemodes/events/dust.dm @@ -91,24 +91,23 @@ The "dust" will damage the hull of the station causin minor hull breaches. qdel(src) /obj/effect/space_dust/Bump(atom/A) - spawn(0) - if(prob(50)) - for(var/mob/M in range(10, src)) - if(!M.stat && !isAI(M)) - shake_camera(M, 3, 1) - if (A) - playsound(src, 'sound/effects/meteorimpact.ogg', 40, 1) + if(prob(50)) + for(var/mob/M in range(10, src)) + if(!M.stat && !isAI(M)) + shake_camera(M, 3, 1) + if (A) + playsound(src, 'sound/effects/meteorimpact.ogg', 40, 1) - if(ismob(A)) - A.ex_act(strength)//This should work for now I guess - else if(!istype(A,/obj/machinery/power/emitter) && !istype(A,/obj/machinery/field_generator)) //Protect the singularity from getting released every round! - A.ex_act(strength) //Changing emitter/field gen ex_act would make it immune to bombs and C4 + if(ismob(A)) + A.ex_act(strength)//This should work for now I guess + else if(!istype(A,/obj/machinery/power/emitter) && !istype(A,/obj/machinery/field_generator)) //Protect the singularity from getting released every round! + A.ex_act(strength) //Changing emitter/field gen ex_act would make it immune to bombs and C4 - life-- - if(life <= 0) - walk(src,0) - qdel(src) - return + life-- + if(life <= 0) + walk(src,0) + qdel(src) + return return diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index f2698dbd31..6411223e13 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -485,7 +485,7 @@ name = "Diskette Box" icon_state = "disk_kit" -/obj/item/storage/box/Initialize() +/obj/item/storage/box/disks/Initialize() . = ..() new /obj/item/disk/body_record(src) new /obj/item/disk/body_record(src) diff --git a/code/game/objects/items/falling_object_vr.dm b/code/game/objects/items/falling_object_vr.dm index d077304d8e..e51f8790d5 100644 --- a/code/game/objects/items/falling_object_vr.dm +++ b/code/game/objects/items/falling_object_vr.dm @@ -26,8 +26,7 @@ dropped.density = FALSE dropped.opacity = FALSE animate(dropped, pixel_y = initial_y, pixel_x = initial_x , time = 7) - spawn(7) - dropped.end_fall(crushing) + addtimer(CALLBACK(dropped, TYPE_PROC_REF(/atom/movable,end_fall), crushing), 0.7 SECONDS) qdel(src) /atom/movable/proc/end_fall(var/crushing = FALSE) diff --git a/code/game/objects/items/toys/toys_vr.dm b/code/game/objects/items/toys/toys_vr.dm index 0d5897f6f5..7c93795a5b 100644 --- a/code/game/objects/items/toys/toys_vr.dm +++ b/code/game/objects/items/toys/toys_vr.dm @@ -512,8 +512,7 @@ playsound(src, 'sound/effects/explosionfar.ogg', 50, 0, 0) for(var/mob/M in range(10, src)) // Checks range if(!M.stat && !isAI(M)) // Checks to make sure whoever's getting shaken is alive/not the AI - sleep(2) // Short delay to match up with the explosion sound - shake_camera(M, 2, 1) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(shake_camera), M, 2, 1), 0.2 SECONDS) else to_chat(user, span_warning("Nothing happens.")) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index adb9d81978..b4ad3cc448 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -437,8 +437,14 @@ if(ticker < burst) addtimer(CALLBACK(src, PROC_REF(handle_gunfire),target, user, clickparams, pointblank, reflex, ++ticker, TRUE), burst_delay, TIMER_DELETE_ME) + return - + if(ticker == burst) + if(muzzle_flash) + if(gun_light) + addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, set_light),light_brightness), burst_delay, TIMER_DELETE_ME) + else + addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, set_light),0), burst_delay, TIMER_DELETE_ME) // Similar to the above proc, but does not require a user, which is ideal for things like turrets. /obj/item/gun/proc/Fire_userless(atom/target) @@ -594,8 +600,7 @@ to_chat(user, span_warning("You struggle to hold \the [src] steady!")) if(recoil) - spawn() - shake_camera(user, recoil+1, recoil) + shake_camera(user, recoil+1, recoil) update_icon() /obj/item/gun/proc/process_point_blank(obj/projectile, mob/user, atom/target) diff --git a/code/modules/projectiles/projectile/special.dm b/code/modules/projectiles/projectile/special.dm index 7168266b15..18a58c9f7a 100644 --- a/code/modules/projectiles/projectile/special.dm +++ b/code/modules/projectiles/projectile/special.dm @@ -109,7 +109,7 @@ /obj/item/projectile/meteor name = "meteor" icon = 'icons/obj/meteor.dmi' - icon_state = "smallf" + icon_state = "small" damage = 0 damage_type = BRUTE nodamage = 1 @@ -121,8 +121,6 @@ loc = A.loc return - sleep(-1) //Might not be important enough for a sleep(-1) but the sleep/spawn itself is necessary thanks to explosions and metoerhits - if(src)//Do not add to this if() statement, otherwise the meteor won't delete them if(A) diff --git a/code/modules/shuttles/crashes.dm b/code/modules/shuttles/crashes.dm index a71ab5e07e..b1186c126c 100644 --- a/code/modules/shuttles/crashes.dm +++ b/code/modules/shuttles/crashes.dm @@ -41,11 +41,14 @@ for(var/area/A in shuttle_area) for(var/mob/living/L in A) victims += L - spawn(0) - shake_camera(L,2 SECONDS,4) + shake_camera(L,2 SECONDS,4) //SHAKA SHAKA SHAKA - sleep(2 SECONDS) + addtimer(CALLBACK(src, PROC_REF(after_crash), victims, target), 2 SECONDS) + +/datum/shuttle/proc/after_crash(var/list/victims, var/obj/effect/shuttle_landmark/target) + PRIVATE_PROC(TRUE) + SHOULD_NOT_OVERRIDE(TRUE) // Move the shuttle if (!attempt_move(target)) diff --git a/code/modules/shuttles/shuttle.dm b/code/modules/shuttles/shuttle.dm index ad0a83dbfa..1494132ae6 100644 --- a/code/modules/shuttles/shuttle.dm +++ b/code/modules/shuttles/shuttle.dm @@ -330,22 +330,21 @@ TA.ChangeTurf(get_base_turf_by_area(TA), 1, 1) if(knockdown) for(var/mob/living/M in A) - spawn(0) - if(M.buckled) - to_chat(M, span_red("Sudden acceleration presses you into \the [M.buckled]!")) - shake_camera(M, 3, 1) - else - to_chat(M, span_red("The floor lurches beneath you!")) - shake_camera(M, 10, 1) - // TODO - tossing? - //M.visible_message(span_warning("[M.name] is tossed around by the sudden acceleration!")) - //M.throw_at_random(FALSE, 4, 1) - if(istype(M, /mob/living/carbon)) - M.Weaken(3) - //VOREStation Add - if(move_direction) - throw_a_mob(M,move_direction) - //VOREStation Add End + if(M.buckled) + to_chat(M, span_red("Sudden acceleration presses you into \the [M.buckled]!")) + shake_camera(M, 3, 1) + else + to_chat(M, span_red("The floor lurches beneath you!")) + shake_camera(M, 10, 1) + // TODO - tossing? + //M.visible_message(span_warning("[M.name] is tossed around by the sudden acceleration!")) + //M.throw_at_random(FALSE, 4, 1) + if(istype(M, /mob/living/carbon)) + M.Weaken(3) + //VOREStation Add + if(move_direction) + throw_a_mob(M,move_direction) + //VOREStation Add End // We only need to rebuild powernets for our cables. No need to check machines because they are on top of cables. for(var/obj/structure/cable/C in A) powernets |= C.powernet diff --git a/code/modules/tgui_input/say_modal/modal.dm b/code/modules/tgui_input/say_modal/modal.dm index c43554ac12..30f5805f46 100644 --- a/code/modules/tgui_input/say_modal/modal.dm +++ b/code/modules/tgui_input/say_modal/modal.dm @@ -64,14 +64,14 @@ /datum/tgui_say/proc/load() window_open = FALSE - var/minimumHeight = client?.prefs?.read_preference(/datum/preference/numeric/tgui_say_height) || 1 - var/minimumWidth = client?.prefs?.read_preference(/datum/preference/numeric/tgui_say_width) || 1 + var/minimum_height = client?.prefs?.read_preference(/datum/preference/numeric/tgui_say_height) || 1 + var/minimu_width = client?.prefs?.read_preference(/datum/preference/numeric/tgui_say_width) || 1 winset(client, "tgui_say", "pos=410,400;size=360,30;is-visible=0;") window.send_message("props", list( lightMode = client?.prefs?.read_preference(/datum/preference/toggle/tgui_say_light), - minimumHeight = minimumHeight, - minimumWidth = minimumWidth, + minimumHeight = minimum_height, + minimumWidth = minimu_width, maxLength = max_length, )) diff --git a/tgui/packages/common/storage.js b/tgui/packages/common/storage.js index fda143c97a..e8a7602cf3 100644 --- a/tgui/packages/common/storage.js +++ b/tgui/packages/common/storage.js @@ -61,7 +61,17 @@ class HubStorageBackend { class StorageProxy { constructor() { this.backendPromise = (async () => { - if (!Byond.TRIDENT && testHubStorage()) { + if (!Byond.TRIDENT) { + if (!testHubStorage()) { + return new Promise((resolve) => { + const listener = () => { + document.removeEventListener('byondstorageupdated', listener); + resolve(new HubStorageBackend()); + }; + + document.addEventListener('byondstorageupdated', listener); + }); + } return new HubStorageBackend(); } })(); diff --git a/tgui/packages/tgui-say/TguiSay.tsx b/tgui/packages/tgui-say/TguiSay.tsx index dd75fbf0e7..963f90270b 100644 --- a/tgui/packages/tgui-say/TguiSay.tsx +++ b/tgui/packages/tgui-say/TguiSay.tsx @@ -130,7 +130,7 @@ export function TguiSay() { const prefix = currentPrefix ?? ''; const grunt = iterator.isSay() ? prefix + value : value; - messages.current.forceSayMsg(grunt, iterator.current()); + messages.current.forceSayMsg(grunt); unloadChat(); } @@ -140,10 +140,26 @@ export function TguiSay() { iterator.next(); setButtonContent(iterator.current()); setCurrentPrefix(null); - messages.current.channelIncrementMsg(iterator.isVisible()); + messages.current.channelIncrementMsg( + iterator.isVisible(), + iterator.current(), + ); + } + + function handleDecrementChannel() { + const iterator = channelIterator.current; + + iterator.prev(); + setButtonContent(iterator.current()); + setCurrentPrefix(null); + messages.current.channelIncrementMsg( + iterator.isVisible(), + iterator.current(), + ); } function handleInput(event: FormEvent): void { + const iterator = channelIterator.current; let newValue = event.currentTarget.value; let newPrefix = getPrefix(newValue) || currentPrefix; @@ -160,7 +176,7 @@ export function TguiSay() { // Handles typing indicators if (channelIterator.current.isVisible() && newPrefix !== ',b ') { - messages.current.typingMsg(); + messages.current.typingMsg(iterator.current()); } setValue(newValue); @@ -236,6 +252,10 @@ export function TguiSay() { case KEY.Tab: event.preventDefault(); + if (event.shiftKey) { + handleDecrementChannel(); + break; + } handleIncrementChannel(); break; diff --git a/tgui/packages/tgui-say/helpers.ts b/tgui/packages/tgui-say/helpers.ts index 1e9b7b5100..89327ed05e 100644 --- a/tgui/packages/tgui-say/helpers.ts +++ b/tgui/packages/tgui-say/helpers.ts @@ -48,7 +48,7 @@ function setWindowVisibility(visible: boolean): void { }); } -const CHANNEL_REGEX = /^[:.]|,b\w\s/; +const CHANNEL_REGEX = /^[:.]\w|,b\s/; /** Tests for a channel prefix, returning it or none */ export function getPrefix( diff --git a/tgui/packages/tgui-say/timers.ts b/tgui/packages/tgui-say/timers.ts index 2c19e22409..ef279a3df8 100644 --- a/tgui/packages/tgui-say/timers.ts +++ b/tgui/packages/tgui-say/timers.ts @@ -8,15 +8,18 @@ const SECONDS = 1000; export const byondMessages = { // Debounce: Prevents spamming the server channelIncrementMsg: debounce( - (visible: boolean) => Byond.sendMessage('thinking', { visible }), + (visible: boolean, channel: Channel) => + Byond.sendMessage('thinking', { visible, channel }), 0.4 * SECONDS, ), forceSayMsg: debounce( - (entry: string, channel: Channel) => - Byond.sendMessage('force', { entry, channel }), + (entry: string) => Byond.sendMessage('force', { entry, channel: 'Say' }), 1 * SECONDS, true, ), // Throttle: Prevents spamming the server - typingMsg: throttle(() => Byond.sendMessage('typing'), 4 * SECONDS), + typingMsg: throttle( + (channel: string) => Byond.sendMessage('typing', { channel }), + 4 * SECONDS, + ), } as const; diff --git a/tgui/packages/tgui/backend.ts b/tgui/packages/tgui/backend.ts index 3ebabb6b90..87e45c4851 100644 --- a/tgui/packages/tgui/backend.ts +++ b/tgui/packages/tgui/backend.ts @@ -311,43 +311,6 @@ export const useBackend = () => { */ type StateWithSetter = [T, (nextState: T) => void]; -/** - * Allocates state on Redux store without sharing it with other clients. - * - * Use it when you want to have a stateful variable in your component - * that persists between renders, but will be forgotten after you close - * the UI. - * - * It is a lot more performant than `setSharedState`. - * - * @param context React context. - * @param key Key which uniquely identifies this state in Redux store. - * @param initialState Initializes your global variable with this value. - * @deprecated Use useState and useEffect when you can. Pass the state as a prop. - */ -export const useLocalState = ( - key: string, - initialState: T, -): StateWithSetter => { - const state = globalStore?.getState()?.backend; - const sharedStates = state?.shared ?? {}; - const sharedState = key in sharedStates ? sharedStates[key] : initialState; - return [ - sharedState, - (nextState) => { - globalStore.dispatch( - backendSetSharedState({ - key, - nextState: - typeof nextState === 'function' - ? nextState(sharedState) - : nextState, - }), - ); - }, - ]; -}; - /** * Allocates state on Redux store, and **shares** it with other clients * in the game.