[Orxonox-commit 3341] r8029 - code/branches/usability/src/orxonox/gamestates

dafrick at orxonox.net dafrick at orxonox.net
Sun Mar 6 13:38:49 CET 2011


Author: dafrick
Date: 2011-03-06 13:38:49 +0100 (Sun, 06 Mar 2011)
New Revision: 8029

Modified:
   code/branches/usability/src/orxonox/gamestates/GSLevel.cc
   code/branches/usability/src/orxonox/gamestates/GSRoot.cc
   code/branches/usability/src/orxonox/gamestates/GSRoot.h
Log:
Introducing delayed starting of mainMenu if the loading of a level has failed. Probably not the smartest or cleanest implementation, so please feel free to adjust.


Modified: code/branches/usability/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSLevel.cc	2011-03-06 00:19:46 UTC (rev 8028)
+++ code/branches/usability/src/orxonox/gamestates/GSLevel.cc	2011-03-06 12:38:49 UTC (rev 8029)
@@ -45,6 +45,7 @@
 
 #include "LevelManager.h"
 #include "PlayerManager.h"
+#include "GSRoot.h"
 
 namespace orxonox
 {
@@ -155,9 +156,11 @@
         // call the loader
         COUT(0) << "Loading level..." << std::endl;
         startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
-        Loader::open(startFile_);
+        bool loaded = Loader::open(startFile_);
 
         Core::getInstance().updateLastLevelTimestamp();
+        if(!loaded)
+            GSRoot::delayedStartMainMenu();
     }
 
     void GSLevel::unloadLevel()

Modified: code/branches/usability/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSRoot.cc	2011-03-06 00:19:46 UTC (rev 8028)
+++ code/branches/usability/src/orxonox/gamestates/GSRoot.cc	2011-03-06 12:38:49 UTC (rev 8029)
@@ -37,6 +37,8 @@
 #include "tools/Timer.h"
 #include "tools/interfaces/Tickable.h"
 
+#include "GSLevel.h"
+
 namespace orxonox
 {
     DeclareGameState(GSRoot, "root", false, false);
@@ -45,6 +47,8 @@
     static const std::string __CC_setPause_name = "setPause";
     static const std::string __CC_pause_name = "pause";
 
+    /*static*/ bool GSRoot::startMainMenu_s = false;
+
     SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
     SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
     SetConsoleCommand(__CC_setPause_name,      &GSRoot::setPause     ).accessLevel(AccessLevel::Master).hide();
@@ -97,6 +101,12 @@
 
     void GSRoot::update(const Clock& time)
     {
+        if(startMainMenu_s)
+        {
+            delayedStartMainMenu();
+            startMainMenu_s = false;
+        }
+
         for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
         {
             Timer* object = *it;
@@ -174,4 +184,13 @@
         if (!GameMode::isStandalone())
             callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new);
     }
+
+    /*static*/ void GSRoot::delayedStartMainMenu(void)
+    {
+        if(!startMainMenu_s)
+            startMainMenu_s = true;
+        else
+            GSLevel::startMainMenu();
+    }
+
 }

Modified: code/branches/usability/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSRoot.h	2011-03-06 00:19:46 UTC (rev 8028)
+++ code/branches/usability/src/orxonox/gamestates/GSRoot.h	2011-03-06 12:38:49 UTC (rev 8029)
@@ -53,12 +53,15 @@
         void setPause(bool pause);
         void pause();
 
+        static void delayedStartMainMenu(void);
+
     protected:
         virtual void changedTimeFactor(float factor_new, float factor_old);
 
     private:
         bool                  bPaused_;
         float                 timeFactorPauseBackup_;
+        static bool           startMainMenu_s;
     };
 }
 




More information about the Orxonox-commit mailing list