[Orxonox-commit 713] r3245 - in branches/core4/src: core orxonox orxonox/gamestates

rgrieder at orxonox.net rgrieder at orxonox.net
Mon Jun 29 13:32:40 CEST 2009


Author: rgrieder
Date: 2009-06-29 13:32:40 +0200 (Mon, 29 Jun 2009)
New Revision: 3245

Modified:
   branches/core4/src/core/CMakeLists.txt
   branches/core4/src/core/Game.cc
   branches/core4/src/core/Game.h
   branches/core4/src/orxonox/CMakeLists.txt
   branches/core4/src/orxonox/LevelManager.cc
   branches/core4/src/orxonox/LevelManager.h
   branches/core4/src/orxonox/gamestates/GSLevel.cc
   branches/core4/src/orxonox/gamestates/GSLevel.h
   branches/core4/src/orxonox/gamestates/GSMainMenu.cc
   branches/core4/src/orxonox/gamestates/GSRoot.cc
   branches/core4/src/orxonox/gamestates/GSRoot.h
Log:
Moved Game::getLevel to LevelManager::getStartLevel and Game::setLevel to LevelManager::setStartLevel.

Modified: branches/core4/src/core/CMakeLists.txt
===================================================================
--- branches/core4/src/core/CMakeLists.txt	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/core/CMakeLists.txt	2009-06-29 11:32:40 UTC (rev 3245)
@@ -67,7 +67,6 @@
   FIND_HEADER_FILES
   TOLUA_FILES
     CommandExecutor.h
-    Game.h
     LuaBind.h
   DEFINE_SYMBOL
     "CORE_SHARED_BUILD"

Modified: branches/core4/src/core/Game.cc
===================================================================
--- branches/core4/src/core/Game.cc	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/core/Game.cc	2009-06-29 11:32:40 UTC (rev 3245)
@@ -148,25 +148,8 @@
             .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
         SetConfigValue(statisticsAvgLength_, 1000000)
             .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
-        SetConfigValue(levelName_, "presentation_dm.oxw")
-            .description("Sets the preselection of the level in the main menu.");
     }
 
-    void Game::setLevel(std::string levelName)
-    {
-        ModifyConfigValue(levelName_, set, levelName);
-    }
-
-    std::string Game::getLevel()
-    {
-        std::string levelName;
-        CommandLine::getValue("level", &levelName);
-        if (levelName == "")
-            return levelName_;
-        else
-            return levelName;
-    }
-
     /**
     @brief
         Main loop of the orxonox game.

Modified: branches/core4/src/core/Game.h
===================================================================
--- branches/core4/src/core/Game.h	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/core/Game.h	2009-06-29 11:32:40 UTC (rev 3245)
@@ -63,12 +63,8 @@
     @brief
         Main class responsible for running the game.
     */
-    class _CoreExport Game
-    // tolua_end
-        : public OrxonoxClass
-    // tolua_begin
+    class _CoreExport Game : public OrxonoxClass
     {
-    //tolua_end
     public:
         Game(int argc, char** argv);
         ~Game();
@@ -93,11 +89,8 @@
 
         template <class T>
         static bool declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bConsoleMode);
-        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; } //tolua_export
+        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
 
-        void setLevel(std::string levelName); //tolua_export
-        std::string getLevel(); //tolua_export
-
     private:
         class _CoreExport GameStateFactory
         {
@@ -162,11 +155,10 @@
         // config values
         unsigned int                    statisticsRefreshCycle_;
         unsigned int                    statisticsAvgLength_;
-        std::string                     levelName_;
 
         static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
         static Game* singletonRef_s;        //!< Pointer to the Singleton
-    }; // tolua_export
+    };
 
     template <class T>
     /*static*/ bool Game::declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bGraphicsMode)
@@ -192,6 +184,6 @@
         // just a required dummy return value
         return true;
     }
-} // tolua_export
+}
 
 #endif /* _Game_H__ */

Modified: branches/core4/src/orxonox/CMakeLists.txt
===================================================================
--- branches/core4/src/orxonox/CMakeLists.txt	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/CMakeLists.txt	2009-06-29 11:32:40 UTC (rev 3245)
@@ -41,6 +41,7 @@
 ORXONOX_ADD_EXECUTABLE(orxonox
   FIND_HEADER_FILES
   TOLUA_FILES
+    LevelManager.h
     gui/GUIManager.h
     objects/pickup/BaseItem.h
     objects/pickup/PickupInventory.h

Modified: branches/core4/src/orxonox/LevelManager.cc
===================================================================
--- branches/core4/src/orxonox/LevelManager.cc	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/LevelManager.cc	2009-06-29 11:32:40 UTC (rev 3245)
@@ -29,6 +29,10 @@
 #include "LevelManager.h"
 
 #include <map>
+
+#include "core/CommandLine.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
 #include "PlayerManager.h"
 #include "objects/Level.h"
 #include "objects/infos/HumanPlayer.h"
@@ -41,6 +45,15 @@
     {
         assert(singletonRef_s == 0);
         singletonRef_s = this;
+
+        RegisterRootObject(LevelManager);
+        this->setConfigValues();
+
+        // check override
+        if (!CommandLine::getArgument("level")->hasDefaultValue())
+        {
+            ModifyConfigValue(startLevelName_, tset, CommandLine::getValue("mediaPath").getString());
+        }
     }
 
     LevelManager::~LevelManager()
@@ -49,6 +62,12 @@
         singletonRef_s = 0;
     }
 
+    void LevelManager::setConfigValues()
+    {
+        SetConfigValue(startLevelName_, "presentation_dm.oxw")
+            .description("Sets the preselection of the level in the main menu.");
+    }
+
     void LevelManager::requestActivity(Level* level)
     {
         this->levels_s.push_back(level);
@@ -92,4 +111,14 @@
                 this->levels_s.front()->playerEntered(it->second);
         }
     }
