diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 5027792581b..0e0d62d1ae2 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -25,6 +25,7 @@ #include "kyra/script.h" #include "kyra/text.h" #include "kyra/animator.h" +#include "kyra/sound.h" #include "common/config-manager.h" #include "common/savefile.h" @@ -56,6 +57,9 @@ void KyraEngine::readSettings() { _configMusic = ConfMan.getBool("music_mute") ? 0 : 1; _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + bool speechMute = ConfMan.getBool("speech_mute"); bool subtitles = ConfMan.getBool("subtitles"); @@ -108,6 +112,12 @@ void KyraEngine::writeSettings() { break; } + if (!_configMusic) + _sound->beginFadeOut(); + + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + ConfMan.setBool("speech_mute", speechMute); ConfMan.setBool("subtitles", subtitles); diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 02208f9f5d0..a96c46604b9 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -36,7 +36,8 @@ namespace Kyra { Sound::Sound(KyraEngine *engine, Audio::Mixer *mixer) - : _engine(engine), _mixer(mixer), _currentVocFile(0), _vocHandle(), _compressHandle() { + : _engine(engine), _mixer(mixer), _currentVocFile(0), _vocHandle(), _compressHandle(), + _musicEnabled(true), _sfxEnabled(false) { } Sound::~Sound() { @@ -363,7 +364,7 @@ void SoundMidiPC::onTimer(void *refCon) { } void SoundMidiPC::playTrack(uint8 track) { - if (_parser && (track != 0 || _nativeMT32)) { + if (_parser && (track != 0 || _nativeMT32) && _musicEnabled) { _isPlaying = true; _fadeMusicOut = false; _fadeStartTime = 0; @@ -387,7 +388,7 @@ void SoundMidiPC::haltTrack() { } void SoundMidiPC::playSoundEffect(uint8 track) { - if (_soundEffect) { + if (_soundEffect && _sfxEnabled) { _sfxIsPlaying = true; _soundEffect->setTrack(track); _soundEffect->jumpToTick(0); diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 3252bee6d8e..a7de8513496 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -61,12 +61,20 @@ public: virtual void beginFadeOut() = 0; + void enableMusic(bool enable) { _musicEnabled = enable; } + bool musicEnabled() const { return _musicEnabled; } + void enableSFX(bool enable) { _sfxEnabled = enable; } + bool sfxEnabled() const { return _sfxEnabled; } + void voicePlay(const char *file); void voiceUnload() {} bool voiceIsPlaying(); void voiceStop(); protected: + bool _musicEnabled; + bool _sfxEnabled; + KyraEngine *_engine; Audio::Mixer *_mixer; @@ -105,6 +113,8 @@ public: void beginFadeOut(); private: + void play(uint8 track); + void loadSoundFile(const char *file); void unk1(); diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 79eb187dc5b..9680fe47015 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -2196,7 +2196,8 @@ void SoundAdlibPC::loadMusicFile(const char *file) { } void SoundAdlibPC::playTrack(uint8 track) { - playSoundEffect(track); + if (_musicEnabled) + play(track); } void SoundAdlibPC::haltTrack() { @@ -2206,6 +2207,11 @@ void SoundAdlibPC::haltTrack() { } void SoundAdlibPC::playSoundEffect(uint8 track) { + if (_sfxEnabled) + play(track); +} + +void SoundAdlibPC::play(uint8 track) { uint8 soundId = _trackEntries[track]; if ((int8)soundId == -1 || !_soundDataPtr) return;