]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameInitDispose.cpp
Fixes #41 It was hard to click on the next campaign level when it’s above an old one
[lugaru.git] / Source / GameInitDispose.cpp
index 24a9de3e1bbdda9b83c79e5432d8945ef68a0cef..fefba877857be0d8a1c4abc12158fcb1aa3ac623 100644 (file)
@@ -18,11 +18,13 @@ You should have received a copy of the GNU General Public License
 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "Game.h"
-#include "openal_wrapper.h"
-#include "Animation/Animation.h"
-#include "Texture.h"
-#include "Utils/Folders.h"
+#include "Game.hpp"
+
+#include "Animation/Animation.hpp"
+#include "Audio/openal_wrapper.hpp"
+#include "Graphic/Texture.hpp"
+#include "Menu/Menu.hpp"
+#include "Utils/Folders.hpp"
 
 extern float screenwidth, screenheight;
 extern float viewdistance;
@@ -56,7 +58,6 @@ extern float flashamount, flashr, flashg, flashb;
 extern int flashdelay;
 extern int whichjointstartarray[26];
 extern int whichjointendarray[26];
-extern int difficulty;
 extern float slomospeed;
 extern bool gamestarted;
 
@@ -78,11 +79,11 @@ void Dispose()
     LOGFUNC;
 
     if (Game::endgame == 2) {
-        Game::accountactive->endGame();
+        Account::active().endGame();
         Game::endgame = 0;
     }
 
-    Account::saveFile(Folders::getUserDataPath()+"/users", Game::accountactive);
+    Account::saveFile(Folders::getUserDataPath()+"/users");
 
     //textures.clear();
 
@@ -457,7 +458,7 @@ void Game::InitGame()
 
     numchallengelevels = 14;
 
-    accountactive = Account::loadFile(Folders::getUserDataPath()+"/users");
+    Account::loadFile(Folders::getUserDataPath()+"/users");
 
     whichjointstartarray[0] = righthip;
     whichjointendarray[0] = rightfoot;
@@ -627,7 +628,7 @@ void Game::InitGame()
     newscreenwidth = screenwidth;
     newscreenheight = screenheight;
 
-    LoadMenu();
+    Menu::Load();
 
     Animation::loadAll();
 }
@@ -650,12 +651,11 @@ void Game::LoadScreenTexture()
     glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
 }
 
-//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
+//TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.hpp
 void Game::LoadStuff()
 {
     static float temptexdetail;
     static float viewdistdetail;
-    static int i, j;
     float megascale = 1;
 
     LOGFUNC;
@@ -668,7 +668,6 @@ void Game::LoadStuff()
         p->skeleton.drawmodel.textureptr.destroy();
     }
 
-    i = abs(Random() % 4);
     visibleloading = 0; //don't use loadscreentexture yet
     loadscreentexture.load("Textures/Fire.jpg", 1);
     visibleloading = 1;
@@ -684,12 +683,13 @@ void Game::LoadStuff()
 
     if (detail == 2) {
         texdetail = 1;
-    }
-    if (detail == 1) {
+        kTextureSize = 1024;
+    } else if (detail == 1) {
         texdetail = 2;
-    }
-    if (detail == 0) {
+        kTextureSize = 512;
+    } else {
         texdetail = 4;
+        kTextureSize = 256;
     }
 
     realtexdetail = texdetail;
@@ -756,14 +756,6 @@ void Game::LoadStuff()
 
     viewer = 0;
 
-
-    if (detail)
-        kTextureSize = 1024;
-    if (detail == 1)
-        kTextureSize = 512;
-    if (detail == 0)
-        kTextureSize = 256;
-
     //Set up distant light
     light.color[0] = .95;
     light.color[1] = .95;
