From b9b81a22c298a44304f260203673c5c83b1cb04b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 11 Sep 2016 23:05:09 +0200 Subject: FULLPIPE: Make sound controls work and persistent --- engines/fullpipe/fullpipe.cpp | 8 +++----- engines/fullpipe/modal.cpp | 2 +- engines/fullpipe/sound.cpp | 11 ++++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'engines/fullpipe') diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index 82528f2886..6b8f92ccd2 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -63,8 +63,9 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) warning("Sound initialization failed."); } - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + syncSoundSettings(); + _sfxVolume = ConfMan.getInt("sfx_volume") * 39 - 10000; + _musicVolume = ConfMan.getInt("music_volume"); _rnd = new Common::RandomSource("fullpipe"); _console = 0; @@ -84,9 +85,6 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) _soundEnabled = true; _flgSoundList = true; - _sfxVolume = 0; - _musicVolume = 0; - _inputController = 0; _inputDisabled = false; diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index 27503d4cbe..1d1bbd077d 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -1023,7 +1023,7 @@ bool ModalMainMenu::init(int counterdiff) { } void ModalMainMenu::updateVolume() { - if (g_fp->_soundEnabled ) { + if (g_fp->_soundEnabled) { for (int s = 0; s < g_fp->_currSoundListCount; s++) for (int i = 0; i < g_fp->_currSoundList1[s]->getCount(); i++) { updateSoundVolume(g_fp->_currSoundList1[s]->getSoundByIndex(i)); diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index c9af9e85ae..e7432a62c4 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -29,6 +29,7 @@ #include "fullpipe/messages.h" #include "fullpipe/statics.h" +#include "common/config-manager.h" #include "common/memstream.h" #include "audio/mixer.h" #include "audio/audiostream.h" @@ -214,8 +215,8 @@ void Sound::setPanAndVolumeByStaticAni() { } void Sound::setPanAndVolume(int vol, int pan) { - g_fp->_mixer->setChannelVolume(*_handle, vol / 39); // 0..10000 - g_fp->_mixer->setChannelBalance(*_handle, pan / 78); // -10000..10000 + g_fp->_mixer->setChannelVolume(*_handle, MIN((vol + 10000) / 39, 255)); // -10000..0 + g_fp->_mixer->setChannelBalance(*_handle, CLIP(pan / 78, -127, 127)); // -10000..10000 } void Sound::play(int flag) { @@ -520,6 +521,9 @@ void FullpipeEngine::stopAllSoundInstances(int id) { } void FullpipeEngine::updateSoundVolume() { + ConfMan.setInt("sfx_volume", MAX((_sfxVolume + 10000) / 39, 255)); + syncSoundSettings(); + for (int i = 0; i < _currSoundListCount; i++) for (int j = 0; j < _currSoundList1[i]->getCount(); j++) { _currSoundList1[i]->getSoundByIndex(j)->setPanAndVolume(_sfxVolume, 0); @@ -529,7 +533,8 @@ void FullpipeEngine::updateSoundVolume() { void FullpipeEngine::setMusicVolume(int vol) { _musicVolume = vol; - g_fp->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol); + ConfMan.setInt("music_volume", _musicVolume); + syncSoundSettings(); } } // End of namespace Fullpipe -- cgit v1.2.3