diff options
-rw-r--r-- | include/ui.h | 2 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | src/config.cpp | 19 | ||||
-rw-r--r-- | src/ui.cpp | 15 | ||||
-rw-r--r-- | src/world.cpp | 4 |
5 files changed, 12 insertions, 30 deletions
diff --git a/include/ui.h b/include/ui.h index 38a4932..ccc16af 100644 --- a/include/ui.h +++ b/include/ui.h @@ -158,8 +158,6 @@ namespace ui { * Draw various menu items */ void quitGame(); - void quitMenu(); - void optionsMenuF(); void drawMenu(Menu* menu); @@ -377,8 +377,6 @@ int main(/*int argc, char *argv[]*/){ delete[] shaderSource; glEnable(GL_MULTISAMPLE); - - Mix_Volume(0,VOLUME_MASTER); /* * Create all the worlds, entities, mobs, and the player. This function is defined in 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 } } |