]> git.jsancho.org Git - lugaru.git/commitdiff
Moved visibleloading check inside LoadingScreen
authorCôme Chilliet <come@chilliet.eu>
Fri, 16 Dec 2016 22:56:00 +0000 (23:56 +0100)
committerCôme Chilliet <come@chilliet.eu>
Fri, 16 Dec 2016 22:56:00 +0000 (23:56 +0100)
Source/Animation/Animation.cpp
Source/Animation/Skeleton.cpp
Source/Environment/Terrain.cpp
Source/Environment/Terrain.hpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/Graphic/Models.cpp
Source/Menu/Menu.cpp
Source/Utils/ImageIO.cpp
Source/main.cpp

index 89aa9f4da02f6a671b878c935f71e6eb239b85aa..8ee1fd662ea0b171008980a2f0df62af506ed520 100644 (file)
@@ -23,8 +23,6 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include "Game.hpp"
 #include "Utils/Folders.hpp"
 
-extern bool visibleloading;
-
 std::vector<Animation> Animation::animations;
 
 void Animation::loadAll()
@@ -99,8 +97,7 @@ Animation::Animation(const std::string& filename, anim_height_type aheight, anim
     height = aheight;
     attack = aattack;
 
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     // read file in binary mode
     tfile = Folders::openMandatoryFile( filepath, "rb" );
index a098b1a4d2d8316dc8b50fc33f45d231deeaaa39..014117c5410fd7c8527e8ca244e404f946ded850 100644 (file)
@@ -37,8 +37,6 @@ extern int detail;
 extern int whichjointstartarray[26];
 extern int whichjointendarray[26];
 
-extern bool visibleloading;
-
 Skeleton::Skeleton() :
     selected(0),
     id(0),
index 98828fdef1573de01f9c2fab6967e5911babbed1..ba4e24024b397447b91ea4a6e65ac04e7dea22a3 100644 (file)
@@ -38,7 +38,6 @@ extern int detail;
 extern bool decals;
 extern float blurness;
 extern float targetblurness;
-extern bool visibleloading;
 extern bool skyboxtexture;
 
 //Functions
@@ -426,8 +425,7 @@ bool Terrain::load(const std::string& fileName)
         }
     }
     texture.bpp = 24;
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     texdetail = temptexdetail;
 
@@ -439,8 +437,7 @@ bool Terrain::load(const std::string& fileName)
         }
     }
 
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     float slopeness;
 
@@ -449,8 +446,7 @@ bool Terrain::load(const std::string& fileName)
             textureness[i][j] = -1;
         }
     }
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
 
     for (i = 0; i < size; i++) {
@@ -499,8 +495,7 @@ bool Terrain::load(const std::string& fileName)
             }
         }
     }
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     for (i = 0; i < size; i++) {
         for (j = 0; j < size; j++) {
@@ -512,8 +507,7 @@ bool Terrain::load(const std::string& fileName)
             }
         }
     }
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     for (i = 0; i < size; i++) {
         for (j = 0; j < size; j++) {
@@ -638,8 +632,7 @@ bool Terrain::load(const std::string& fileName)
             }
         }
     }
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     patch_size = size / subdivision;
     patch_elements = (patch_size) * (patch_size) * 54;
@@ -732,7 +725,9 @@ void Terrain::drawpatch(int whichx, int whichy, float opacity)
         glEnable(GL_BLEND);
         UpdateTransparency(whichx, whichy);
     }
+
     glColor4f(1, 1, 1, 1);
+
     //Set up vertex array
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_COLOR_ARRAY);
@@ -756,7 +751,9 @@ void Terrain::drawpatchother(int whichx, int whichy, float opacity)
         UpdateTransparency(whichx, whichy);
     }
     UpdateTransparencyother(whichx, whichy);
+
     glColor4f(1, 1, 1, 1);
+
     //Set up vertex array
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_COLOR_ARRAY);
@@ -1394,8 +1391,7 @@ void Terrain::DoShadows()
                         }
                     }
                 }
-                if (visibleloading)
-                    Game::LoadingScreen();
+                Game::LoadingScreen();
             }
             brightness = dotproduct(&lightloc, &normals[i][j]);
             if (shadowed)
