Files
faceclaw/app/ui/sound-setting.ts
James Babcock c9e95a3f69 Refinements to bulitin games
All: settings persistence
All: pause on menu
Flappy: both swipe directions trigger flaps
Freecell: skip irrelevant locations
Blocks: Lower speed/difficulty
Pinball: remove the half-implemented Nudge gesture.
2026-09-12 23:50:23 -07:00

27 lines
773 B
TypeScript

/**
* The "Sound: on/off" entry in a game's context menu, persisted per app under
* `<appId>.soundOn` so each game remembers its own choice across launches.
* Reads default to on; storage failures fall back to on and never throw.
*/
import { getBooleanSetting, setBooleanSetting } from "../native/settings-store";
function soundKey(appId: string): string {
return `${appId}.soundOn`;
}
export function loadSoundEnabled(appId: string): boolean {
try {
return getBooleanSetting(soundKey(appId), true);
} catch {
return true;
}
}
export function saveSoundEnabled(appId: string, enabled: boolean): void {
try {
setBooleanSetting(soundKey(appId), enabled);
} catch (error) {
console.warn(`${appId} sound setting save failed: ${error}`);
}
}