From 8a546af02970d2a14bd47311a39b7665f9224137 Mon Sep 17 00:00:00 2001 From: arudaev Date: Sun, 25 Oct 2026 09:19:03 +0100 Subject: [PATCH] feat(input): rebindable keys in Settings Playtest M5. Every action keeps its default keys until the player gives it one of their own in Settings -> Keys; that key is taken from any other action, saved in the browser, and Reset brings the defaults back. The hero, the chair and the coffee machine read the bound physical keys, and Phaser's named keys only back up an action still on its defaults. Refs #72 --- docs/02-GAME-DESIGN.md | 2 +- docs/meetings/playtest-24-oct.md | 2 +- game/src/combat/chair.ts | 14 +++--- game/src/combat/coffee.ts | 6 +-- game/src/player/bindings.test.ts | 53 +++++++++++++++++++++++ game/src/player/physicalKeys.ts | 74 +++++++++++++++++++++++++++++++- game/src/player/player.ts | 16 ++++--- game/src/style.css | 2 + game/src/ui/menu.ts | 59 +++++++++++++++++++++++-- 9 files changed, 205 insertions(+), 23 deletions(-) create mode 100644 game/src/player/bindings.test.ts diff --git a/docs/02-GAME-DESIGN.md b/docs/02-GAME-DESIGN.md index c32465b..ad5d811 100644 --- a/docs/02-GAME-DESIGN.md +++ b/docs/02-GAME-DESIGN.md @@ -46,7 +46,7 @@ The weapon is switched in the pocket computer menu (or ←/→ while the menu is A ☰ button in the top-right corner, Esc or the pad's Start open the **game menu** and pause the stage (`game/src/ui/menu.ts`, plain DOM over the canvas so it stays crisp and works with mouse, touch and keyboard). Four tabs: - **Controls** – the table above, for keyboard and gamepad. -- **Settings** – sound on/off and volume, zoom (the game's own view or 133 / 200 / 286 % wider), full screen. +- **Settings** – sound on/off and volume, zoom (the game's own view or 133 / 200 / 286 % wider), full screen, and **Keys**. In Keys, click an action and press its new key (Esc keeps the old one). The key then belongs to that action alone and is taken from any other. The choice is saved in the browser, and "Reset to the defaults" brings back both laptop layouts. Esc, Tab and the debug keys stay the game's (`player/physicalKeys.ts` `Bindings`). - **Debug** – debug mode and its switches (`game/src/core/debug.ts`); the corner line names every switch that is on, so a playtest screenshot records what was showing: - **Layers**: every stage layer by id and z, switched off in all chunks at once; with the **purple backdrop** any hole or seam in a plate behind it shows at once (the hot-dog rule, docs/09). - **Collision**: walk lines, one-way beams, ladders, walls, water, hazards, triggers (the F2 legend). diff --git a/docs/meetings/playtest-24-oct.md b/docs/meetings/playtest-24-oct.md index 1666567..695474a 100644 --- a/docs/meetings/playtest-24-oct.md +++ b/docs/meetings/playtest-24-oct.md @@ -38,7 +38,7 @@ Vatsal and Lex played the live slice on 24 Oct and recorded what to fix ([A15](t | M2 | Ladder: alternate the arms by flipping the climb sprite each rung (no new art) | 🔧 | | M3 | WASD did not move the hero (A16) | 🔧 the code reads A/D/W/S – checking keyboard layouts | | M4 | Attack only on J is awkward for arrow-key players: add a second bind (Z/X), or move it | 🔧 second bind X | -| M5 | Rebindable keys in Settings (nice to have) | ⏭ listed under Coming soon | +| M5 | Rebindable keys in Settings (nice to have) | ✅ Settings → Keys: one key of your own per action, saved in the browser; the Controls tab lists your keys | ## Menu and debug (A17 and Alexander) diff --git a/game/src/combat/chair.ts b/game/src/combat/chair.ts index e81388e..693cbac 100644 --- a/game/src/combat/chair.ts +++ b/game/src/combat/chair.ts @@ -11,7 +11,7 @@ import { lowStreak, swingArc } from './swingFx'; import { LOW_CONTACT, LowSweep } from './lowSweep'; import { pickAssist } from './assist'; import { UP_CONTACT } from './overhead'; -import { CODES, physicalKeys } from '../player/physicalKeys'; +import { bindings, CODES, physicalKeys } from '../player/physicalKeys'; const ROVER_HEIGHT = 25; // docs/05 and approved enemy-rover:idle-00 alpha height. const ROVER_WIDTH = 31; // Approved enemy-rover:idle-00 alpha width; compare.py measures 31×25. @@ -161,14 +161,16 @@ export class ChairCombat { this.guard.step(milliseconds / 1000); if (this.guard.phase !== 'break') this.guard.direction = this.player.facing; const pad = this.scene.input.gamepad?.getAll().find(p => p.connected); - const down = this.key.isDown || this.altKey.isDown || this.physical.any(CODES.attack) || !!pad?.X || this.mouse.down; + // J and X (Phaser's keys) count only while attack has its default keys; a rebound attack is its own key alone. + const named = bindings.isDefault('attack'); + const down = named && (this.key.isDown || this.altKey.isDown) || this.physical.any(CODES.attack) || !!pad?.X || this.mouse.down; // Both edge checks run every frame so neither key keeps a stale Just-flag. - const justUp = [this.key, this.altKey].map(k => Phaser.Input.Keyboard.JustUp(k)).some(Boolean) || this.mouse.released; - const justDown = [this.key, this.altKey].map(k => Phaser.Input.Keyboard.JustDown(k)).some(Boolean) || this.mouse.pressed; + const justUp = [this.key, this.altKey].map(k => Phaser.Input.Keyboard.JustUp(k)).some(Boolean) && named || this.mouse.released; + const justDown = [this.key, this.altKey].map(k => Phaser.Input.Keyboard.JustDown(k)).some(Boolean) && named || this.mouse.pressed; this.mouse.pressed = false; this.mouse.released = false; const { pressed, released } = actionEdges(down, this.wasDown, justDown, justUp); - const up = this.directions.W.isDown || this.directions.UP.isDown || this.physical.any(CODES.up) || !!pad?.up || (pad?.leftStick.y ?? 0) < -0.2; - const below = this.directions.S.isDown || this.directions.DOWN.isDown || this.physical.any(CODES.down) || !!pad?.down || (pad?.leftStick.y ?? 0) > 0.2; + const up = bindings.isDefault('up') && (this.directions.W.isDown || this.directions.UP.isDown) || this.physical.any(CODES.up) || !!pad?.up || (pad?.leftStick.y ?? 0) < -0.2; + const below = bindings.isDefault('down') && (this.directions.S.isDown || this.directions.DOWN.isDown) || this.physical.any(CODES.down) || !!pad?.down || (pad?.leftStick.y ?? 0) > 0.2; this.buffer.step(milliseconds / 1000); if (this.enabled && pressed && this.player.dodge.active) { // Pressed during a dodge-dash: struck as the dash ends. diff --git a/game/src/combat/coffee.ts b/game/src/combat/coffee.ts index 02bcb4c..724c0ae 100644 --- a/game/src/combat/coffee.ts +++ b/game/src/combat/coffee.ts @@ -2,7 +2,7 @@ import type Phaser from 'phaser'; import type { Box, CollisionChunk } from '../stage/collision'; import { overlaps, type Body } from '../player/body'; import type { Player } from '../player/player'; -import { CODES, physicalKeys } from '../player/physicalKeys'; +import { bindings, CODES, physicalKeys } from '../player/physicalKeys'; /** * The approved machine's idle clip (coffee-machine.anims.json: steady, flicker, the pond on the screen). It glows @@ -56,8 +56,8 @@ export class CoffeePoints { } update() { const pad = this.scene.input.gamepad?.getAll().find(p => p.connected); - const up = this.keys.W.isDown || this.keys.UP.isDown || this.physical.any(CODES.up) || !!pad?.up || (pad?.leftStick.y ?? 0) < -0.2; - const attacking = this.keys.J.isDown || this.keys.X.isDown || this.physical.any(CODES.attack) || !!pad?.X; + const up = bindings.isDefault('up') && (this.keys.W.isDown || this.keys.UP.isDown) || this.physical.any(CODES.up) || !!pad?.up || (pad?.leftStick.y ?? 0) < -0.2; + const attacking = bindings.isDefault('attack') && (this.keys.J.isDown || this.keys.X.isDown) || this.physical.any(CODES.attack) || !!pad?.X; const machine = this.use.step(up, this.player.body, this.player.canAttack && !attacking, this.machines); if (machine && this.player.beginInteraction()) this.player.saveCheckpoint(machine.id!); const frame = `idle-0${coffeeFrame(this.scene.time.now, this.fps)}`; diff --git a/game/src/player/bindings.test.ts b/game/src/player/bindings.test.ts new file mode 100644 index 0000000..576c126 --- /dev/null +++ b/game/src/player/bindings.test.ts @@ -0,0 +1,53 @@ +import { describe, expect, it } from 'vitest'; +import { BINDINGS_KEY, Bindings, DEFAULT_CODES, keyName } from './physicalKeys'; + +function memory(initial: Record = {}) { + const data = { ...initial }; + return { data, getItem: (k: string) => data[k] ?? null, setItem: (k: string, v: string) => { data[k] = v; }, + removeItem: (k: string) => { delete data[k]; } }; +} + +describe('rebindable keys', () => { + it('starts with the defaults', () => { + const b = new Bindings(memory()); + expect(b.codes('attack')).toEqual(DEFAULT_CODES.attack); + expect(b.isDefault('jump')).toBe(true); + }); + + it('gives an action one key of the player\'s own, saved, and takes that key from the others', () => { + const store = memory(); + const b = new Bindings(store); + expect(b.set('attack', 'KeyK')).toBe(true); // K was a jump key + expect(b.codes('attack')).toEqual(['KeyK']); + expect(b.codes('jump')).toEqual(['Space', 'KeyZ']); + expect(JSON.parse(store.data[BINDINGS_KEY])).toEqual({ attack: ['KeyK'] }); + expect(new Bindings(store).codes('attack')).toEqual(['KeyK']); // back after a reload + b.set('jump', 'KeyK'); // and it can be taken back + expect(b.codes('attack')).toEqual([]); + expect(b.codes('jump')).toEqual(['KeyK']); + }); + + it('keeps Esc, Tab and the debug keys for the game, and resets to the defaults', () => { + const store = memory(); + const b = new Bindings(store); + expect(b.set('dodge', 'Escape')).toBe(false); + expect(b.set('dodge', 'Tab')).toBe(false); + b.set('dodge', 'KeyQ'); + b.reset(); + expect(b.codes('dodge')).toEqual(DEFAULT_CODES.dodge); + expect(store.data[BINDINGS_KEY]).toBeUndefined(); + }); + + it('ignores broken saved data and blocked storage', () => { + expect(new Bindings(memory({ [BINDINGS_KEY]: '{oops' })).codes('left')).toEqual(DEFAULT_CODES.left); + expect(new Bindings(memory({ [BINDINGS_KEY]: '{"left": 5}' })).codes('left')).toEqual(DEFAULT_CODES.left); + const blocked = { getItem: () => { throw new Error('blocked'); }, setItem: () => { throw new Error('blocked'); }, removeItem: () => undefined }; + const b = new Bindings(blocked); + expect(b.set('left', 'KeyQ')).toBe(true); + expect(b.codes('left')).toEqual(['KeyQ']); + }); + + it('names keys for people', () => { + expect(['KeyA', 'ArrowLeft', 'ShiftLeft', 'Digit1', 'Space'].map(keyName)).toEqual(['A', '←', 'Shift', '1', 'Space']); + }); +}); diff --git a/game/src/player/physicalKeys.ts b/game/src/player/physicalKeys.ts index 52982c4..d2d9272 100644 --- a/game/src/player/physicalKeys.ts +++ b/game/src/player/physicalKeys.ts @@ -6,7 +6,7 @@ import type Phaser from 'phaser'; * keyboard layout and is 229 for every letter while an input method (IME) is active, so Phaser never saw W/A/S/D; * `code` is the key's place on the board ('KeyW' is the key left of E on any layout), so it always works. */ -export const CODES = { +export const DEFAULT_CODES = { left: ['KeyA', 'ArrowLeft'], right: ['KeyD', 'ArrowRight'], up: ['KeyW', 'ArrowUp'], down: ['KeyS', 'ArrowDown'], /** * The two laptop layouts (playtest 24 Oct): WASD with J attack / K jump / L dodge, or the arrows with @@ -19,6 +19,78 @@ export const CODES = { dodge: ['KeyL', 'KeyC', 'ShiftLeft', 'ShiftRight'], } as const; +export type Action = keyof typeof DEFAULT_CODES; +export const ACTIONS = Object.keys(DEFAULT_CODES) as Action[]; +/** Where the player's own keys are kept (per browser; the game has no accounts). */ +export const BINDINGS_KEY = 'deggster.keys'; +/** Keys the game keeps for itself: the menu, the map, the debug keys. */ +const RESERVED = new Set(['Escape', 'Tab', 'F2', 'F3', 'F4', 'F5', 'F8', 'F9', 'F10']); + +interface Store { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void } + +/** + * The keys of every action (playtest M5, rebindable keys in Settings). Each action starts with its defaults; the + * player can give it one key of their own instead. A key belongs to one action: binding it takes it from any other. + * Saved in the browser (a broken or blocked storage just means the defaults). + */ +export class Bindings { + private own: Partial> = {}; + constructor(private store?: Store) { + try { + const saved = JSON.parse(store?.getItem(BINDINGS_KEY) ?? '{}') as Record; + for (const action of ACTIONS) { + const codes = saved[action]; + if (Array.isArray(codes) && codes.every(c => typeof c === 'string')) this.own[action] = codes; + } + } catch { this.own = {}; } + } + codes(action: Action): readonly string[] { + return this.own[action] ?? DEFAULT_CODES[action].filter(code => !this.takenByOwn(code, action)); + } + isDefault(action: Action): boolean { return !this.own[action]; } + /** Give the action this key alone; false for a key the game keeps (Esc, Tab, the debug keys). */ + set(action: Action, code: string): boolean { + if (!code || RESERVED.has(code)) return false; + for (const other of ACTIONS) { + if (other !== action && this.own[other]) this.own[other] = this.own[other]!.filter(c => c !== code); + } + this.own[action] = [code]; + this.save(); + return true; + } + reset(): void { this.own = {}; this.save(); } + /** A key the player gave to another action is no longer one of this action's defaults. */ + private takenByOwn(code: string, action: Action): boolean { + return ACTIONS.some(other => other !== action && this.own[other]?.includes(code)); + } + private save(): void { + try { + if (Object.keys(this.own).length) this.store?.setItem(BINDINGS_KEY, JSON.stringify(this.own)); + else this.store?.removeItem(BINDINGS_KEY); + } catch { /* blocked storage: the keys last until the page closes */ } + } +} + +function browserStore(): Store | undefined { + try { return typeof localStorage === 'undefined' ? undefined : localStorage; } catch { return undefined; } +} + +/** The game's bindings (Settings → Keys changes them). */ +export const bindings = new Bindings(browserStore()); + +/** The keys of every action, as bound right now. */ +export const CODES: { readonly [A in Action]: readonly string[] } = Object.defineProperties({}, Object.fromEntries( + ACTIONS.map(action => [action, { get: () => bindings.codes(action), enumerable: true }]))) as never; + +/** A key's name for people: KeyA → A, ArrowLeft → ←, ShiftLeft → Shift, Digit1 → 1. */ +export function keyName(code: string): string { + const arrows: Record = { ArrowLeft: '←', ArrowRight: '→', ArrowUp: '↑', ArrowDown: '↓' }; + if (arrows[code]) return arrows[code]; + const m = /^(?:Key|Digit|Numpad)(.+)$/.exec(code); + if (m) return m[1]; + return code.replace(/(Left|Right)$/, '').replace(/^Bracket/, '').replace(/^Semicolon$/, ';') || code; +} + /** Pure key state, so it is tested without a browser. */ export class KeyState { private down = new Set(); diff --git a/game/src/player/player.ts b/game/src/player/player.ts index da22a50..41f5ebc 100644 --- a/game/src/player/player.ts +++ b/game/src/player/player.ts @@ -21,7 +21,7 @@ import { parseAtmosphere, type Wind } from '../stage/atmosphere/config'; import { ACTOR_RIM, addRim } from '../stage/atmosphere/pipeline'; import { dataKey } from '../boot/manifest'; import { GuardPush } from '../combat/guard'; -import { CODES, physicalKeys } from './physicalKeys'; +import { bindings, CODES, physicalKeys, type Action } from './physicalKeys'; import { Dodge } from './dodge'; import { Lunge } from '../combat/assist'; @@ -197,14 +197,16 @@ export class Player { const pad = this.scene.input.gamepad?.getAll().find(p => p.connected); const interacting = this.interaction.active; const interactionPose = this.interaction.step(milliseconds / 1000); - // Phaser's keys (keyCode) or the physical key (code): WASD works on any layout and with an input method active. - const key = (codes: readonly string[], ...names: string[]) => names.some(name => this.keys[name].isDown) || this.physical.any(codes); - const axis = interacting ? 0 : horizontal(key(CODES.left, 'A', 'LEFT'), key(CODES.right, 'D', 'RIGHT'), + // The physical key (code): WASD works on any layout and with an input method active. Phaser's keys (keyCode) + // only back up an action that still has its default keys – a rebound action answers to its own key alone. + const key = (action: Action, ...names: string[]) => + this.physical.any(CODES[action]) || bindings.isDefault(action) && names.some(name => this.keys[name].isDown); + const axis = interacting ? 0 : horizontal(key('left', 'A', 'LEFT'), key('right', 'D', 'RIGHT'), pad?.leftStick.x, pad?.left, pad?.right); - const jumpDown = !interacting && (key(CODES.jump, 'SPACE', 'K', 'Z') || !!pad?.A); - const vertical = interacting || key(CODES.attack, 'J', 'X') || pad?.X ? 0 : horizontal(key(CODES.up, 'W', 'UP'), key(CODES.down, 'S', 'DOWN'), + const jumpDown = !interacting && (key('jump', 'SPACE', 'K', 'Z') || !!pad?.A); + const vertical = interacting || key('attack', 'J', 'X') || pad?.X ? 0 : horizontal(key('up', 'W', 'UP'), key('down', 'S', 'DOWN'), pad?.leftStick.y, pad?.up, pad?.down); - const dodgeDown = !interacting && (key(CODES.dodge, 'L', 'C', 'SHIFT') || !!pad?.B || !!pad?.R1); + const dodgeDown = !interacting && (key('dodge', 'L', 'C', 'SHIFT') || !!pad?.B || !!pad?.R1); let dodgePressed = dodgeDown && !this.dodgeWas; this.dodgeWas = dodgeDown; const geometry = this.chunks.map(c => c.world); diff --git a/game/src/style.css b/game/src/style.css index 1caac04..e5d62e9 100644 --- a/game/src/style.css +++ b/game/src/style.css @@ -31,3 +31,5 @@ canvas { display: block; image-rendering: pixelated; } .wm-note { color: #9fb7b3; margin: 0; } .wm-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; } @media (max-width: 520px) { .wm-field { grid-template-columns: 1fr; gap: 4px; } } +.wm-keys { display: grid; gap: 6px; } +.wm-keys .wm-key-label { display: inline-block; min-width: 13em; } diff --git a/game/src/ui/menu.ts b/game/src/ui/menu.ts index 55ef238..70da42e 100644 --- a/game/src/ui/menu.ts +++ b/game/src/ui/menu.ts @@ -1,11 +1,12 @@ import { debugStore, ZOOMS } from '../core/debug'; import { LEVELS, nextSpot, type Spot } from '../stage/teleports'; import type { RegionTarget } from '../stage/swap'; +import { ACTIONS, bindings, CODES, keyName, type Action } from '../player/physicalKeys'; import { download, falls } from '../stage/fallCapture'; /** * The game menu (docs/02 "Menu and debug mode"): a small ☰ button in the corner, Esc or the pad's Start. It pauses - * the stage and has four tabs – Controls (keyboard and gamepad), Settings (sound, zoom, full screen), Debug (the + * the stage and has four tabs – Controls (keyboard and gamepad), Settings (sound, zoom, full screen, keys), Debug (the * switches in core/debug.ts and every stage layer) and Coming soon. Plain DOM over the canvas: crisp at any scale, * mouse, touch and keyboard all work. The stage tells it what it has (`MenuHost`); the menu never reaches into * the scenes itself. @@ -46,9 +47,18 @@ export const COMING = [ 'The poncho glide after Rusty Creek – updrafts off the water, gaps only a glide crosses', 'More crabs and drones in the maze', 'Lost in the Green, the Mensa, the Toxic Garden and the Playground', - 'Touch controls and rebindable keys', + 'Touch controls', ]; +/** The actions Settings → Keys can rebind, as the player reads them. */ +export const KEY_LABELS: Record = { + left: 'Walk left', right: 'Walk right', up: 'Interact, climb up', down: 'Drop through, climb down', + jump: 'Jump', attack: 'Attack / guard', dodge: 'Dodge-dash', +}; + +/** An action's keys for the menu: "A, ←", or "none" when the player gave all of them away. */ +export const keysText = (codes: readonly string[]) => codes.length ? [...new Set(codes.map(keyName))].join(', ') : 'none'; + type Tab = 'controls' | 'settings' | 'debug' | 'coming'; const TABS: [Tab, string][] = [['controls', 'Controls'], ['settings', 'Settings'], ['debug', 'Debug'], ['coming', 'Coming soon']]; @@ -60,6 +70,9 @@ export class GameMenu { private tab: Tab = 'controls'; private open = false; private offStore: () => void; + /** The action waiting for its new key in Settings → Keys. */ + private listening?: Action; + private stopListening?: () => void; constructor(parent: HTMLElement, private host: MenuHost) { this.button = el('button', 'wm-open', '☰') as HTMLButtonElement; @@ -104,6 +117,7 @@ export class GameMenu { toggle(open = !this.open) { if (open === this.open) return; this.open = open; + if (!open) this.stopListening?.(); this.root.hidden = !open; this.host.pause(open); if (open) { this.render(); (this.panel.querySelector('.wm-tab[aria-selected="true"]') as HTMLElement | null)?.focus(); } @@ -125,7 +139,9 @@ export class GameMenu { row.append(el('td', '', action), el('td', 'wm-key', keys), el('td', 'wm-key', pad)); table.append(row); } - return [table, el('p', 'wm-note', 'Two laptop layouts: WASD with J attack, K jump, L dodge – or the arrows with Z jump, X attack, C dodge. Touch controls are coming.')]; + const own = ACTIONS.filter(a => !bindings.isDefault(a)).map(a => `${KEY_LABELS[a]}: ${keysText(CODES[a])}`); + return [table, el('p', 'wm-note', 'Two laptop layouts: WASD with J attack, K jump, L dodge – or the arrows with Z jump, X attack, C dodge. Change any of them in Settings → Keys.'), + ...own.length ? [el('p', 'wm-note', `Your own keys – ${own.join(' · ')}.`)] : []]; } private settings(): HTMLElement[] { @@ -148,9 +164,44 @@ export class GameMenu { field('Volume', volume), field('Zoom', zoom), field('Screen', full), + field('Keys', this.keys()), ]; } + /** Settings → Keys (playtest M5): click an action, press its new key (Esc keeps the old one). */ + private keys(): HTMLElement { + const list = el('div', 'wm-keys'); + for (const action of ACTIONS) { + const waiting = this.listening === action; + const b = el('button', 'wm-chip', waiting ? 'Press a key… (Esc: keep)' : keysText(CODES[action])) as HTMLButtonElement; + b.setAttribute('aria-pressed', String(waiting)); + b.title = `Change the key for ${KEY_LABELS[action].toLowerCase()}`; + b.onclick = () => this.listen(action); + list.append(row(el('span', 'wm-key-label', KEY_LABELS[action]), b)); + } + const reset = el('button', 'wm-chip', 'Reset to the defaults') as HTMLButtonElement; + reset.disabled = ACTIONS.every(a => bindings.isDefault(a)); + reset.onclick = () => { this.stopListening?.(); bindings.reset(); this.render(); }; + list.append(reset); + return list; + } + + /** The next key pressed goes to the action – caught before the game and the menu's own Esc see it. */ + private listen(action: Action) { + this.stopListening?.(); + this.listening = action; + const onKey = (event: KeyboardEvent) => { + event.preventDefault(); + event.stopPropagation(); + if (event.code !== 'Escape') bindings.set(action, event.code); + this.stopListening?.(); + this.render(); + }; + window.addEventListener('keydown', onKey, true); + this.stopListening = () => { window.removeEventListener('keydown', onKey, true); this.listening = undefined; this.stopListening = undefined; }; + this.render(); + } + private debug(): HTMLElement[] { const s = debugStore.state; const out: HTMLElement[] = [ @@ -208,7 +259,7 @@ export class GameMenu { return [list]; } - destroy() { this.offStore(); this.button.remove(); this.root.remove(); } + destroy() { this.stopListening?.(); this.offStore(); this.button.remove(); this.root.remove(); } } function el(tag: string, className = '', text?: string): HTMLElement {