@@ -1419,8 +1415,7 @@ void Terrain::DoShadows()
         }
     }
 
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     //Smooth shadows
     for (i = 0; i < size; i++) {
index 097cdbd375f2bfa28a13edf44be6abfb6672dd96..444a47bf2212ff81df2bdacfcae399a197db447e 100644 (file)
@@ -113,19 +113,21 @@ public:
     XYZ getLighting(float pointx, float pointz);
     XYZ getNormal(float pointx, float pointz);
     void UpdateVertexArray(int whichx, int whichy);
-    void UpdateTransparency(int whichx, int whichy);
-    void UpdateTransparencyother(int whichx, int whichy);
-    void UpdateTransparencyotherother(int whichx, int whichy);
     bool load(const std::string& fileName);
     void CalculateNormals();
     void drawdecals();
     void draw(int layer);
-    void drawpatch(int whichx, int whichy, float opacity);
-    void drawpatchother(int whichx, int whichy, float opacity);
-    void drawpatchotherother(int whichx, int whichy, float opacity);
     void DoShadows();
 
     Terrain();
+
+private:
+    void drawpatch(int whichx, int whichy, float opacity);
+    void drawpatchother(int whichx, int whichy, float opacity);
+    void drawpatchotherother(int whichx, int whichy, float opacity);
+    void UpdateTransparency(int whichx, int whichy);
+    void UpdateTransparencyother(int whichx, int whichy);
+    void UpdateTransparencyotherother(int whichx, int whichy);
 };
 
 #endif
index 5e6ce040c9d95e197e7cd79186f10398e8b18105..d6173f51acdb64e1e59bfe23a5d7484647df07f4 100644 (file)
@@ -174,6 +174,10 @@ GLvoid Game::ReSizeGLScene(float fov, float pnear)
 
 void Game::LoadingScreen()
 {
+    if (!visibleloading) {
+        return;
+    }
+
     static float loadprogress;
     static AbsoluteTime frametime = {0, 0};
     AbsoluteTime currTime = UpTime ();
@@ -652,9 +656,9 @@ void Game::LoadStuff()
 
     stillloading = 1;
 
-    visibleloading = 0; //don't use loadscreentexture yet
+    visibleloading = false; //don't use loadscreentexture yet
     loadscreentexture.load("Textures/Fire.jpg", 1);
-    visibleloading = 1;
+    visibleloading = true;
 
     temptexdetail = texdetail;
     texdetail = 1;
@@ -872,6 +876,6 @@ void Game::LoadStuff()
     loading = 0;
     changedelay = 1;
 
-    visibleloading = 0;
+    visibleloading = false;
 }
 
index c8b61cae073683a6df734fc9587cf989aad263c4..a400c22321826144d3cb1db681c1c42408d54e67 100644 (file)
@@ -566,9 +566,9 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
     LOG(std::string("Loading level...") + name);
 
     if (!gameon)
-        visibleloading = 1;
+        visibleloading = true;
     if (stealthloading)
-        visibleloading = 0;
+        visibleloading = false;
     if (!stillloading)
         loadtime = 0;
     gamestarted = 1;
@@ -663,8 +663,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
                 terrain.patchobjectnum[i][j] = 0;
             }
         }
-        if (visibleloading)
-            LoadingScreen();
+        Game::LoadingScreen();
     }
 
     weapons.clear();
@@ -721,8 +720,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
             weapons.push_back(Weapon(type, 0));
         }
 
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     funpackf(tfile, "Bf Bf Bf", &Person::players[0]->armorhead, &Person::players[0]->armorhigh, &Person::players[0]->armorlow);
     funpackf(tfile, "Bf Bf Bf", &Person::players[0]->protectionhead, &Person::players[0]->protectionhigh, &Person::players[0]->protectionlow);
@@ -781,20 +779,14 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
         Hotspot::hotspots.clear();
     }
 
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     if (!stealthloading) {
         Object::ComputeCenter();
-
-        if (visibleloading)
-            LoadingScreen();
-
         Object::ComputeRadius();
     }
 
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     int numplayers;
     funpackf(tfile, "Bi", &numplayers);
@@ -810,8 +802,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
             cerr << "Invalid Person found in " << name << endl;
         }
     }
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     funpackf(tfile, "Bi", &numpathpoints);
     if (numpathpoints > 30 || numpathpoints < 0)
@@ -822,8 +813,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
             funpackf(tfile, "Bi", &pathpointconnect[j][k]);
         }
     }
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     funpackf(tfile, "Bf Bf Bf Bf", &mapcenter.x, &mapcenter.y, &mapcenter.z, &mapradius);
 
