X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=c070d293872a430e7b922908e5adb8cedcec805e;hb=bdabd9d4a53be2fa9d90f900f7e5949d2f0ef75c;hp=4a700b37567b6f4ebf4b72be76ab394bb8bdf137;hpb=71a5b4590a18bf663b97b8a52078754899dcf345;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 4a700b3..c070d29 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -20,9 +20,10 @@ along with Lugaru. If not, see . #include "Game.h" #include "openal_wrapper.h" -#include "Animation.h" +#include "Animation/Animation.h" #include "Texture.h" #include "Utils/Folders.h" +#include "Menu.h" extern float screenwidth, screenheight; extern float viewdistance; @@ -56,7 +57,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 +78,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(); @@ -134,7 +134,7 @@ void Game::deleteGame() -void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize) +void LoadSave(const std::string& fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize) { LOGFUNC; @@ -146,7 +146,10 @@ void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *arr //Load Image ImageRec texture; - load_image(Folders::getResourcePath(fileName).c_str(), texture); + if (!load_image(Folders::getResourcePath(fileName).c_str(), texture)) { + texdetail = temptexdetail; + return; + } texdetail = temptexdetail; int bytesPerPixel = texture.bpp / 8; @@ -454,7 +457,7 @@ void Game::InitGame() numchallengelevels = 14; - accountactive = Account::loadFile(Folders::getUserDataPath()+"/users"); + Account::loadFile(Folders::getUserDataPath()+"/users"); whichjointstartarray[0] = righthip; whichjointendarray[0] = rightfoot; @@ -624,7 +627,9 @@ void Game::InitGame() newscreenwidth = screenwidth; newscreenheight = screenheight; - LoadMenu(); + Menu::Load(); + + Animation::loadAll(); } @@ -699,14 +704,14 @@ void Game::LoadStuff() Weapon::lightbloodswordtextureptr.load("Textures/SwordBloodLight.jpg", 1); Weapon::stafftextureptr.load("Textures/Staff.jpg", 1); - Weapon::throwingknifemodel.load((char *)"Models/ThrowingKnife.solid", 1); + Weapon::throwingknifemodel.load("Models/ThrowingKnife.solid", 1); Weapon::throwingknifemodel.Scale(.001, .001, .001); Weapon::throwingknifemodel.Rotate(90, 0, 0); Weapon::throwingknifemodel.Rotate(0, 90, 0); Weapon::throwingknifemodel.flat = 0; Weapon::throwingknifemodel.CalculateNormals(1); - Weapon::swordmodel.load((char *)"Models/Sword.solid", 1); + Weapon::swordmodel.load("Models/Sword.solid", 1); Weapon::swordmodel.Scale(.001, .001, .001); Weapon::swordmodel.Rotate(90, 0, 0); Weapon::swordmodel.Rotate(0, 90, 0); @@ -714,7 +719,7 @@ void Game::LoadStuff() Weapon::swordmodel.flat = 1; Weapon::swordmodel.CalculateNormals(1); - Weapon::staffmodel.load((char *)"Models/Staff.solid", 1); + Weapon::staffmodel.load("Models/Staff.solid", 1); Weapon::staffmodel.Scale(.005, .005, .005); Weapon::staffmodel.Rotate(90, 0, 0); Weapon::staffmodel.Rotate(0, 90, 0); @@ -785,7 +790,7 @@ void Game::LoadStuff() viewer.x = terrain.size / 2 * terrain.scale; viewer.z = terrain.size / 2 * terrain.scale; - hawk.load((char *)"Models/Hawk.solid", 1); + hawk.load("Models/Hawk.solid", 1); hawk.Scale(.03, .03, .03); hawk.Rotate(90, 1, 1); hawk.CalculateNormals(0); @@ -794,15 +799,15 @@ void Game::LoadStuff() hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7; hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25; - eye.load((char *)"Models/Eye.solid", 1); + eye.load("Models/Eye.solid", 1); eye.Scale(.03, .03, .03); eye.CalculateNormals(0); - cornea.load((char *)"Models/Cornea.solid", 1); + cornea.load("Models/Cornea.solid", 1); cornea.Scale(.03, .03, .03); cornea.CalculateNormals(0); - iris.load((char *)"Models/Iris.solid", 1); + iris.load("Models/Iris.solid", 1); iris.Scale(.03, .03, .03); iris.CalculateNormals(0); @@ -816,58 +821,59 @@ void Game::LoadStuff() firstload = 0; - loadAllAnimations(); //Fix knife stab, too lazy to do it manually XYZ moveamount; moveamount = 0; moveamount.z = 2; - for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) { - for (j = 0; j < animation[knifesneakattackanim].numframes; j++) { - animation[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 (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) { + for (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[knifesneakattackedanim].numframes; j++) { - animation[knifesneakattackedanim].position[i][j] += moveamount; + for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) { + for (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[dead1anim].position[i][1] = animation[dead1anim].position[i][0]; - animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0]; - animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0]; - animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0]; + for (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[dead1anim].speed[0] = 0.001; - animation[dead2anim].speed[0] = 0.001; - animation[dead3anim].speed[0] = 0.001; - animation[dead4anim].speed[0] = 0.001; - - animation[dead1anim].speed[1] = 0.001; - animation[dead2anim].speed[1] = 0.001; - animation[dead3anim].speed[1] = 0.001; - animation[dead4anim].speed[1] = 0.001; - - for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) { - for (j = 0; j < animation[swordsneakattackanim].numframes; j++) { - animation[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 (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) { + for (j = 0; j < Animation::animations[swordsneakattackanim].frames.size(); j++) { + Animation::animations[swordsneakattackanim].frames[j].joints[i].position += moveamount; } } LoadingScreen(); - for (j = 0; j < animation[swordsneakattackanim].numframes; j++) { - animation[swordsneakattackanim].weapontarget[j] += moveamount; + for (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[swordsneakattackedanim].numframes; j++) { - animation[swordsneakattackedanim].position[i][j] += moveamount; + for (i = 0; i < Person::players[0]->skeleton.joints.size(); i++) { + for (j = 0; j < Animation::animations[swordsneakattackedanim].frames.size(); j++) { + Animation::animations[swordsneakattackedanim].frames[j].joints[i].position += moveamount; } }