Fix: in-game mute button now mutes background music too

HUD mute is a master toggle (sound effects + music) via sound-store.toggleAll;
icon reflects fully-muted state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 12:46:51 +03:30
parent aaf66b921f
commit 0a3ffa6314
2 changed files with 17 additions and 6 deletions
+9
View File
@@ -8,6 +8,8 @@ interface SoundStore {
music: boolean;
toggleSfx: () => void;
toggleMusic: () => void;
/** Master mute: turns BOTH sfx and music off (or both back on). */
toggleAll: () => void;
}
export const useSoundStore = create<SoundStore>((set, get) => ({
@@ -23,4 +25,11 @@ export const useSoundStore = create<SoundStore>((set, get) => ({
sound.setMusicEnabled(v);
set({ music: v });
},
toggleAll: () => {
// If anything is on, mute everything; otherwise turn everything back on.
const v = !(get().sfx || get().music);
sound.setSfxEnabled(v);
sound.setMusicEnabled(v);
set({ sfx: v, music: v });
},
}));