aboutsummaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/config.cpp b/src/config.cpp
index efa2523..72a071d 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -49,25 +49,22 @@ void readConfig(){
if(vol->FirstChildElement("sfx")->QueryFloatAttribute("volume",&fval) == XML_NO_ERROR)
VOLUME_SFX = fval;
else VOLUME_SFX = 50;
-
- Mix_Volume(0,VOLUME_MASTER);
- Mix_Volume(1,VOLUME_SFX);
- Mix_VolumeMusic(VOLUME_MUSIC);
-
+
ui::initFonts();
ui::setFontFace(xml.FirstChildElement("font")->Attribute("path"));
+ updateConfig();
}
void updateConfig(){
- vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER);
- vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC);
- vol->FirstChildElement("sfx")->SetAttribute("volume", VOLUME_SFX);
-
Mix_Volume(0,VOLUME_MASTER);
- Mix_Volume(1,VOLUME_SFX);
- Mix_VolumeMusic(VOLUME_MUSIC);
+ Mix_Volume(1,VOLUME_SFX * (VOLUME_MASTER/100.0f));
+ Mix_VolumeMusic(VOLUME_MUSIC * (VOLUME_MASTER/100.0f));
}
void saveConfig(){
+ vol->FirstChildElement("master")->SetAttribute("volume",VOLUME_MASTER);
+ vol->FirstChildElement("music")->SetAttribute("volume",VOLUME_MUSIC);
+ vol->FirstChildElement("sfx")->SetAttribute("volume", VOLUME_SFX);
+
xml.SaveFile("config/settings.xml", false);
}