]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Everything changes based off of master volume, volume updates in menu
authordrumsetmonkey <abelleisle@roadrunner.com>
Fri, 19 Feb 2016 05:12:50 +0000 (00:12 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Fri, 19 Feb 2016 05:12:50 +0000 (00:12 -0500)
include/ui.h
main.cpp
src/config.cpp
src/ui.cpp
src/world.cpp

index 38a49328db2ee80169718ad5b34ff153fc8defb2..ccc16af8f802b99b939ff40a2704d3e5deec20af 100644 (file)
@@ -158,8 +158,6 @@ namespace ui {
         *      Draw various menu items
        */
        void quitGame();
-       void quitMenu();
-       void optionsMenuF();
        void drawMenu(Menu* menu);
 
 
index 19fe8d4382c0fa208d82e39d56acfde9feed04ea..805fa000af09239faa37ba853071e4fdb3fe92ad 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -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
index efa2523bfdf72c1b05a3a5e0e4ef86964c498702..72a071d72c6a16b11fc2f06971e325e5bd321e53 100644 (file)
@@ -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);
 }
index 3d635ab610f357b0f488cf3d7974a74a206e451d..2d0045348c29cf56f030049cd5216a99d3473578 100644 (file)
@@ -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);
index 25b7d35dc310ffe57668e27ce3bfcabce62e5623..51efaf2a193c79acf80888d002947e25c60bcc4c 100644 (file)
@@ -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
        }
 }