diff --git a/libs/game-state/src/hotkeys.ts b/libs/game-state/src/hotkeys.ts index fe1c702..96e2ace 100644 --- a/libs/game-state/src/hotkeys.ts +++ b/libs/game-state/src/hotkeys.ts @@ -118,6 +118,7 @@ export function setupGlobalHotKeys(): void { export function setupCustomHotKeys(map: Record): void { for (const [key, value] of Object.entries(map)) { Mousetrap.bind(key, () => { + if (isPaused$.value) return; qspApi$.value?.execLoc(value); return false; }); diff --git a/libs/game-state/src/input.ts b/libs/game-state/src/input.ts index 3ce4ac1..c4ff363 100644 --- a/libs/game-state/src/input.ts +++ b/libs/game-state/src/input.ts @@ -1,4 +1,5 @@ import { create } from 'xoid'; +import { isPaused$ } from './counter'; interface InputAtom { isOpen: boolean; @@ -26,6 +27,7 @@ export const input$ = create( const entered$ = atom.focus((s) => s.entered); return { open(content: string, onfinished: (result: string) => void): void { + isPaused$.set(true); atom.set({ isOpen: true, content, @@ -39,17 +41,22 @@ export const input$ = create( finish(): void { if (isOpen$.value) { isOpen$.set(false); + isPaused$.set(false); atom.value.onfinished?.(entered$.value); } }, close(): void { if (isOpen$.value) { isOpen$.set(false); + isPaused$.set(false); atom.value.onfinished?.(''); } }, clear(): void { - if (isOpen$.value) atom.value.onfinished?.(''); + if (isOpen$.value) { + atom.value.onfinished?.(''); + isPaused$.set(false); + } atom.set({ isOpen: false, content: '', diff --git a/libs/game-state/src/msg.ts b/libs/game-state/src/msg.ts index 4371383..efeba15 100644 --- a/libs/game-state/src/msg.ts +++ b/libs/game-state/src/msg.ts @@ -1,4 +1,5 @@ import { create } from 'xoid'; +import { isPaused$ } from './counter'; interface MsgAtom { isOpen: boolean; @@ -21,6 +22,7 @@ export const msg$ = create( const isOpen$ = atom.focus((s) => s.isOpen); return { open(content: string, onclosed: () => void): void { + isPaused$.set(true); atom.set({ isOpen: true, content, @@ -29,12 +31,16 @@ export const msg$ = create( }, close(): void { if (isOpen$.value) { + isPaused$.set(false); isOpen$.set(false); atom.value.onclosed?.(); } }, clear(): void { - if (isOpen$.value) atom.value.onclosed?.(); + if (isOpen$.value) { + isPaused$.set(false); + atom.value.onclosed?.(); + } atom.set({ isOpen: false, content: '',