diff options
author | Paul Gilbert | 2018-01-28 11:53:11 -0500 |
---|---|---|
committer | Paul Gilbert | 2018-01-28 11:53:11 -0500 |
commit | 319b2c29d5e68973917556798e86dd846c7d719c (patch) | |
tree | 324e36c0992429dffedddbcc5e0d5bdcaac0b54c /engines/xeen | |
parent | 9dffe629596211bc00f2b4b7599c474e51661765 (diff) | |
download | scummvm-rg350-319b2c29d5e68973917556798e86dd846c7d719c.tar.gz scummvm-rg350-319b2c29d5e68973917556798e86dd846c7d719c.tar.bz2 scummvm-rg350-319b2c29d5e68973917556798e86dd846c7d719c.zip |
XEEN: Added logic for music/sound toggling
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs_control_panel.cpp | 6 | ||||
-rw-r--r-- | engines/xeen/music.cpp | 17 | ||||
-rw-r--r-- | engines/xeen/music.h | 10 | ||||
-rw-r--r-- | engines/xeen/sound.cpp | 19 | ||||
-rw-r--r-- | engines/xeen/sound.h | 11 | ||||
-rw-r--r-- | engines/xeen/xeen.cpp | 5 | ||||
-rw-r--r-- | engines/xeen/xeen.h | 5 |
7 files changed, 70 insertions, 3 deletions
diff --git a/engines/xeen/dialogs_control_panel.cpp b/engines/xeen/dialogs_control_panel.cpp index 3783d45633..9eec117bb2 100644 --- a/engines/xeen/dialogs_control_panel.cpp +++ b/engines/xeen/dialogs_control_panel.cpp @@ -132,11 +132,11 @@ int ControlPanel::execute() { break; case Common::KEYCODE_e: - // TODO: Toggle sound effects + sound.setEffectsOn(!sound._soundOn); break; case Common::KEYCODE_m: - // TODO: Toggle music + sound.setMusicOn(!sound._musicOn); break; case Common::KEYCODE_ESCAPE: @@ -180,7 +180,7 @@ int ControlPanel::execute() { void ControlPanel::loadButtons() { _iconSprites.load("cpanel.icn"); - addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f, 0, &_iconSprites); + addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_e, 0, &_iconSprites); addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m, 0, &_iconSprites); addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, 0, &_iconSprites); addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s, 0, &_iconSprites); diff --git a/engines/xeen/music.cpp b/engines/xeen/music.cpp index 1e9f6e2fbc..c9a62d5007 100644 --- a/engines/xeen/music.cpp +++ b/engines/xeen/music.cpp @@ -21,6 +21,7 @@ */ #include "common/md5.h" +#include "common/config-manager.h" #include "xeen/music.h" #include "xeen/xeen.h" #include "xeen/files.h" @@ -725,6 +726,8 @@ int Music::songCommand(uint commandId, byte volume) { void Music::playSong(Common::SeekableReadStream &stream) { stopSong(); + if (!_musicOn) + return; byte *songData = new byte[stream.size()]; stream.seek(0); @@ -742,4 +745,18 @@ void Music::playSong(const Common::String &name, int param) { playSong(f); } +void Music::setMusicOn(bool isOn) { + ConfMan.setBool("music_mute", !isOn); + if (isOn) + ConfMan.setBool("mute", false); + + g_vm->syncSoundSettings(); +} + +void Music::updateSoundSettings() { + _musicOn = !ConfMan.getBool("music_mute"); + if (!_musicOn) + stopSong(); +} + } // End of namespace Xeen diff --git a/engines/xeen/music.h b/engines/xeen/music.h index 126b079677..5bc6eb0a28 100644 --- a/engines/xeen/music.h +++ b/engines/xeen/music.h @@ -369,6 +369,16 @@ public: void playSong(const byte *data) { _musicDriver->playSong(data); } + + /** + * Sets whether music is on + */ + void setMusicOn(bool isOn); + + /** + * Called to reload sound settings + */ + virtual void updateSoundSettings(); }; } // End of namespace Xeen diff --git a/engines/xeen/sound.cpp b/engines/xeen/sound.cpp index 1da879842a..65a3e95784 100644 --- a/engines/xeen/sound.cpp +++ b/engines/xeen/sound.cpp @@ -22,6 +22,7 @@ #include "audio/decoders/raw.h" #include "audio/decoders/voc.h" +#include "common/config-manager.h" #include "xeen/sound.h" #include "xeen/xeen.h" @@ -39,6 +40,8 @@ Sound::~Sound() { void Sound::playSound(Common::SeekableReadStream &s, int unused) { stopSound(); + if (!_soundOn) + return; s.seek(0); Common::SeekableReadStream *srcStream = s.readStream(s.size()); @@ -69,4 +72,20 @@ void Sound::stopAllAudio() { stopSound(); } +void Sound::setEffectsOn(bool isOn) { + ConfMan.setBool("sfx_mute", !isOn); + if (isOn) + ConfMan.setBool("mute", false); + + g_vm->syncSoundSettings(); +} + +void Sound::updateSoundSettings() { + _soundOn = !ConfMan.getBool("sfx_mute"); + if (!_soundOn) + stopFX(); + + Music::updateSoundSettings(); +} + } // End of namespace Xeen diff --git a/engines/xeen/sound.h b/engines/xeen/sound.h index 41342dfab1..a79885a70f 100644 --- a/engines/xeen/sound.h +++ b/engines/xeen/sound.h @@ -68,6 +68,17 @@ public: * Stops all playing music, FX, and sound samples */ void stopAllAudio(); + + /** + * Sets whether sound effects is on + */ + void setEffectsOn(bool isOn); + + /** + * Called to reload sound settings + */ + virtual void updateSoundSettings(); + }; } // End of namespace Xeen diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index cac44d49a5..49862a74a1 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -246,4 +246,9 @@ Common::String XeenEngine::printK2(uint value) { Common::String::format("%u", value); } +void XeenEngine::syncSoundSettings() { + if (_sound) + _sound->updateSoundSettings(); +} + } // End of namespace Xeen diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 610fe8ba4b..00f3901868 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -186,6 +186,11 @@ public: virtual Common::Error saveGameState(int slot, const Common::String &desc); /** + * Updates sound settings + */ + virtual void syncSoundSettings(); + + /** * Returns true if a savegame can currently be loaded */ bool canLoadGameStateCurrently(); |