CGE2: Fix initVolumeSwitch().

This commit is contained in:
uruk 2014-08-13 20:25:38 +02:00
parent 2eddd72fbf
commit 28a450982a
2 changed files with 11 additions and 8 deletions

View File

@ -224,7 +224,7 @@ public:
void switchVox();
void switchSay();
void initToolbar();
void initVolumeSwitch(Sprite *volSwitch);
void initVolumeSwitch(Sprite *volSwitch, int val);
void checkSounds();

View File

@ -198,17 +198,20 @@ void CGE2Engine::initToolbar() {
_vol[0] = _vga->_showQ->locate(kDvolRef);
_vol[1] = _vga->_showQ->locate(kMvolRef);
if (_vol[0])
initVolumeSwitch(_vol[0]);
if (_vol[0]) {
int val = ConfMan.getInt("sfx_volume");
initVolumeSwitch(_vol[0], val);
}
if (_vol[1])
initVolumeSwitch(_vol[1]);
if (_vol[1]) {
int val = ConfMan.getInt("music_volume");
initVolumeSwitch(_vol[1], val);
}
}
void CGE2Engine::initVolumeSwitch(Sprite *volSwitch) {
void CGE2Engine::initVolumeSwitch(Sprite *volSwitch, int val) {
int state = 0;
if (!ConfMan.getBool("mute"))
state = ConfMan.getInt("sfx_volume") / kSoundNumtoStateRate;
state = val / kSoundNumtoStateRate;
volSwitch->step(state);
}