+
+    void LevelManager::setStartLevel(const std::string& levelName)
+    {
+        ModifyConfigValue(startLevelName_, set, levelName);
+    }
+
+    const std::string& LevelManager::getStartLevel()
+    {
+        return startLevelName_;
+    }
 }

Modified: branches/core4/src/orxonox/LevelManager.h
===================================================================
--- branches/core4/src/orxonox/LevelManager.h	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/LevelManager.h	2009-06-29 11:32:40 UTC (rev 3245)
@@ -33,21 +33,30 @@
 
 #include <cassert>
 #include <list>
+#include "core/OrxonoxClass.h"
 
+// tolua_begin
 namespace orxonox
 {
     class _OrxonoxExport LevelManager
-    {
+    // tolua_end
+        : public OrxonoxClass
+    { // tolua_export
         public:
             LevelManager();
             virtual ~LevelManager();
 
+            void setConfigValues();
+
             void requestActivity(Level* level);
             void releaseActivity(Level* level);
             Level* getActiveLevel();
 
+            void setStartLevel(const std::string& levelName); //tolua_export
+            const std::string& getStartLevel(); //tolua_export
+
             static LevelManager* getInstancePtr() { return singletonRef_s; }
-            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
 
         private:
             LevelManager(const LevelManager&);
@@ -56,8 +65,11 @@
 
             std::list<Level*> levels_s;
 
+            // config values
+            std::string startLevelName_;
+
             static LevelManager* singletonRef_s;
-    };
-}
+    }; // tolua_export
+} // tolua_export
 
 #endif /* _LevelManager_H__ */

Modified: branches/core4/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSLevel.cc	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/gamestates/GSLevel.cc	2009-06-29 11:32:40 UTC (rev 3245)
@@ -70,7 +70,6 @@
         , guiKeysOnlyInputState_(0)
         , radar_(0)
         , cameraManager_(0)
-        , levelManager_(0)
     {
         RegisterObject(GSLevel);
 
@@ -119,9 +118,6 @@
 
         if (GameMode::isMaster())
         {
-            // create the global LevelManager
-            this->levelManager_ = new LevelManager();
-
             this->loadLevel();
         }
 
@@ -201,12 +197,6 @@
             this->cameraManager_ = 0;
         }
 
-        if (this->levelManager_)
-        {
-            delete this->levelManager_;
-            this->levelManager_ = 0;
-        }
-
         if (this->playerManager_)
         {
             delete this->playerManager_;
@@ -254,7 +244,7 @@
         std::string levelName;
         CommandLine::getValue("level", &levelName);
         if (levelName == "")
-            startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + Game::getInstance().getLevel());
+            startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + LevelManager::getInstance().getStartLevel());
         else
             startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
         Loader::open(startFile_s);

Modified: branches/core4/src/orxonox/gamestates/GSLevel.h
===================================================================
--- branches/core4/src/orxonox/gamestates/GSLevel.h	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/gamestates/GSLevel.h	2009-06-29 11:32:40 UTC (rev 3245)
@@ -67,7 +67,6 @@
         SimpleInputState*     guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
         Radar*                radar_;                   //!< represents the Radar (not the HUD part)
         CameraManager*        cameraManager_;           //!< camera manager for this level
-        LevelManager*         levelManager_;            //!< global level manager
         PlayerManager*        playerManager_;           //!< player manager for this level
         QuestManager*         questManager_;
         NotificationManager*  notificationManager_;

Modified: branches/core4/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSMainMenu.cc	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/gamestates/GSMainMenu.cc	2009-06-29 11:32:40 UTC (rev 3245)
@@ -66,7 +66,7 @@
         this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
 
         // show main menu
-        GUIManager::getInstance().showGUI("mainmenu_2");
+        GUIManager::getInstance().showGUI("mainmenu_3");
         GUIManager::getInstance().setCamera(this->camera_);
         GraphicsManager::getInstance().setCamera(this->camera_);
 

Modified: branches/core4/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- branches/core4/src/orxonox/gamestates/GSRoot.cc	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/gamestates/GSRoot.cc	2009-06-29 11:32:40 UTC (rev 3245)
@@ -36,6 +36,7 @@
 #include "tools/Timer.h"
 #include "interfaces/TimeFactorListener.h"
 #include "interfaces/Tickable.h"
+#include "LevelManager.h"
 
 namespace orxonox
 {
@@ -82,6 +83,9 @@
             CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
         }
 
+        // create the global LevelManager
+        this->levelManager_ = new LevelManager();
+
         // Load level directly?
         bool loadLevel = false;
         if (CommandLine::getValue("standalone").getBool())
@@ -128,6 +132,8 @@
             this->ccPause_ = 0;
         }
 */
+
+        delete this->levelManager_;
     }
 
     void GSRoot::update(const Clock& time)

Modified: branches/core4/src/orxonox/gamestates/GSRoot.h
===================================================================
--- branches/core4/src/orxonox/gamestates/GSRoot.h	2009-06-28 21:23:24 UTC (rev 3244)
+++ branches/core4/src/orxonox/gamestates/GSRoot.h	2009-06-29 11:32:40 UTC (rev 3245)
@@ -51,10 +51,12 @@
         float getTimeFactor() { return this->timeFactor_; }
 
     private:
-        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
+        float                 timeFactor_;              //!< A factor that sets the gamespeed. 1 is normal.
         bool                  bPaused_;
         float                 timeFactorPauseBackup_;
 
+        LevelManager*         levelManager_;            //!< global level manager
+
         // console commands
         ConsoleCommand*       ccSetTimeFactor_;
         ConsoleCommand*       ccPause_;




More information about the Orxonox-commit mailing list