Skip to content

Commit

Permalink
TSAGE: Fix updating the volume when changed in the Options dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 21, 2011
1 parent 8c6ad70 commit 8aa368f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions engines/tsage/ringworld_demo.cpp
Expand Up @@ -72,6 +72,7 @@ void RingworldDemoGame::processEvent(Event &event) {
ConfigDialog *dlg = new ConfigDialog();
dlg->runModal();
delete dlg;
_globals->_soundManager.syncSounds();
_globals->_events.setCursorFromFlag();
break;
}
Expand Down
1 change: 1 addition & 0 deletions engines/tsage/ringworld_logic.cpp
Expand Up @@ -1441,6 +1441,7 @@ void RingworldGame::processEvent(Event &event) {
ConfigDialog *dlg = new ConfigDialog();
dlg->runModal();
delete dlg;
_globals->_soundManager.syncSounds();
_globals->_events.setCursorFromFlag();
break;
}
Expand Down
14 changes: 7 additions & 7 deletions engines/tsage/sound.cpp
Expand Up @@ -43,7 +43,7 @@ SoundManager::SoundManager() {
_voiceTypeStructPtrs[i] = NULL;

_groupsAvail = 0;
_masterVol = 127;
_newVolume = _masterVol = 127;
_suspendedCount = 0;
_driversDetected = false;
_needToRethink = false;
Expand Down Expand Up @@ -100,18 +100,14 @@ void SoundManager::syncSounds() {
mute = ConfMan.getBool("mute");

bool music_mute = mute;
bool sfx_mute = mute;

if (!mute) {
music_mute = ConfMan.getBool("music_mute");
sfx_mute = ConfMan.getBool("sfx_mute");
}

// Get the new music and sfx volumes
// Get the new music volume
int musicVolume = music_mute ? 0 : MIN(255, ConfMan.getInt("music_volume"));
int sfxVolume = sfx_mute ? 0 : MIN(255, ConfMan.getInt("sfx_volume"));

warning("Set volume music=%d sfx=%d", musicVolume, sfxVolume);
this->setMasterVol(musicVolume / 2);
}

Expand Down Expand Up @@ -251,7 +247,7 @@ bool SoundManager::isInstalled(int driverNum) const {
}

void SoundManager::setMasterVol(int volume) {
_sfSetMasterVol(volume);
_newVolume = volume;
}

int SoundManager::getMasterVol() const {
Expand Down Expand Up @@ -341,6 +337,10 @@ void SoundManager::_sfSoundServer() {
_sfDereferenceAll();
}

// If the master volume has changed, update it
if (sfManager()._newVolume != sfManager()._masterVol)
_sfSetMasterVol(sfManager()._newVolume);

// Handle any fading if necessary
_sfProcessFading();

Expand Down
1 change: 1 addition & 0 deletions engines/tsage/sound.h
Expand Up @@ -171,6 +171,7 @@ class SoundManager : public SaveListener {
VoiceTypeStruct *_voiceTypeStructPtrs[SOUND_ARR_SIZE];
uint32 _groupsAvail;
int _masterVol;
int _newVolume;
Common::Mutex _serverDisabledMutex;
Common::Mutex _serverSuspendedMutex;
int _suspendedCount;
Expand Down

0 comments on commit 8aa368f

Please sign in to comment.