diff options
author | Christopher Page | 2008-06-30 22:41:55 +0000 |
---|---|---|
committer | Christopher Page | 2008-06-30 22:41:55 +0000 |
commit | c1ae3f7dd0fc52df450c136ecad14cedda26a20c (patch) | |
tree | ec4743a186b92d904ad740a0fc4223b60c7b11ee | |
parent | 30c52e215c1e733de97edb10b313186cf90d8743 (diff) | |
download | scummvm-rg350-c1ae3f7dd0fc52df450c136ecad14cedda26a20c.tar.gz scummvm-rg350-c1ae3f7dd0fc52df450c136ecad14cedda26a20c.tar.bz2 scummvm-rg350-c1ae3f7dd0fc52df450c136ecad14cedda26a20c.zip |
Sound settings for Lure can be modified through the GMM
svn-id: r32855
-rw-r--r-- | engines/engine.h | 2 | ||||
-rw-r--r-- | engines/lure/lure.cpp | 4 | ||||
-rw-r--r-- | engines/lure/lure.h | 1 | ||||
-rw-r--r-- | engines/lure/sound.cpp | 43 | ||||
-rw-r--r-- | engines/lure/sound.h | 2 |
5 files changed, 37 insertions, 15 deletions
diff --git a/engines/engine.h b/engines/engine.h index 4be5527a8c..02eea82618 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -128,7 +128,7 @@ public: /** Run the Global Main Menu Dialog */ - void mainMenuDialog(); + virtual void mainMenuDialog(); /** Sync the engine's sound settings with the config manager */ diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index d20071691f..9c5482da6d 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -246,6 +246,10 @@ void LureEngine::GUIError(const char *msg, ...) { Engine::GUIErrorMessage(buffer); } +void LureEngine::syncSoundSettings() { + Sound.syncSounds(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); +} + Common::String *LureEngine::detectSave(int slotNumber) { Common::ReadStream *f = this->_saveFileMan->openForLoading( generateSaveName(slotNumber)); diff --git a/engines/lure/lure.h b/engines/lure/lure.h index 1c5b40e54b..940e04edc7 100644 --- a/engines/lure/lure.h +++ b/engines/lure/lure.h @@ -70,6 +70,7 @@ public: virtual int init(); virtual int go(); virtual void pauseEngineIntern(bool pause); + virtual void syncSoundSettings(); Disk &disk() { return *_disk; } diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index 285f66e4e2..9253f03b28 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -220,10 +220,12 @@ void SoundManager::addSound(uint8 soundIndex, bool tidyFlag) { newEntry->channel = channelCtr; newEntry->numChannels = numChannels; newEntry->flags = rec.flags; - if (_isRoland) - newEntry->volume = rec.volume; - else /* resource volumes do not seem to work well with our adlib emu */ - newEntry->volume = 240; /* 255 causes clipping with adlib */ + + if (newEntry->soundNumber & 0x80) + newEntry->volume = ConfMan.getInt("music_volume"); + else + newEntry->volume = ConfMan.getInt("sfx_volume"); + _activeSounds.push_back(SoundList::value_type(newEntry)); musicInterface_Play(rec.soundNumber, channelCtr, numChannels); @@ -280,6 +282,21 @@ uint8 SoundManager::descIndexOf(uint8 soundNumber) { return 0xff; // Couldn't find entry } +// Used to sync the volume for all channels with the Config Manager +// +void SoundManager::syncSounds(uint8 musicVol, uint8 sfxVol) { + MusicListIterator i; + + musicInterface_TidySounds(); + + for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { + if ((*i)->isMusic()) + (*i)->setVolume(musicVol); + else + (*i)->setVolume(sfxVol); + } +} + SoundDescResource *SoundManager::findSound(uint8 soundNumber) { debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber); SoundListIterator i; @@ -402,9 +419,8 @@ void SoundManager::musicInterface_Play(uint8 soundNumber, uint8 channelNumber, u return; bool isMusic = (soundNumber & 0x80) != 0; - uint8 volume = isMusic ? game.musicVolume() : game.sfxVolume(); - - if (!game.soundFlag() || (volume == 0)) + + if (!game.soundFlag()) // Don't play sounds if sound is turned off return; @@ -576,7 +592,11 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], /* 90 is power on default for midi compliant devices */ _channels[_channelNumber + i].volume = 90; } - setVolume(240); /* 255 causes clipping with mastervol 192 and adlib */ + + if (isMusic) + setVolume(ConfMan.getInt("music_volume")); + else + setVolume(ConfMan.getInt("sfx_volume")); _passThrough = false; @@ -634,14 +654,9 @@ void MidiMusic::setVolume(int volume) { _volume = volume; - Game &game = Game::getReference(); - volume *= _isMusic ? game.musicVolume() : game.sfxVolume(); - for (int i = 0; i < _numChannels; ++i) { if (_channels[_channelNumber + i].midiChannel != NULL) - _channels[_channelNumber + i].midiChannel->volume( - _channels[_channelNumber + i].volume * - volume / 65025); + _channels[_channelNumber + i].midiChannel->volume(volume); } } diff --git a/engines/lure/sound.h b/engines/lure/sound.h index c5a31a6c28..fd59729bc9 100644 --- a/engines/lure/sound.h +++ b/engines/lure/sound.h @@ -98,6 +98,7 @@ public: uint8 channelNumber() { return _channelNumber; } uint8 soundNumber() { return _soundNumber; } bool isPlaying() { return _isPlaying; } + bool isMusic() {return _isMusic; } }; class SoundManager: public Common::Singleton<SoundManager> { @@ -142,6 +143,7 @@ public: void stopSound(uint8 soundIndex); void killSound(uint8 soundNumber); void setVolume(uint8 soundNumber, uint8 volume); + void syncSounds(uint8 musicVol, uint8 sfxVol); void tidySounds(); uint8 descIndexOf(uint8 soundNumber); SoundDescResource *findSound(uint8 soundNumber); |