@@ -825,53 +817,55 @@ void Game::LoadStuff()
     XYZ moveamount;
     moveamount = 0;
     moveamount.z = 2;
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
-        for (j = 0; j < Animation::animations[knifesneakattackanim].numframes; j++) {
-            Animation::animations[knifesneakattackanim].position[i][j] += moveamount;
+    // FIXME - Why this uses skeleton.joints.size() and not Animation::numjoints? (are they equal?)
+    // It seems skeleton.joints.size() is 0 at this point, so this is useless.
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[knifesneakattackanim].frames.size(); j++) {
+            Animation::animations[knifesneakattackanim].frames[j].joints[i].position += moveamount;
         }
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
-        for (j = 0; j < Animation::animations[knifesneakattackedanim].numframes; j++) {
-            Animation::animations[knifesneakattackedanim].position[i][j] += moveamount;
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[knifesneakattackedanim].frames.size(); j++) {
+            Animation::animations[knifesneakattackedanim].frames[j].joints[i].position += moveamount;
         }
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
-        Animation::animations[dead1anim].position[i][1] = Animation::animations[dead1anim].position[i][0];
-        Animation::animations[dead2anim].position[i][1] = Animation::animations[dead2anim].position[i][0];
-        Animation::animations[dead3anim].position[i][1] = Animation::animations[dead3anim].position[i][0];
-        Animation::animations[dead4anim].position[i][1] = Animation::animations[dead4anim].position[i][0];
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        Animation::animations[dead1anim].frames[1].joints[i].position = Animation::animations[dead1anim].frames[0].joints[i].position;
+        Animation::animations[dead2anim].frames[1].joints[i].position = Animation::animations[dead2anim].frames[0].joints[i].position;
+        Animation::animations[dead3anim].frames[1].joints[i].position = Animation::animations[dead3anim].frames[0].joints[i].position;
+        Animation::animations[dead4anim].frames[1].joints[i].position = Animation::animations[dead4anim].frames[0].joints[i].position;
     }
-    Animation::animations[dead1anim].speed[0] = 0.001;
-    Animation::animations[dead2anim].speed[0] = 0.001;
-    Animation::animations[dead3anim].speed[0] = 0.001;
-    Animation::animations[dead4anim].speed[0] = 0.001;
-
-    Animation::animations[dead1anim].speed[1] = 0.001;
-    Animation::animations[dead2anim].speed[1] = 0.001;
-    Animation::animations[dead3anim].speed[1] = 0.001;
-    Animation::animations[dead4anim].speed[1] = 0.001;
-
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
-        for (j = 0; j < Animation::animations[swordsneakattackanim].numframes; j++) {
-            Animation::animations[swordsneakattackanim].position[i][j] += moveamount;
+    Animation::animations[dead1anim].frames[0].speed = 0.001;
+    Animation::animations[dead2anim].frames[0].speed = 0.001;
+    Animation::animations[dead3anim].frames[0].speed = 0.001;
+    Animation::animations[dead4anim].frames[0].speed = 0.001;
+
+    Animation::animations[dead1anim].frames[1].speed = 0.001;
+    Animation::animations[dead2anim].frames[1].speed = 0.001;
+    Animation::animations[dead3anim].frames[1].speed = 0.001;
+    Animation::animations[dead4anim].frames[1].speed = 0.001;
+
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
+            Animation::animations[swordsneakattackanim].frames[j].joints[i].position += moveamount;
         }
     }
     LoadingScreen();
-    for (j = 0; j < Animation::animations[swordsneakattackanim].numframes; j++) {
-        Animation::animations[swordsneakattackanim].weapontarget[j] += moveamount;
+    for (unsigned j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) {
+        Animation::animations[swordsneakattackanim].frames[j].weapontarget += moveamount;
     }
 
     LoadingScreen();
 
-    for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
-        for (j = 0; j < Animation::animations[swordsneakattackedanim].numframes; j++) {
-            Animation::animations[swordsneakattackedanim].position[i][j] += moveamount;
+    for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
+        for (unsigned j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) {
+            Animation::animations[swordsneakattackedanim].frames[j].joints[i].position += moveamount;
         }
     }