[Orxonox-commit 3177] r7870 - in code/trunk/src: libraries/core orxonox/gamestates

landauf at orxonox.net landauf at orxonox.net
Sat Feb 12 19:24:16 CET 2011


Author: landauf
Date: 2011-02-12 19:24:16 +0100 (Sat, 12 Feb 2011)
New Revision: 7870

Modified:
   code/trunk/src/libraries/core/Core.cc
   code/trunk/src/libraries/core/Core.h
   code/trunk/src/libraries/core/GraphicsManager.cc
   code/trunk/src/orxonox/gamestates/GSLevel.cc
Log:
added feature: ogre config dialog keeps showing up on startup until the user loads a level the first time.

the reason is: if the user closes the game (or it crashes) before loading a level, there was maybe a problem with the ogre config, so we show the menu again to modify it.
if the user manages to start a level, at least the menu shows correctly, hence he can change the config in the orxonox settings from now on if needed.

Modified: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	2011-02-12 16:18:30 UTC (rev 7869)
+++ code/trunk/src/libraries/core/Core.cc	2011-02-12 18:24:16 UTC (rev 7870)
@@ -93,6 +93,8 @@
         , consoleCommandDestroyer_(ConsoleCommand::destroyAll)
         , bGraphicsLoaded_(false)
         , bStartIOConsole_(true)
+        , lastLevelTimestamp_(0)
+        , ogreConfigTimestamp_(0)
     {
         // Set the hard coded fixed paths
         this->pathConfig_.reset(new PathConfig());
@@ -220,6 +222,10 @@
             .callback(this, &Core::initRandomNumberGenerator);
         SetConfigValue(bStartIOConsole_, true)
             .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
+        SetConfigValue(lastLevelTimestamp_, 0)
+            .description("Timestamp when the last level was started.");
+        SetConfigValue(ogreConfigTimestamp_, 0)
+            .description("Timestamp when the ogre config file was changed.");
     }
 
     //! Callback function if the language has changed.
@@ -394,4 +400,14 @@
             this->graphicsManager_->postUpdate(time);
         }
     }
+
+    void Core::updateLastLevelTimestamp()
+    {
+        ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
+
+    void Core::updateOgreConfigTimestamp()
+    {
+        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
 }

Modified: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h	2011-02-12 16:18:30 UTC (rev 7869)
+++ code/trunk/src/libraries/core/Core.h	2011-02-12 18:24:16 UTC (rev 7870)
@@ -82,6 +82,14 @@
                 { return this->language_; }
             void resetLanguage();
 
+            void updateLastLevelTimestamp();
+            inline long long getLastLevelTimestamp() const
+                { return this->lastLevelTimestamp_; }
+
+            void updateOgreConfigTimestamp();
+            inline long long getOgreConfigTimestamp() const
+                { return this->ogreConfigTimestamp_; }
+
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
 
@@ -119,6 +127,8 @@
             std::string                   language_;                   //!< The language
             bool                          bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
             bool                          bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
+            long long                     lastLevelTimestamp_;         ///< Timestamp when the last level was started
+            long long                     ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
 
             static Core*                  singletonPtr_s;
     };

Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc	2011-02-12 16:18:30 UTC (rev 7869)
+++ code/trunk/src/libraries/core/GraphicsManager.cc	2011-02-12 18:24:16 UTC (rev 7870)
@@ -53,6 +53,7 @@
 #include "util/SubString.h"
 #include "ConfigValueIncludes.h"
 #include "CoreIncludes.h"
+#include "Core.h"
 #include "Game.h"
 #include "GameMode.h"
 #include "Loader.h"
@@ -302,9 +303,13 @@
     {
         CCOUT(4) << "Configuring Renderer" << std::endl;
 
-        if (!ogreRoot_->restoreConfig())
+        if (!ogreRoot_->restoreConfig() || Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp())
+        {
             if (!ogreRoot_->showConfigDialog())
                 ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled.");
+            else
+                Core::getInstance().updateOgreConfigTimestamp();
+        }
 
         CCOUT(4) << "Creating render window" << std::endl;
 

Modified: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	2011-02-12 16:18:30 UTC (rev 7869)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	2011-02-12 18:24:16 UTC (rev 7870)
@@ -35,6 +35,7 @@
 #include "core/input/InputManager.h"
 #include "core/input/InputState.h"
 #include "core/input/KeyBinderManager.h"
+#include "core/Core.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
 #include "core/GUIManager.h"
@@ -139,6 +140,8 @@
         COUT(0) << "Loading level..." << std::endl;
         startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
         Loader::open(startFile_);
+
+        Core::getInstance().updateLastLevelTimestamp();
     }
 
     void GSLevel::unloadLevel()




More information about the Orxonox-commit mailing list