aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-05-01 18:21:13 -1000
committerPaul Gilbert2015-05-01 18:21:13 -1000
commit12d3976c380e00f22c6f7a930ff56c215a7bd9ab (patch)
treed300e63c6088ae024460565162acfc95f9b4ea72 /engines
parentd9a42a80ffeb9eaee957bbc858f714e5cf362946 (diff)
downloadscummvm-rg350-12d3976c380e00f22c6f7a930ff56c215a7bd9ab.tar.gz
scummvm-rg350-12d3976c380e00f22c6f7a930ff56c215a7bd9ab.tar.bz2
scummvm-rg350-12d3976c380e00f22c6f7a930ff56c215a7bd9ab.zip
SHERLOCK: Implement configuration settings save/load
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/sherlock.cpp42
-rw-r--r--engines/sherlock/sherlock.h3
-rw-r--r--engines/sherlock/sound.cpp22
-rw-r--r--engines/sherlock/sound.h7
-rw-r--r--engines/sherlock/user_interface.h2
5 files changed, 67 insertions, 9 deletions
diff --git a/engines/sherlock/sherlock.cpp b/engines/sherlock/sherlock.cpp
index e3d137a3a3..3ab2caabc4 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();
}
/**
@@ -203,10 +206,47 @@ void SherlockEngine::setFlags(int flagNum) {
}
/**
+ * 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 3f0779421c..02e2e99229 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 a452efd890..e66f82e5c4 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 c85af2ac2a..3bd3a99f07 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 99612b218b..ac2c16d7c2 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();