@@ -835,18 +825,15 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
     if (!stealthloading) {
         Object::AddObjectsToTerrain();
         terrain.DoShadows();
-        if (visibleloading)
-            LoadingScreen();
+        Game::LoadingScreen();
         Object::DoShadows();
-        if (visibleloading)
-            LoadingScreen();
+        Game::LoadingScreen();
     }
 
     fclose(tfile);
 
     for (unsigned i = 0; i < Person::players.size(); i++) {
-        if (visibleloading)
-            LoadingScreen();
+        Game::LoadingScreen();
         if (i == 0) {
             Person::players[i]->burnt = 0;
             Person::players[i]->bled = 0;
@@ -901,8 +888,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
         }
 
 
-        if (visibleloading)
-            LoadingScreen();
+        Game::LoadingScreen();
 
         if (cellophane) {
             Person::players[i]->proportionhead.z = 0;
@@ -968,8 +954,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
     hawkcoords = Person::players[0]->coords;
     hawkcoords.y += 30;
 
-    if (visibleloading)
-        LoadingScreen();
+    Game::LoadingScreen();
 
     LOG("Starting background music...");
 
@@ -993,7 +978,7 @@ void Game::Loadlevel(const std::string& name, bool tutorial)
 
     leveltime = 0;
     wonleveltime = 0;
-    visibleloading = 0;
+    visibleloading = false;
 }
 
 void doDevKeys()
@@ -5618,7 +5603,7 @@ void Game::TickOnceAfter()
                         LoadStuff();
                     whichchoice = 0;
                     actuallevel = campaignlevels[actuallevel].nextlevel.front();
-                    visibleloading = 1;
+                    visibleloading = true;
                     stillloading = 1;
                     Loadlevel(campaignlevels[actuallevel].mapname.c_str());
                     campaign = 1;
index df62ea9381c1c6aba02a7d5de59688b457e92c0f..7184ce2f887d3b0021714f7fec1f997dd76d40db 100644 (file)
@@ -25,7 +25,7 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include <SDL.h>
 #include <string>
 
-bool visibleloading = 0;
+bool visibleloading = false;
 
 float volume = 0;
 bool ismotionblur = false;
index 1e5947277b70d4fb2ed0a0ca3794d0191bafbd1e..4120864b74146e015f0b4830462cfc40e908a759 100644 (file)
@@ -30,8 +30,6 @@ extern float fadestart;
 extern float texdetail;
 extern bool decals;
 
-extern bool visibleloading;
-
 int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 {
     static int j;
@@ -474,8 +472,7 @@ bool Model::load(const std::string& filename, bool texture )
 
     LOG(std::string("Loading model...") + filename);
 
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
 
     type = normaltype;
     color = 0;
@@ -819,8 +816,7 @@ void Model::Rotate(float xang, float yang, float zang)
 
 void Model::CalculateNormals(bool facenormalise)
 {
-    if (visibleloading)
-        Game::LoadingScreen();
+    Game::LoadingScreen();
     static int i;
     if (type != normaltype && type != decalstype)
         return;
index bac46a622c935dd2509a646980f5bb6ffa90be55..54f6fc519478c0c23d3074d0810e794fd65ececf 100644 (file)
@@ -712,7 +712,7 @@ void Menu::Tick()
                     LoadStuff();
                 whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
                 actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
-                visibleloading = 1;
+                visibleloading = true;
                 stillloading = 1;
                 Loadlevel(campaignlevels[actuallevel].mapname.c_str());
                 campaign = 1;
index 508c10f54247a9d57412bbdc7c16f7c0e7daed88..95f89544c26b062c5751faa1dd310b2fa4d6c4cd 100644 (file)
@@ -28,8 +28,6 @@ along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
 #include <stdio.h>
 #include <zlib.h>
 
-extern bool visibleloading;
-
 /* These two are needed for screenshot */
 extern int kContextWidth;
 extern int kContextHeight;
@@ -51,9 +49,7 @@ ImageRec::~ImageRec()
 
 bool load_image(const char *file_name, ImageRec &tex)
 {
-    if (visibleloading) {
-        Game::LoadingScreen();
-    }
+    Game::LoadingScreen();
 
     if ( tex.data == NULL ) {
         return false;
index 8463907b00b2aee8a91d2c3c2117f3a77546b76f..1ee05a5b0494cb53940c7f3f4f9fed7582a51547 100644 (file)
@@ -53,7 +53,6 @@ extern int mainmenu;
 
 extern float slomospeed;
 extern float slomofreq;
-extern bool visibleloading;
 
 extern int difficulty;