diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp index e3d137a3a3d..3ab2caabc40 100644 --- a/engines/sherlock/sherlock.cpp +++ b/engines/sherlock/sherlock.cpp @@ -94,6 +94,9 @@ void SherlockEngine::initialize() { _sound = new Sound(this); _talk = new Talk(this); _ui = new UserInterface(this); + + // Load game settings + loadConfig(); } /** @@ -202,11 +205,48 @@ void SherlockEngine::setFlags(int flagNum) { _scene->checkSceneFlags(true); } +/** + * Load game configuration esttings + */ +void SherlockEngine::loadConfig() { + // Load sound settings + syncSoundSettings(); + + // Load other settings + if (ConfMan.hasKey("font")) + _screen->setFont(ConfMan.getInt("font")); + if (ConfMan.hasKey("help_style")) + _ui->_helpStyle = ConfMan.getInt("help_style"); + if (ConfMan.hasKey("window_style")) + _ui->_windowStyle = ConfMan.getInt("window_style"); + if (ConfMan.hasKey("portraits_on")) + _people->_portraitsOn = ConfMan.getBool("portraits_on"); +} + /** * Saves game configuration information */ void SherlockEngine::saveConfig() { - // TODO + ConfMan.setBool("mute", _sound->_digitized); + ConfMan.setBool("music_mute", _sound->_music); + ConfMan.setBool("speech_mute", _sound->_voices); + + ConfMan.setInt("font", _screen->fontNumber()); + ConfMan.setInt("help_style", _ui->_helpStyle); + ConfMan.setInt("window_style", _ui->_windowStyle); + ConfMan.setBool("portraits_on", _people->_portraitsOn); + + ConfMan.flushToDisk(); +} + +/** + * Called by the engine when sound settings are updated + */ +void SherlockEngine::syncSoundSettings() { + Engine::syncSoundSettings(); + + // Load sound-related settings + _sound->syncSoundSettings(); } /** diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h index 3f0779421ce..02e2e992299 100644 --- a/engines/sherlock/sherlock.h +++ b/engines/sherlock/sherlock.h @@ -74,6 +74,8 @@ private: void sceneLoop(); void handleInput(); + + void loadConfig(); protected: virtual void initialize(); @@ -117,6 +119,7 @@ public: virtual bool canSaveGameStateCurrently(); virtual Common::Error loadGameState(int slot); virtual Common::Error saveGameState(int slot, const Common::String &desc); + virtual void syncSoundSettings(); int getGameType() const; uint32 getGameID() const; diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp index a452efd8903..e66f82e5c43 100644 --- a/engines/sherlock/sound.cpp +++ b/engines/sherlock/sound.cpp @@ -21,20 +21,34 @@ */ #include "sherlock/sound.h" +#include "common/config-manager.h" namespace Sherlock { Sound::Sound(SherlockEngine *vm): _vm(vm) { + _digitized = false; + _music = false; + _voices = 0; _soundOn = false; _musicOn = false; _speechOn = false; - _voices = 0; _playingEpilogue = false; - _music = false; - _digitized = false; _diskSoundPlaying = false; _soundIsOn = nullptr; - _digiBuf = nullptr; +} + +/** + * Saves sound-related settings + */ +void Sound::syncSoundSettings() { + _digitized = !ConfMan.getBool("mute"); + _music = !ConfMan.getBool("mute") && !ConfMan.getBool("music_mute"); + _voices = !ConfMan.getBool("mute") && !ConfMan.getBool("speech_mute") ? 1 : 0; + + // TODO: For now, keep sound completely mute until sound is implemented + _digitized = false; + _music = false; + _voices = 0; } void Sound::loadSound(const Common::String &name, int priority) { diff --git a/engines/sherlock/sound.h b/engines/sherlock/sound.h index c85af2ac2af..3bd3a99f074 100644 --- a/engines/sherlock/sound.h +++ b/engines/sherlock/sound.h @@ -38,19 +38,20 @@ class Sound { private: SherlockEngine *_vm; public: + bool _digitized; + bool _music; + int _voices; bool _soundOn; bool _musicOn; bool _speechOn; - int _voices; bool _playingEpilogue; - bool _music; - bool _digitized; bool _diskSoundPlaying; byte *_soundIsOn; byte *_digiBuf; public: Sound(SherlockEngine *vm); + void syncSoundSettings(); void loadSound(const Common::String &name, int priority); bool playSound(const Common::String &name, WaitType waitType = WAIT_RETURN_IMMEDIATELY); void cacheSound(const Common::String &name, int index); diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 99612b218b4..ac2c16d7c22 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -85,7 +85,6 @@ private: int _bgFound; int _oldBgFound; int _keycode; - int _helpStyle; int _lookHelp; int _help, _oldHelp; int _key, _oldKey; @@ -137,6 +136,7 @@ public: int _invLookFlag; int _temp1; int _windowStyle; + int _helpStyle; public: UserInterface(SherlockEngine *vm); ~UserInterface();