From c295f524b23af358192ddb352454ebf995dd51b0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 6 Jun 2009 17:36:06 +0000 Subject: Implement feature request #1180217: "GUI: Mute option" svn-id: r41233 --- backends/events/default/default-events.cpp | 5 +++++ backends/platform/sdl/events.cpp | 5 +++++ common/events.h | 1 + engines/engine.cpp | 22 +++++++++++++++++++--- engines/engine.h | 5 +++++ gui/options.cpp | 18 ++++++++++++++++-- gui/options.h | 2 ++ gui/themes/scummclassic.zip | Bin 45730 -> 45221 bytes gui/themes/scummmodern.zip | Bin 148944 -> 148602 bytes gui/themes/scummmodern/scummmodern_layout.stx | 9 +++++++++ 10 files changed, 62 insertions(+), 5 deletions(-) diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 9b2c8df287..06851c5185 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -553,6 +553,11 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _shouldRTL = true; break; + case Common::EVENT_MUTE: + if (g_engine) + g_engine->flipMute(); + break; + case Common::EVENT_QUIT: if (ConfMan.getBool("confirm_exit")) { if (_confirmExitDialogActive) { diff --git a/backends/platform/sdl/events.cpp b/backends/platform/sdl/events.cpp index b4fc5e0777..feb2c9a9c5 100644 --- a/backends/platform/sdl/events.cpp +++ b/backends/platform/sdl/events.cpp @@ -252,6 +252,11 @@ bool OSystem_SDL::pollEvent(Common::Event &event) { } #endif + if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'u') { + event.type = Common::EVENT_MUTE; + return true; + } + // Ctrl-Alt- will change the GFX mode if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) { diff --git a/common/events.h b/common/events.h index f6a07e3341..e13d95cf47 100644 --- a/common/events.h +++ b/common/events.h @@ -61,6 +61,7 @@ enum EventType { EVENT_MAINMENU = 15, EVENT_RTL = 16, + EVENT_MUTE = 17, EVENT_QUIT = 10, EVENT_SCREEN_CHANGED = 11, diff --git a/engines/engine.cpp b/engines/engine.cpp index 269bb0bc28..0847e27246 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -304,9 +304,25 @@ void Engine::syncSoundSettings() { int soundVolumeSFX = ConfMan.getInt("sfx_volume"); int soundVolumeSpeech = ConfMan.getInt("speech_volume"); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, soundVolumeSFX); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech); + bool mute = false; + if (ConfMan.hasKey("mute")) + mute = ConfMan.getBool("mute"); + + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, (mute ? 0 : soundVolumeMusic)); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, (mute ? 0 : soundVolumeSFX)); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, (mute ? 0 : soundVolumeSpeech)); +} + +void Engine::flipMute() { + bool mute = false; + + if (ConfMan.hasKey("mute")) { + mute = !ConfMan.getBool("mute"); + } + + ConfMan.setBool("mute", mute); + + syncSoundSettings(); } Common::Error Engine::loadGameState(int slot) { diff --git a/engines/engine.h b/engines/engine.h index 45477f408d..ff3ce6c326 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -175,6 +175,11 @@ public: */ virtual void syncSoundSettings(); + /** + * Flip mute all sound option. + */ + virtual void flipMute(); + /** * Load a game state. * @param slot the slot from which a savestate should be loaded diff --git a/gui/options.cpp b/gui/options.cpp index 415d7ca357..2e23a4dc61 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -119,6 +119,7 @@ void OptionsDialog::init() { _speechVolumeDesc = 0; _speechVolumeSlider = 0; _speechVolumeLabel = 0; + _muteCheckbox = 0; _subToggleDesc = 0; _subToggleButton = 0; _subSpeedDesc = 0; @@ -240,12 +241,19 @@ void OptionsDialog::open() { vol = ConfMan.getInt("speech_volume", _domain); _speechVolumeSlider->setValue(vol); _speechVolumeLabel->setValue(vol); + + bool val = false; + if (ConfMan.hasKey("mute", _domain)) { + val = ConfMan.getBool("mute", _domain); + } else { + ConfMan.setBool("mute", false); + } + _muteCheckbox->setState(val); } // Subtitle options if (_subToggleButton) { - int speed; - int sliderMaxValue = _subSpeedSlider->getMaxValue(); + int speed; int sliderMaxValue = _subSpeedSlider->getMaxValue(); _subMode = getSubtitleMode(ConfMan.getBool("subtitles", _domain), ConfMan.getBool("speech_mute", _domain)); _subToggleButton->setLabel(_subModeDesc[_subMode]); @@ -300,10 +308,12 @@ void OptionsDialog::close() { ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain); ConfMan.setInt("sfx_volume", _sfxVolumeSlider->getValue(), _domain); ConfMan.setInt("speech_volume", _speechVolumeSlider->getValue(), _domain); + ConfMan.setBool("mute", _muteCheckbox->getState(), _domain); } else { ConfMan.removeKey("music_volume", _domain); ConfMan.removeKey("sfx_volume", _domain); ConfMan.removeKey("speech_volume", _domain); + ConfMan.removeKey("mute", _domain); } } @@ -514,6 +524,7 @@ void OptionsDialog::setVolumeSettingsState(bool enabled) { _speechVolumeDesc->setEnabled(enabled); _speechVolumeSlider->setEnabled(enabled); _speechVolumeLabel->setEnabled(enabled); + _muteCheckbox->setEnabled(enabled); } void OptionsDialog::setSubtitleSettingsState(bool enabled) { @@ -640,6 +651,9 @@ void OptionsDialog::addVolumeControls(GuiObject *boss, const String &prefix) { _musicVolumeSlider->setMaxValue(Audio::Mixer::kMaxMixerVolume); _musicVolumeLabel->setFlags(WIDGET_CLEARBG); + _muteCheckbox = new CheckboxWidget(boss, prefix + "vcMuteCheckbox", "Mute All", 0, 0); + + _sfxVolumeDesc = new StaticTextWidget(boss, prefix + "vcSfxText", "SFX volume:"); _sfxVolumeSlider = new SliderWidget(boss, prefix + "vcSfxSlider", kSfxVolumeChanged); _sfxVolumeLabel = new StaticTextWidget(boss, prefix + "vcSfxLabel", "100%"); diff --git a/gui/options.h b/gui/options.h index 53fc5e2d01..4edf12a0df 100644 --- a/gui/options.h +++ b/gui/options.h @@ -145,6 +145,8 @@ private: StaticTextWidget *_speechVolumeDesc; SliderWidget *_speechVolumeSlider; StaticTextWidget *_speechVolumeLabel; + + CheckboxWidget *_muteCheckbox; }; diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 798f4d292f..7dcf3402ed 100644 Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index a67b11f244..9838b8b2f4 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 736fce87f2..6246b6c965 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -252,6 +252,11 @@ /> + + @@ -592,8 +597,12 @@ /> +