SHERLOCK: RT: Properly hook up volume and mute toggles in Options dialog

This commit is contained in:
Paul Gilbert 2016-02-05 19:31:35 -05:00
parent bb9052bf6f
commit 456e5956e0
4 changed files with 19 additions and 15 deletions

View File

@ -222,14 +222,13 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
_midiParser = NULL;
_musicType = MT_NULL;
_musicPlaying = false;
_musicOn = false;
_midiOption = false;
_musicVolume = 0;
_midiMusicData = nullptr;
_musicVolume = ConfMan.hasKey("music_volume") ? ConfMan.getInt("music_volume") : 255;
if (IS_3DO) {
// 3DO - uses digital samples for music
_musicOn = true;
_musicOn = ConfMan.hasKey("music_mute") ? !ConfMan.getBool("music_mute") : true;
return;
}
@ -328,7 +327,7 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
}
}
_musicOn = true;
_musicOn = ConfMan.hasKey("music_mute") ? !ConfMan.getBool("music_mute") : true;
}
}
@ -580,6 +579,7 @@ bool Music::waitUntilMSec(uint32 msecTarget, uint32 msecMax, uint32 additionalDe
void Music::setMusicVolume(int volume) {
_musicVolume = volume;
_musicOn = volume > 0;
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
}

View File

@ -239,6 +239,9 @@ void SherlockEngine::saveConfig() {
ConfMan.setBool("mute", !_sound->_digitized);
ConfMan.setBool("music_mute", !_music->_musicOn);
ConfMan.setBool("speech_mute", !_sound->_speechOn);
ConfMan.setInt("music_volume", _music->_musicVolume);
ConfMan.setInt("sfx_volume", _sound->_soundVolume);
ConfMan.setInt("speech_volume", _sound->_soundVolume);
ConfMan.setInt("font", _screen->fontNumber());
ConfMan.setBool("fade_style", _screen->_fadeStyle);

View File

@ -58,10 +58,9 @@ Sound::Sound(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
_soundPlaying = false;
_speechPlaying = false;
_curPriority = 0;
_soundVolume = 255;
_soundOn = true;
_speechOn = true;
_soundVolume = ConfMan.hasKey("sfx_volume") ? ConfMan.getInt("sfx_volume") : 255;
_soundOn = ConfMan.hasKey("mute") ? !ConfMan.getBool("mute") : true;
_speechOn = ConfMan.hasKey("speech_mute") ? !ConfMan.getBool("speech_mute") : true;
if (IS_3DO) {
// 3DO: we don't need to prepare anything for sound
@ -239,7 +238,10 @@ Audio::SoundHandle &Sound::getFreeSoundHandle() {
}
void Sound::setVolume(int volume) {
warning("TODO: setVolume - %d", volume);
_soundVolume = volume;
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, volume);
}
void Sound::playSpeech(const Common::String &name) {

View File

@ -130,10 +130,9 @@ void WidgetOptions::handleEvents() {
else if (_digiSliderX > _bounds.width() - _surface.widestChar())
_digiSliderX = _bounds.width() - _surface.widestChar();
int temp = sound._soundVolume;
sound._soundVolume = (_digiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2);
if (sound._soundVolume != temp) {
sound.setVolume(sound._soundVolume);
int newVolume = (_digiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2);
if (newVolume != sound._soundVolume) {
sound.setVolume(newVolume);
vm.saveConfig();
}
@ -188,7 +187,7 @@ void WidgetOptions::handleEvents() {
case 5:
// Toggle Voices
sound._voices = !sound._voices;
sound._speechOn = !sound._speechOn;
render(OP_NAMES);
vm.saveConfig();
@ -326,7 +325,7 @@ void WidgetOptions::render(OptionRenderMode mode) {
break;
case 5:
str = Common::String::format("%s %s", FIXED(Voices), OFF_ON[sound._voices]);
str = Common::String::format("%s %s", FIXED(Voices), OFF_ON[sound._speechOn]);
break;
case 6: {