]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameInitDispose.cpp
removed unused menu animation code
[lugaru.git] / Source / GameInitDispose.cpp
index db565c2faf9d995705484362096a8a4b6f8a359a..1b8699ee479b18d31e0ce2b9488013d23a2151d1 100644 (file)
@@ -61,7 +61,6 @@ extern long dirID;
 extern int mainmenu;
 extern int oldmainmenu;
 extern bool visibleloading;
-extern int loadscreencolor;
 extern float flashamount,flashr,flashg,flashb;
 extern int flashdelay;
 extern int whichjointstartarray[26];
@@ -100,8 +99,6 @@ void LOG(const std::string &fmt, ...)
 }
 
 
-Game::TextureList Game::textures;
-
 void Game::Dispose()
 {
        int i,j;
@@ -115,13 +112,7 @@ void Game::Dispose()
 
        Account::saveFile(":Data:Users", accountactive);
 
-       TexIter it = textures.begin();
-       for (; it != textures.end(); ++it)
-       {
-               if (glIsTexture(it->second))
-                       glDeleteTextures(1, &it->second);
-       }
-       textures.clear();
+       //textures.clear();
 
        LOG("Shutting down sound system...");
 
@@ -146,7 +137,17 @@ void Game::Dispose()
 }
 
 
-void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
+void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha){
+    textures.push_back(TextureInfo(fileName,textureid,mipmap,hasalpha));
+    textures.back().load();
+}
+
+void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize){
+    textures.push_back(TextureInfo(fileName,textureid,mipmap,array,skinsize));
+    textures.back().load();
+}
+
+void Game::LoadTextureData(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
 {
        GLuint          type;
 
@@ -192,7 +193,7 @@ void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool
        }
 }
 
-void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
+void Game::LoadTextureSaveData(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize, bool reload)
 {
        GLuint          type;
        int i;
@@ -237,12 +238,12 @@ void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GL
                if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
 
                int tempnum=0;
-               for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
-                       if((i+1)%4||type==GL_RGB){
-                               array[tempnum]=texture.data[i];
-                               tempnum++;
-                       }
-               }
+        if(!reload)
+            for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++)
+                if((i+1)%4||type==GL_RGB){
+                    array[tempnum]=texture.data[i];
+                    tempnum++;
+                }
 
                *skinsize=texture.sizeX;
 
@@ -295,7 +296,7 @@ void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte
        }
 }
 
-bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
+bool Game::AddClothes(const char *fileName, GLubyte *array)
 {
        int i;
        int bytesPerPixel;
@@ -418,14 +419,6 @@ void Game::LoadingScreen()
                glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
                glDisable(GL_BLEND);
                glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
-               //glColor4f(1,1,1,1);
-               /*if(loadscreencolor==0)glColor4f(1,1,1,1);
-               if(loadscreencolor==1)glColor4f(1,0,0,1);
-               if(loadscreencolor==2)glColor4f(0,1,0,1);
-               if(loadscreencolor==3)glColor4f(0,0,1,1);
-               if(loadscreencolor==4)glColor4f(1,1,0,1);
-               if(loadscreencolor==5)glColor4f(1,0,1,1);
-               */
                glPushMatrix();
                //glScalef(.25,.25,.25);
                glBegin(GL_QUADS);
@@ -482,13 +475,6 @@ void Game::LoadingScreen()
                glEnable(GL_BLEND);
                //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
                glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
-               /*if(loadscreencolor==0)glColor4f(1,1,1,1);
-               if(loadscreencolor==1)glColor4f(1,0,0,1);
-               if(loadscreencolor==2)glColor4f(0,1,0,1);
-               if(loadscreencolor==3)glColor4f(0,0,1,1);
-               if(loadscreencolor==4)glColor4f(1,1,0,1);
-               if(loadscreencolor==5)glColor4f(1,0,1,1);
-               */
                glPushMatrix();
                //glScalef(.25,.25,.25);
                glBegin(GL_QUADS);
@@ -600,7 +586,6 @@ void Game::LoadingScreen()
                }
 
                swap_gl_buffers();
-               loadscreencolor=0;
        }
 }
 
@@ -641,13 +626,6 @@ void Game::FadeLoadingScreen(float howmuch)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
        glDisable(GL_BLEND);
        glColor4f(loadprogress/100,0,0,1);
-       /*if(loadscreencolor==0)glColor4f(1,1,1,1);
-       if(loadscreencolor==1)glColor4f(1,0,0,1);
-       if(loadscreencolor==2)glColor4f(0,1,0,1);
-       if(loadscreencolor==3)glColor4f(0,0,1,1);
-       if(loadscreencolor==4)glColor4f(1,1,0,1);
-       if(loadscreencolor==5)glColor4f(1,0,1,1);
-       */
        glPushMatrix();
        //glScalef(.25,.25,.25);
        glBegin(GL_QUADS);
@@ -679,7 +657,6 @@ void Game::FadeLoadingScreen(float howmuch)
        text.glPrint(280,125,string,1,1,640,480);
        */
        swap_gl_buffers();
-       loadscreencolor=0;
 }
 
 
@@ -862,7 +839,7 @@ void Game::InitGame()
        loadAllSounds();
 
        if(musictoggle)
-         emit_stream_np(stream_music3);
+         emit_stream_np(stream_menutheme);
 
        LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
 
@@ -881,9 +858,6 @@ void Game::InitGame()
        //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
        texdetail=temptexdetail;
 
-       loaddistrib=0;
-       anim=0;
-
        FadeLoadingScreen(95);
 
 
@@ -900,6 +874,22 @@ void Game::InitGame()
 }
 
 
+void Game::LoadScreenTexture(){
+    glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    if(!screentexture)
+        glGenTextures( 1, &screentexture );
+    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+
+
+    glEnable(GL_TEXTURE_2D);
+    glBindTexture( GL_TEXTURE_2D, screentexture);
+    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+
+    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
+}
+
 void Game::LoadStuff()
 {
        static float temptexdetail;
@@ -1156,7 +1146,6 @@ void Game::LoadStuff()
                }
        }
 
-       loadscreencolor=4;
        LoadingScreen();
 
        for(i=0;i<player[0].skeleton.num_joints;i++){
@@ -1165,7 +1154,6 @@ void Game::LoadStuff()
                }
        }
 
-       loadscreencolor=4;
        LoadingScreen();
 
        for(i=0;i<player[0].skeleton.num_joints;i++){
@@ -1189,13 +1177,11 @@ void Game::LoadStuff()
                        animation[swordsneakattackanim].position[i][j]+=moveamount;
                }
        }
-       loadscreencolor=4;
        LoadingScreen();
        for(j=0;j<animation[swordsneakattackanim].numframes;j++){
                animation[swordsneakattackanim].weapontarget[j]+=moveamount;
        }
 
-       loadscreencolor=4;
        LoadingScreen();
 
        for(i=0;i<player[0].skeleton.num_joints;i++){
@@ -1210,29 +1196,16 @@ void Game::LoadStuff()
        }
        }
        */
-       loadscreencolor=4;
        LoadingScreen();
        temptexdetail=texdetail;
        texdetail=1;
        texdetail=temptexdetail;
 
-       loadscreencolor=4;
        LoadingScreen();
 
        //if(ismotionblur){
        if(!screentexture){
-               glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-               glGenTextures( 1, &screentexture );
-               glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-
-               glEnable(GL_TEXTURE_2D);
-               glBindTexture( GL_TEXTURE_2D, screentexture);
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
-               glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-
-               glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
+        LoadScreenTexture();
        }
 
        if(targetlevel!=7){