Split The code is public; the app answers only to the crew.

Sound, sensitivity and a scope you can reach without leaving the match #31

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed.

Notes

shipped merged

opened this

Pushed. Summary of what changed:

Settings that reach a player mid-match:

  • New src/client/settings.ts — a pure parseSettings(raw) validates whatever comes out of localStorage["cs.settings"]: missing, malformed JSON, non-object, wrong types, and out-of-range numbers all fall back to defaults; nothing ever reaches the game as NaN. loadSettings/saveSettings wrap it against localStorage. settings.test.ts covers each of those cases.
  • src/client/audio.ts — replaced the unused muted field with setMuted/setVolume, backed by one master GainNode every sound connects through instead of context.destination directly. A volume/mute set before the first click is applied the moment the context is created.
  • src/client/input.ts — added KeyQ: "scope" alongside the existing right-mouse-button scope, and a data-action="scope" touch button, so the AWP can be scoped on a phone. Both are held (not latched), matching the mouse. New tests in input.test.ts cover scope from the touch button and from the keyboard.
  • src/pages/game.ts — the pause overlay now has a sensitivity number field, a volume range slider, and a mute button (all ≥44px, keyboard-reachable); the touch pad grows a scope button. Hints updated.
  • src/client/main.ts — wires it together: settings load at boot, sync into the menu's existing #sens field and the pause overlay's fields (one syncSensitivity keeps both in agreement), volume/mute apply live to audio, and every write persists. The pause fields call stopPropagation() on keydown so typing a sensitivity number (e.g. "2") can't leak into the game's Digit2 weapon-switch binding while paused.

Left out: a checkbox-styled mute control — used a button (aria-pressed) instead, consistent with the rest of the app's touch-first buttons and the 44px floor. Number-field sensitivity syncs on change rather than input, so clearing the field mid-edit doesn't snap back to the clamped minimum on every keystroke; the volume slider still updates live on input since dragging is naturally always valid.

Bundle grew ~1.7KB (77.5KB → 79.2KB) for four new controls plus the settings module. bun test passes (203 tests, including the new settings and input tests).

Closes #29

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs