[Orxonox-commit 823] r3343 - in branches/resource/src: core orxonox orxonox/gamestates

rgrieder at orxonox.net rgrieder at orxonox.net
Fri Jul 24 16:25:33 CEST 2009


Author: rgrieder
Date: 2009-07-24 16:25:33 +0200 (Fri, 24 Jul 2009)
New Revision: 3343

Modified:
   branches/resource/src/core/Core.cc
   branches/resource/src/core/Core.h
   branches/resource/src/core/GameMode.h
   branches/resource/src/orxonox/LevelManager.cc
   branches/resource/src/orxonox/OrxonoxPrecompiledHeaders.h
   branches/resource/src/orxonox/gamestates/GSGraphics.cc
Log:
Expanded Core class by loadGraphics and unloadGraphics which don't do anything at the moment.

Modified: branches/resource/src/core/Core.cc
===================================================================
--- branches/resource/src/core/Core.cc	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/core/Core.cc	2009-07-24 14:25:33 UTC (rev 3343)
@@ -67,6 +67,7 @@
 #include "ConfigValueIncludes.h"
 #include "CoreIncludes.h"
 #include "Factory.h"
+#include "GameMode.h"
 #include "Identifier.h"
 #include "Language.h"
 #include "LuaBind.h"
@@ -229,6 +230,7 @@
 
 
     Core::Core(const std::string& cmdLine)
+        : bGraphicsLoaded_(false)
     {
         if (singletonRef_s != 0)
         {
@@ -314,7 +316,7 @@
 
         // Destroy command line arguments
         CommandLine::destroyAllArguments();
-        // Also delete external console command that don't belong to an Identifier
+        // Also delete external console commands that don't belong to an Identifier
         CommandExecutor::destroyExternalCommands();
         // Clean up class hierarchy stuff (identifiers, XMLPort, configValues, consoleCommand)
         Identifier::destroyAllIdentifiers();
@@ -324,6 +326,24 @@
         // Don't assign singletonRef_s with NULL! Recreation is not supported
     }
 
+    void Core::loadGraphics()
+    {
+        if (bGraphicsLoaded_)
+            return;
+
+        GameMode::setShowsGraphics(true);
+        bGraphicsLoaded_ = true;
+    }
+
+    void Core::unloadGraphics()
+    {
+        if (!bGraphicsLoaded_)
+            return;
+
+        bGraphicsLoaded_ = false;
+        GameMode::setShowsGraphics(false);
+    }
+
     /**
         @brief Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
         @param device The device

Modified: branches/resource/src/core/Core.h
===================================================================
--- branches/resource/src/core/Core.h	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/core/Core.h	2009-07-24 14:25:33 UTC (rev 3343)
@@ -72,6 +72,9 @@
 
             void update(const Clock& time);
 
+            void loadGraphics();
+            void unloadGraphics();
+
             static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
 
             static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
@@ -110,7 +113,8 @@
             TclBind*              tclBind_;
             TclThreadManager*     tclThreadManager_;
 
-            bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
+            bool                  isDevBuild_;          //!< True for builds in the build directory (not installed)
+            bool                  bGraphicsLoaded_;
             CoreConfiguration*    configuration_;
 
             static Core* singletonRef_s;

Modified: branches/resource/src/core/GameMode.h
===================================================================
--- branches/resource/src/core/GameMode.h	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/core/GameMode.h	2009-07-24 14:25:33 UTC (rev 3343)
@@ -40,23 +40,27 @@
 {
     class _CoreExport GameMode
     {
+        friend class Core;
+
         public:
             static bool showsGraphics() { return bShowsGraphics_s; }
             static bool hasServer()     { return bHasServer_s; }
             static bool isClient()      { return bIsClient_s; }
             static bool isStandalone()  { return bIsStandalone_s; }
             static bool isMaster()      { return bIsMaster_s; }
-            static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
+
             static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
             static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
             static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
-            static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
 
         private:
             GameMode();
             GameMode(const GameMode& inst);
             ~GameMode();
 
+            static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
+            static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
+
             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
             static bool bHasServer_s;                       //!< global variable that tells whether this is a server
             static bool bIsClient_s;

Modified: branches/resource/src/orxonox/LevelManager.cc
===================================================================
--- branches/resource/src/orxonox/LevelManager.cc	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/orxonox/LevelManager.cc	2009-07-24 14:25:33 UTC (rev 3343)
@@ -33,6 +33,7 @@
 
 #include "core/CommandLine.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/Core.h"
 #include "core/CoreIncludes.h"
 #include "core/Loader.h"
 #include "PlayerManager.h"

Modified: branches/resource/src/orxonox/OrxonoxPrecompiledHeaders.h
===================================================================
--- branches/resource/src/orxonox/OrxonoxPrecompiledHeaders.h	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/orxonox/OrxonoxPrecompiledHeaders.h	2009-07-24 14:25:33 UTC (rev 3343)
@@ -89,9 +89,8 @@
 #include "core/BaseObject.h"
 //#include "core/ConfigValueIncludes.h" // 19
 //#include "core/ConsoleCommand.h" // 15
-#include "core/Core.h"
+//#include "core/Core.h" // ?, but not many times
 #include "core/CoreIncludes.h"
-#include "core/GameMode.h"
 #include "core/XMLPort.h"
 
 #include "network/synchronisable/Synchronisable.h"

Modified: branches/resource/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- branches/resource/src/orxonox/gamestates/GSGraphics.cc	2009-07-24 12:14:24 UTC (rev 3342)
+++ branches/resource/src/orxonox/gamestates/GSGraphics.cc	2009-07-24 14:25:33 UTC (rev 3343)
@@ -92,7 +92,8 @@
     */
     void GSGraphics::activate()
     {
-        GameMode::setShowsGraphics(true);
+        // Load OGRE, CEGUI and OIS
+        Core::getInstance().loadGraphics();
 
         // Load OGRE including the render window
         this->graphicsManager_ = new GraphicsManager();
@@ -169,7 +170,8 @@
 
         delete graphicsManager_;
 
-        GameMode::setShowsGraphics(false);
+        // Unload OGRE, CEGUI and OIS
+        Core::getInstance().loadGraphics();
     }
 
     /**




More information about the Orxonox-commit mailing list