git repos / blockattack-game

commit 75741e4a

Poul Sander · 2021-06-04 19:49
75741e4a2588afd4c38bba19f34c2e0e1d30b57c patch · browse files
parent 8642f4393659f1afcdd13213606dda81649a4e8a

Volume is now adjustable in the configFile'

Changed files

M source/code/main.cpp before
diff --git a/source/code/main.cpp b/source/code/main.cpp index caf8c18..8be85d3 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -222,7 +222,8 @@ static int InitImages(sago::SagoSpriteHolder& holder) {
globalData.typingChunk = holder.GetDataHolder().getSoundHandler("typing");
counterChunk = holder.GetDataHolder().getSoundHandler("counter");
counterFinalChunk = holder.GetDataHolder().getSoundHandler("counter_final");
- const int soundVolume = 84; //0-128
+ Config::getInstance()->setDefault("volume_sound", "24"); //0-128
+ int soundVolume = Config::getInstance()->getInt("volume_sound");
Mix_VolumeChunk(boing.get(), soundVolume);
Mix_VolumeChunk(applause.get(), soundVolume);
Mix_VolumeChunk(photoClick.get(), soundVolume);
@@ -1047,6 +1048,7 @@ int main(int argc, char* argv[]) {
globalData.NoSound = true; //Tries to stop all sound from playing/loading
}
}
+ Config::getInstance()->setDefault("volume_music", "20"); //0-128
if (globalData.verboseLevel) {
@@ -1740,20 +1742,22 @@ int runGame(Gametype gametype, int level) {
if ((!globalData.NoSound)&&(!Mix_PlayingMusic())&&(globalData.MusicEnabled)&&(!bNearDeath)) {
// then starts playing it.
Mix_PlayMusic(bgMusic.get(), -1); //music loop
- Mix_VolumeMusic((MIX_MAX_VOLUME*3)/10);
+ int musicVolume = Config::getInstance()->getInt("volume_music");
+ Mix_VolumeMusic(musicVolume);
}
if (bNearDeath!=bNearDeathPrev) {
+ int musicVolume = Config::getInstance()->getInt("volume_music");
if (bNearDeath) {
if (!globalData.NoSound &&(globalData.MusicEnabled)) {
Mix_PlayMusic(highbeatMusic.get(), 1);
- Mix_VolumeMusic((MIX_MAX_VOLUME*5)/10);
+ Mix_VolumeMusic(musicVolume);
}
}
else {
if (!globalData.NoSound &&(globalData.MusicEnabled)) {
Mix_PlayMusic(bgMusic.get(), -1);
- Mix_VolumeMusic((MIX_MAX_VOLUME*3)/10);
+ Mix_VolumeMusic(musicVolume);
}
}
}