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:
@@ -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 });
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user