Implement feature request #1180217: "GUI: Mute option"

svn-id: r41233
This commit is contained in:
Eugene Sandulenko 2009-06-06 17:36:06 +00:00
parent 4ceec0dfbb
commit c295f524b2
10 changed files with 62 additions and 5 deletions

View File

@ -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) {

View File

@ -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-<key> will change the GFX mode
if ((b & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {

View File

@ -61,6 +61,7 @@ enum EventType {
EVENT_MAINMENU = 15,
EVENT_RTL = 16,
EVENT_MUTE = 17,
EVENT_QUIT = 10,
EVENT_SCREEN_CHANGED = 11,

View File

@ -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) {

View File

@ -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

View File

@ -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%");

View File

@ -145,6 +145,8 @@ private:
StaticTextWidget *_speechVolumeDesc;
SliderWidget *_speechVolumeSlider;
StaticTextWidget *_speechVolumeLabel;
CheckboxWidget *_muteCheckbox;
};

Binary file not shown.

Binary file not shown.

View File

@ -252,6 +252,11 @@
/>
<widget name = 'vcSfxLabel'
type = 'SmallLabel'
width = "40"
/>
<space/>
<widget name = 'vcMuteCheckbox'
type = 'Checkbox'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0'>
@ -592,8 +597,12 @@
/>
<widget name = 'vcSfxLabel'
type = 'SmallLabel'
width = "40"
/>
</layout>
<widget name = 'vcMuteCheckbox'
type = 'Checkbox'
/>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '8'>
<widget name = 'vcSpeechText'
type = 'OptionsLabel'