diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-19 00:12:50 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-02-19 00:12:50 -0500 |
commit | 0d77d11b708e57546d8267e957230c30bc5d048c (patch) | |
tree | 435ea7a56b2d080783f7aa9dec653718aba39342 /src | |
parent | 51b0b214967ca4770b1674431cffa15777b0ec06 (diff) |
Everything changes based off of master volume, volume updates in menu
Diffstat (limited to 'src')
-rw-r--r-- | src/config.cpp | 19 | ||||
-rw-r--r-- | src/ui.cpp | 15 | ||||
-rw-r--r-- | src/world.cpp | 4 |
3 files changed, 12 insertions, 26 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); } @@ -648,11 +648,7 @@ namespace ui { updateConfig(); saveConfig(); } - - void quitMenu(){ - currentMenu = NULL; - } - + menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f){ menuItem temp; temp.member = 0; @@ -717,20 +713,13 @@ namespace ui { return temp; } - char* stradd(const char* a, const char* b){ - size_t len = strlen(a) + strlen(b); - char *ret = (char*)malloc(len * sizeof(char) + 1); - *ret = '\0'; - - return strcat(strcat(ret,a),b); - } - /* * Draws the menu */ void drawMenu(Menu *menu){ setFontSize(24); + updateConfig(); SDL_Event e; mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2); diff --git a/src/world.cpp b/src/world.cpp index 25b7d35..51efaf2 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -381,12 +381,12 @@ void World::bgmPlay(World *prev){ if(prev){ if(bgm != prev->bgm){ Mix_FadeOutMusic(800); - Mix_VolumeMusic(50); + //Mix_VolumeMusic(50); Mix_PlayMusic(bgmObj,-1); // Loop infinitely } }else{ Mix_FadeOutMusic(800); - Mix_VolumeMusic(50); + //Mix_VolumeMusic(50); Mix_PlayMusic(bgmObj,-1); // Loop infinitely } } |