diff options
author | Johannes Schickel | 2008-04-04 18:02:50 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-04-04 18:02:50 +0000 |
commit | 272fa6d578fcb9bcc7ba8511f886630503799bae (patch) | |
tree | 29ec5a6b82b670ddbc6adda2d5f2d66b5897033c /engines/kyra/kyra.cpp | |
parent | 214d6b5eb7a64ed52e970c44e8773faa16f62c63 (diff) | |
download | scummvm-rg350-272fa6d578fcb9bcc7ba8511f886630503799bae.tar.gz scummvm-rg350-272fa6d578fcb9bcc7ba8511f886630503799bae.tar.bz2 scummvm-rg350-272fa6d578fcb9bcc7ba8511f886630503799bae.zip |
Implemented audio menu, slider bars not moveable via mouse yet though.
svn-id: r31384
Diffstat (limited to 'engines/kyra/kyra.cpp')
-rw-r--r-- | engines/kyra/kyra.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 8a377c231d..302f7277ae 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -322,5 +322,56 @@ bool KyraEngine::textEnabled() { return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2); } +inline int convertValueToMixer(int value) { + value -= 2; + return (value * Audio::Mixer::kMaxMixerVolume) / 95; +} + +inline int convertValueFromMixer(int value) { + return (value * 95) / Audio::Mixer::kMaxMixerVolume + 2; +} + +void KyraEngine::setVolume(kVolumeEntry vol, uint8 value) { + switch (vol) { + case kVolumeMusic: + ConfMan.setInt("music_volume", convertValueToMixer(value)); + break; + + case kVolumeSfx: + ConfMan.setInt("sfx_volume", convertValueToMixer(value)); + break; + + case kVolumeSpeech: + ConfMan.setInt("speech_volume", convertValueToMixer(value)); + break; + } + + // Resetup mixer + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); +} + +uint8 KyraEngine::getVolume(kVolumeEntry vol) { + switch (vol) { + case kVolumeMusic: + return convertValueFromMixer(ConfMan.getInt("music_volume")); + break; + + case kVolumeSfx: + return convertValueFromMixer(ConfMan.getInt("sfx_volume")); + break; + + case kVolumeSpeech: + if (speechEnabled()) + return convertValueFromMixer(ConfMan.getInt("speech_volume")); + else + return 2; + break; + } + + return 2; +} + } // End of namespace Kyra |