From c295f524b23af358192ddb352454ebf995dd51b0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 6 Jun 2009 17:36:06 +0000 Subject: [PATCH] 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 9b2c8df2876..06851c51855 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 b4fc5e0777e..feb2c9a9c5c 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 f6a07e3341f..e13d95cf478 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 269bb0bc28a..0847e27246d 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 45477f408de..ff3ce6c3267 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 415d7ca357e..2e23a4dc61d 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 53fc5e2d014..4edf12a0dff 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 798f4d292fae73fede94212e7ce1a8060bb5c19d..7dcf3402ed849495b81a470efd17a6fc10dea9b1 100644 GIT binary patch delta 292 zcmZ4VlxgWhCf)#VW)=|!5O9*(IgvMr7f4wxmAtvxSAl`ScVo_TW)2lD1ziOd&y>x- zS?XkjK=Qk|89vN(XJ7zfA%@9@n?yFxSG-jdv-53}^Sdw9K;U?+L zqFG2PC(Eg+Y(ANH%}Ewyu4LZ{djp_TK$snfVc@{zJsTy!D&Q_tU|`^fNdxHvlRs`$ iP{4E>Ldk)~^9n$hLKLAo3t7>O44@;m*`}=r2?79k2u)Z3 delta 784 zcmZ4bkZI9VCf)#VW)=|!5YSxHI*~Vs7f4z47}p5ARbXIvyD{fEbG?;9MoCFQv6a4l zadK&HZdtBgaao>Taeir0a%x(BQF^LgUTTRxP^>6FA4o&g!0D2r(!6Z_^wLcIl8n^c z)MAK4a!z7#ab~hUl#WkNtI#VhsZdbiQqWaU@l3H&fXiq?rHoBYEDRKk3=AxE4UKe- zj1&wFtc(q<3=E?bvdRjI5=#^|N3+z)@bNERW5wEIbj99-fx+Hm^K*rl^zlMYVr715 z307a|C&wen8k-p#8iPDyscT@Q3uXd+VP$F%rBITXm!Dm#u=$3{DQ7-Wphpb5<_g!j zGceS-Z{Cpcfu0_T&&e+@N-ak9j{`hfApSvCWNc|*ZVvU9G0}R;0GRARm>q~=V9DhD>m|S{;Hgl7fq@?;4WyS${<2;{ o0X3Q#7=(~jH0CQ#Hrb${fEt7h43a2{?qyCc*`Uofc_T;^06-=GfdBvi diff --git a/gui/themes/scummmodern.zip b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Oqxx9^psUKG5Abjk!$HP{?Ypq0ulC*QI+cX$ VuA?n|qqI((8e|-emqdm*e*$OuXI}sS diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 736fce87f23..6246b6c9651 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -252,6 +252,11 @@ /> + + @@ -592,8 +597,12 @@ /> +