[Orxonox-commit 1121] r5842 - in code/branches/core5/src: modules orxonox orxonox/gamestates

rgrieder at orxonox.net rgrieder at orxonox.net
Wed Sep 30 18:13:10 CEST 2009


Author: rgrieder
Date: 2009-09-30 18:13:09 +0200 (Wed, 30 Sep 2009)
New Revision: 5842

Added:
   code/branches/core5/src/orxonox/gamestates/
   code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
   code/branches/core5/src/orxonox/gamestates/GSLevel.cc
Removed:
   code/branches/core5/src/modules/gamestates/
   code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
   code/branches/core5/src/orxonox/gamestates/GSLevel.cc
   code/branches/core5/src/orxonox/gamestates/GameStatesPrecompiledHeaders.h
   code/branches/core5/src/orxonox/gamestates/GameStatesPrereqs.h
Modified:
   code/branches/core5/src/modules/CMakeLists.txt
   code/branches/core5/src/orxonox/CMakeLists.txt
   code/branches/core5/src/orxonox/gamestates/CMakeLists.txt
   code/branches/core5/src/orxonox/gamestates/GSClient.h
   code/branches/core5/src/orxonox/gamestates/GSDedicated.h
   code/branches/core5/src/orxonox/gamestates/GSGraphics.h
   code/branches/core5/src/orxonox/gamestates/GSIOConsole.h
   code/branches/core5/src/orxonox/gamestates/GSLevel.h
   code/branches/core5/src/orxonox/gamestates/GSMainMenu.h
   code/branches/core5/src/orxonox/gamestates/GSRoot.h
   code/branches/core5/src/orxonox/gamestates/GSServer.h
   code/branches/core5/src/orxonox/gamestates/GSStandalone.h
Log:
Moved GameStates back to the orxonox library. This resolves an issue at startup if the command line arguments contained errors. Furthermore you can now simply not build the modules folder and still get a working orxonox.

DELETE ALL "libgamestates*" FILES (esp. in the modules output folder) to avoid problems with duplicate libraries!!!

Modified: code/branches/core5/src/modules/CMakeLists.txt
===================================================================
--- code/branches/core5/src/modules/CMakeLists.txt	2009-09-30 11:21:07 UTC (rev 5841)
+++ code/branches/core5/src/modules/CMakeLists.txt	2009-09-30 16:13:09 UTC (rev 5842)
@@ -26,7 +26,6 @@
 
 ################ Sub Directories ################
 
-ADD_SUBDIRECTORY(gamestates)
 ADD_SUBDIRECTORY(objects)
 ADD_SUBDIRECTORY(overlays)
 ADD_SUBDIRECTORY(pong)

Modified: code/branches/core5/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/core5/src/orxonox/CMakeLists.txt	2009-09-30 11:21:07 UTC (rev 5841)
+++ code/branches/core5/src/orxonox/CMakeLists.txt	2009-09-30 16:13:09 UTC (rev 5842)
@@ -38,6 +38,7 @@
 
 ADD_SUBDIRECTORY(collisionshapes)
 ADD_SUBDIRECTORY(controllers)
+ADD_SUBDIRECTORY(gamestates)
 ADD_SUBDIRECTORY(gametypes)
 ADD_SUBDIRECTORY(graphics)
 ADD_SUBDIRECTORY(infos)

Modified: code/branches/core5/src/orxonox/gamestates/CMakeLists.txt
===================================================================
--- code/branches/core5/src/modules/gamestates/CMakeLists.txt	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/CMakeLists.txt	2009-09-30 16:13:09 UTC (rev 5842)
@@ -1,4 +1,4 @@
-SET_SOURCE_FILES(GAMESTATES_SRC_FILES
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   GSClient.cc
   GSDedicated.cc
   GSGraphics.cc
@@ -9,15 +9,3 @@
   GSServer.cc
   GSStandalone.cc
 )
-
-ORXONOX_ADD_LIBRARY(gamestates
-  MODULE
-  FIND_HEADER_FILES
-  PCH_FILE
-    GameStatesPrecompiledHeaders.h
-  DEFINE_SYMBOL
-    "GAMESTATES_SHARED_BUILD"
-  LINK_LIBRARIES
-    orxonox
-  SOURCE_FILES ${GAMESTATES_SRC_FILES}
-)

Modified: code/branches/core5/src/orxonox/gamestates/GSClient.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSClient.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSClient.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,14 +29,14 @@
 #ifndef _GSClient_H__
 #define _GSClient_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 
 #include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSClient : public GameState
+    class _OrxonoxExport GSClient : public GameState
     {
     public:
         GSClient(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSDedicated.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSDedicated.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,22 +29,23 @@
 #ifndef _GSDedicated_H__
 #define _GSDedicated_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 
-#include "core/GameState.h"
-#include "network/NetworkPrereqs.h"
+#include <cstring>
 #include <queue>
-#include <cstring>
 #include <boost/thread/thread.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/recursive_mutex.hpp>
 
+#include "core/GameState.h"
+#include "network/NetworkPrereqs.h"
+
 struct termios;
 
 namespace orxonox
 {
 
-    class _GameStatesExport GSDedicated : public GameState
+    class _OrxonoxExport GSDedicated : public GameState
     {
     public:
         GSDedicated(const GameStateInfo& info);

Deleted: code/branches/core5/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSGraphics.cc	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSGraphics.cc	2009-09-30 16:13:09 UTC (rev 5842)
@@ -1,176 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      Benjamin Knecht
- *
- */
-
-/**
- at file
- at brief
-    Implementation of Graphics GameState class.
- */
-
-#include "GSGraphics.h"
-
-#include "util/Convert.h"
-#include "core/Clock.h"
-#include "core/CommandExecutor.h"
-#include "core/ConsoleCommand.h"
-#include "core/Core.h"
-#include "core/Game.h"
-#include "core/GUIManager.h"
-#include "core/input/InputManager.h"
-#include "core/input/KeyBinder.h"
-#include "core/input/InputState.h"
-#include "core/Loader.h"
-#include "core/XMLFile.h"
-#include "overlays/InGameConsole.h"
-#include "sound/SoundManager.h"
-
-// HACK:
-#include "overlays/Map.h"
-
-namespace orxonox
-{
-    DeclareGameState(GSGraphics, "graphics", false, true);
-
-    GSGraphics::GSGraphics(const GameStateInfo& info)
-        : GameState(info)
-        , console_(0)
-        , soundManager_(0)
-        , masterKeyBinder_(0)
-        , masterInputState_(0)
-        , debugOverlay_(0)
-    {
-        // load master key bindings
-        masterInputState_ = InputManager::getInstance().createInputState("master", true);
-        masterKeyBinder_ = new KeyBinder();
-        masterInputState_->setKeyHandler(masterKeyBinder_);
-    }
-
-    GSGraphics::~GSGraphics()
-    {
-        InputManager::getInstance().destroyState("master");
-        this->masterKeyBinder_->destroy();
-    }
-
-    /**
-    @brief
-        This function is called when we enter this game state.
-
-        Since graphics is very important for our game this function does quite a lot:
-        \li starts graphics manager
-        \li loads debug overlay
-        \li manages render window
-        \li creates input manager
-        \li loads master key bindings
-        \li loads the SoundManager
-        \li loads ingame console
-        \li loads GUI interface (GUIManager)
-        \li creates console command to toggle GUI
-    */
-    void GSGraphics::activate()
-    {
-        // load debug overlay
-        COUT(3) << "Loading Debug Overlay..." << std::endl;
-        this->debugOverlay_ = new XMLFile("debug.oxo");
-        Loader::open(debugOverlay_);
-
-        masterKeyBinder_->loadBindings("masterKeybindings.ini");
-
-        // Load the SoundManager
-        soundManager_ = new SoundManager();
-
-        // Load the InGameConsole
-        console_ = new InGameConsole();
-        console_->initialise();
-
-        // add console command to toggle GUI
-        this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI");
-        CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
-
-        // enable master input
-        InputManager::getInstance().enterState("master");
-    }
-
-    /**
-    @brief
-        This function is called when the game state is left
-
-        Created references, input states and console commands are deleted.
-    */
-    void GSGraphics::deactivate()
-    {
-/*
-        if (this->ccToggleGUI_)
-        {
-            delete this->ccToggleGUI_;
-            this->ccToggleGUI_ = 0;
-        }
-*/
-
-        this->console_->destroy();
-
-        Loader::unload(this->debugOverlay_);
-        delete this->debugOverlay_;
-
-        this->soundManager_->destroy();
-
-        // HACK: (destroys a resource smart pointer)
-        Map::hackDestroyMap();
-    }
-
-    /**
-    @brief
-        Toggles the visibility of the current GUI
-
-        This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
-        For more details on this function check out the Lua code.
-    */
-    void GSGraphics::toggleGUI()
-    {
-        GUIManager::getInstance().executeCode("toggleGUI()");
-    }
-
-    /**
-    @note
-        A note about the Ogre::FrameListener: Even though we don't use them,
-        they still get called. However, the delta times are not correct (except
-        for timeSinceLastFrame, which is the most important). A little research
-        as shown that there is probably only one FrameListener that doesn't even
-        need the time. So we shouldn't run into problems.
-    */
-    void GSGraphics::update(const Clock& time)
-    {
-        if (this->getActivity().topState)
-        {
-            // This state can not 'survive' on its own.
-            // Load a user interface therefore
-            Game::getInstance().requestState("mainMenu");
-        }
-
-        this->console_->update(time);
-    }
-}

Copied: code/branches/core5/src/orxonox/gamestates/GSGraphics.cc (from rev 5836, code/branches/core5/src/modules/gamestates/GSGraphics.cc)
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSGraphics.cc	                        (rev 0)
+++ code/branches/core5/src/orxonox/gamestates/GSGraphics.cc	2009-09-30 16:13:09 UTC (rev 5842)
@@ -0,0 +1,175 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Benjamin Knecht
+ *
+ */
+
+/**
+ at file
+ at brief
+    Implementation of Graphics GameState class.
+ */
+
+#include "GSGraphics.h"
+
+#include "util/Convert.h"
+#include "core/Clock.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "core/Game.h"
+#include "core/GUIManager.h"
+#include "core/input/InputManager.h"
+#include "core/input/KeyBinder.h"
+#include "core/input/InputState.h"
+#include "core/Loader.h"
+#include "core/XMLFile.h"
+#include "overlays/InGameConsole.h"
+#include "sound/SoundManager.h"
+
+// HACK:
+#include "overlays/Map.h"
+
+namespace orxonox
+{
+    DeclareGameState(GSGraphics, "graphics", false, true);
+
+    GSGraphics::GSGraphics(const GameStateInfo& info)
+        : GameState(info)
+        , console_(0)
+        , soundManager_(0)
+        , masterKeyBinder_(0)
+        , masterInputState_(0)
+        , debugOverlay_(0)
+    {
+        // load master key bindings
+        masterInputState_ = InputManager::getInstance().createInputState("master", true);
+        masterKeyBinder_ = new KeyBinder();
+        masterInputState_->setKeyHandler(masterKeyBinder_);
+    }
+
+    GSGraphics::~GSGraphics()
+    {
+        InputManager::getInstance().destroyState("master");
+        this->masterKeyBinder_->destroy();
+    }
+
+    /**
+    @brief
+        This function is called when we enter this game state.
+
+        Since graphics is very important for our game this function does quite a lot:
+        \li starts graphics manager
+        \li loads debug overlay
+        \li manages render window
+        \li creates input manager
+        \li loads master key bindings
+        \li loads the SoundManager
+        \li loads ingame console
+        \li loads GUI interface (GUIManager)
+        \li creates console command to toggle GUI
+    */
+    void GSGraphics::activate()
+    {
+        // load debug overlay
+        COUT(3) << "Loading Debug Overlay..." << std::endl;
+        this->debugOverlay_ = new XMLFile("debug.oxo");
+        Loader::open(debugOverlay_);
+
+        masterKeyBinder_->loadBindings("masterKeybindings.ini");
+
+        // Load the SoundManager
+        soundManager_ = new SoundManager();
+
+        // Load the InGameConsole
+        console_ = new InGameConsole();
+        console_->initialise();
+
+        // add console command to toggle GUI
+        this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI");
+        CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
+
+        // enable master input
+        InputManager::getInstance().enterState("master");
+    }
+
+    /**
+    @brief
+        This function is called when the game state is left
+
+        Created references, input states and console commands are deleted.
+    */
+    void GSGraphics::deactivate()
+    {
+/*
+        if (this->ccToggleGUI_)
+        {
+            delete this->ccToggleGUI_;
+            this->ccToggleGUI_ = 0;
+        }
+*/
+
+        this->console_->destroy();
+
+        Loader::unload(this->debugOverlay_);
+        delete this->debugOverlay_;
+
+        this->soundManager_->destroy();
+
+        // HACK: (destroys a resource smart pointer)
+        Map::hackDestroyMap();
+    }
+
+    /**
+    @brief
+        Toggles the visibility of the current GUI
+
+        This function just executes a Lua function in the main script of the GUI by accessing the GUIManager.
+        For more details on this function check out the Lua code.
+    */
+    void GSGraphics::toggleGUI()
+    {
+        GUIManager::getInstance().executeCode("toggleGUI()");
+    }
+
+    /**
+    @note
+        A note about the Ogre::FrameListener: Even though we don't use them,
+        they still get called. However, the delta times are not correct (except
+        for timeSinceLastFrame, which is the most important). A little research
+        as shown that there is probably only one FrameListener that doesn't even
+        need the time. So we shouldn't run into problems.
+    */
+    void GSGraphics::update(const Clock& time)
+    {
+        if (this->getActivity().topState)
+        {
+            // This state can not 'survive' on its own.
+            // Load a user interface therefore
+            Game::getInstance().requestState("mainMenu");
+        }
+
+        this->console_->update(time);
+    }
+}

Modified: code/branches/core5/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSGraphics.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSGraphics.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -35,7 +35,7 @@
 #ifndef _GSGraphics_H__
 #define _GSGraphics_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
 
 namespace orxonox
@@ -46,7 +46,7 @@
 
         This game state is only left out if we start a dedicated server where no graphics are present.
     */
-    class _GameStatesExport GSGraphics : public GameState
+    class _OrxonoxExport GSGraphics : public GameState
     {
     public:
         GSGraphics(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSIOConsole.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSIOConsole.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,12 +29,12 @@
 #ifndef _GSIOConsole_H__
 #define _GSIOConsole_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSIOConsole : public GameState
+    class _OrxonoxExport GSIOConsole : public GameState
     {
     public:
         GSIOConsole(const GameStateInfo& info);

Deleted: code/branches/core5/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSLevel.cc	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSLevel.cc	2009-09-30 16:13:09 UTC (rev 5842)
@@ -1,299 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      Fabian 'x3n' Landau
- *      Benjamin Knecht
- *
- */
-
-#include "GSLevel.h"
-
-#include <OgreCompositorManager.h>
-
-#include "core/input/InputManager.h"
-#include "core/input/InputState.h"
-#include "core/input/KeyBinder.h"
-#include "core/Clock.h"
-#include "core/ConsoleCommand.h"
-#include "core/ConfigValueIncludes.h"
-#include "core/CoreIncludes.h"
-#include "core/Game.h"
-#include "core/GameMode.h"
-#include "core/Core.h"
-#include "core/GraphicsManager.h"
-#include "core/GUIManager.h"
-#include "core/Loader.h"
-#include "core/XMLFile.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "CameraManager.h"
-#include "LevelManager.h"
-#include "PlayerManager.h"
-#include "infos/HumanPlayer.h"
-
-namespace orxonox
-{
-    DeclareGameState(GSLevel, "level", false, false);
-    SetConsoleCommand(GSLevel, showIngameGUI, true);
-
-    XMLFile* GSLevel::startFile_s = NULL;
-
-    GSLevel::GSLevel(const GameStateInfo& info)
-        : GameState(info)
-        , keyBinder_(0)
-        , gameInputState_(0)
-        , guiMouseOnlyInputState_(0)
-        , guiKeysOnlyInputState_(0)
-        , cameraManager_(0)
-    {
-        RegisterObject(GSLevel);
-
-        this->ccKeybind_ = 0;
-        this->ccTkeybind_ = 0;
-    }
-
-    GSLevel::~GSLevel()
-    {
-    }
-
-    void GSLevel::setConfigValues()
-    {
-        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
-    }
-
-    void GSLevel::activate()
-    {
-        setConfigValues();
-
-        if (GameMode::showsGraphics())
-        {
-            gameInputState_ = InputManager::getInstance().createInputState("game");
-            keyBinder_ = new KeyBinder();
-            keyBinder_->loadBindings("keybindings.ini");
-            gameInputState_->setHandler(keyBinder_);
-
-            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
-            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
-
-            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
-            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
-
-            // create the global CameraManager
-            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
-        }
-
-        this->playerManager_ = new PlayerManager();
-
-        this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>();
-
-        if (GameMode::isMaster())
-        {
-            this->loadLevel();
-        }
-
-        if (GameMode::showsGraphics())
-        {
-            // keybind console command
-            ccKeybind_ = createConsoleCommand(createFunctor(&GSLevel::keybind, this), "keybind");
-            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
-            ccTkeybind_ = createConsoleCommand(createFunctor(&GSLevel::tkeybind, this), "tkeybind");
-            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
-            // set our console command as callback for the key detector
-            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
-
-            // level is loaded: we can start capturing the input
-            InputManager::getInstance().enterState("game");
-            
-            // connect the HumanPlayer to the game
-            this->playerManager_->clientConnected(0);
-        }
-    }
-
-    void GSLevel::showIngameGUI(bool show)
-    {
-        if (show)
-        {
-            GUIManager::getInstance().showGUI("inGameTest");
-            GUIManager::getInstance().executeCode("showCursor()");
-            InputManager::getInstance().enterState("guiMouseOnly");
-        }
-        else
-        {
-            GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
-            GUIManager::getInstance().executeCode("hideCursor()");
-            InputManager::getInstance().leaveState("guiMouseOnly");
-        }
-    }
-
-    void GSLevel::deactivate()
-    {
-/*
-        // destroy console commands
-        if (this->ccKeybind_)
-        {
-            delete this->ccKeybind_;
-            this->ccKeybind_ = 0;
-        }
-        if (this->ccTkeybind_)
-        {
-            delete this->ccTkeybind_;
-            this->ccTkeybind_ = 0;
-        }
-*/
-
-        if (GameMode::showsGraphics())
-        {
-            // disconnect the HumanPlayer
-            this->playerManager_->clientDisconnected(0);
-            
-            // unload all compositors (this is only necessary because we don't yet destroy all resources!)
-            Ogre::CompositorManager::getSingleton().removeAll();
-        }
-
-        // this call will delete every BaseObject!
-        // But currently this will call methods of objects that exist no more
-        // The only 'memory leak' is the ParticleSpawer. They would be deleted here
-        // and call a sceneNode method that has already been destroy by the corresponding space ship.
-        //Loader::close();
-
-        if (GameMode::showsGraphics())
-        {
-            InputManager::getInstance().leaveState("game");
-        }
-
-        if (GameMode::isMaster())
-            this->unloadLevel();
-
-        if (this->cameraManager_)
-        {
-            delete this->cameraManager_;
-            this->cameraManager_ = 0;
-        }
-
-        if (this->playerManager_)
-        {
-            this->playerManager_->destroy();
-            this->playerManager_ = 0;
-        }
-
-        if (this->scope_GSLevel_)
-        {
-            delete this->scope_GSLevel_;
-            this->scope_GSLevel_ = NULL;
-        }
-
-        if (GameMode::showsGraphics())
-        {
-            gameInputState_->setHandler(0);
-            guiMouseOnlyInputState_->setHandler(0);
-            guiKeysOnlyInputState_->setHandler(0);
-            InputManager::getInstance().destroyState("game");
-            InputManager::getInstance().destroyState("guiKeysOnly");
-            InputManager::getInstance().destroyState("guiMouseOnly");
-            if (this->keyBinder_)
-            {
-                this->keyBinder_->destroy();
-                this->keyBinder_ = 0;
-            }
-        }
-    }
-
-    void GSLevel::update(const Clock& time)
-    {
-        // Note: Temporarily moved to GSGraphics.
-        //// Call the scene objects
-        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
-        //    it->tick(time.getDeltaTime() * this->timeFactor_);
-    }
-
-    void GSLevel::loadLevel()
-    {
-        // call the loader
-        COUT(0) << "Loading level..." << std::endl;
-        startFile_s = new XMLFile(LevelManager::getInstance().getDefaultLevel());
-        Loader::open(startFile_s);
-    }
-
-    void GSLevel::unloadLevel()
-    {
-        Loader::unload(startFile_s);
-
-        delete startFile_s;
-    }
-
-    void GSLevel::keybind(const std::string &command)
-    {
-        this->keybindInternal(command, false);
-    }
-
-    void GSLevel::tkeybind(const std::string &command)
-    {
-        this->keybindInternal(command, true);
-    }
-
-    /**
-    @brief
-        Assigns a command string to a key/button/axis. The name is determined via KeyDetector.
-    @param command
-        Command string that can be executed by the CommandExecutor
-        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
-        the key/button/axis that has been activated. This is configured above in activate().
-    */
-    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
-    {
-        if (GameMode::showsGraphics())
-        {
-            static std::string bindingString = "";
-            static bool bTemporarySaved = false;
-            static bool bound = true;
-            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
-            // Howerver there will be no real issue if it happens anyway.
-            if (command.find(keyDetectorCallbackCode_) != 0)
-            {
-                if (bound)
-                {
-                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-                    InputManager::getInstance().enterState("detector");
-                    bindingString = command;
-                    bTemporarySaved = bTemporary;
-                    bound = false;
-                }
-                //else:  We're still in a keybind command. ignore this call.
-            }
-            else
-            {
-                if (!bound)
-                {
-                    // user has pressed the key
-                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
-                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
-                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
-                    InputManager::getInstance().leaveState("detector");
-                    bound = true;
-                }
-                // else: A key was pressed within the same tick, ignore it.
-            }
-        }
-    }
-}

Copied: code/branches/core5/src/orxonox/gamestates/GSLevel.cc (from rev 5836, code/branches/core5/src/modules/gamestates/GSLevel.cc)
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSLevel.cc	                        (rev 0)
+++ code/branches/core5/src/orxonox/gamestates/GSLevel.cc	2009-09-30 16:13:09 UTC (rev 5842)
@@ -0,0 +1,298 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *      Benjamin Knecht
+ *
+ */
+
+#include "GSLevel.h"
+
+#include <OgreCompositorManager.h>
+
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+#include "core/input/KeyBinder.h"
+#include "core/Clock.h"
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/Game.h"
+#include "core/GameMode.h"
+#include "core/GraphicsManager.h"
+#include "core/GUIManager.h"
+#include "core/Loader.h"
+#include "core/XMLFile.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "CameraManager.h"
+#include "LevelManager.h"
+#include "PlayerManager.h"
+#include "infos/HumanPlayer.h"
+
+namespace orxonox
+{
+    DeclareGameState(GSLevel, "level", false, false);
+    SetConsoleCommand(GSLevel, showIngameGUI, true);
+
+    XMLFile* GSLevel::startFile_s = NULL;
+
+    GSLevel::GSLevel(const GameStateInfo& info)
+        : GameState(info)
+        , keyBinder_(0)
+        , gameInputState_(0)
+        , guiMouseOnlyInputState_(0)
+        , guiKeysOnlyInputState_(0)
+        , cameraManager_(0)
+    {
+        RegisterObject(GSLevel);
+
+        this->ccKeybind_ = 0;
+        this->ccTkeybind_ = 0;
+    }
+
+    GSLevel::~GSLevel()
+    {
+    }
+
+    void GSLevel::setConfigValues()
+    {
+        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
+    }
+
+    void GSLevel::activate()
+    {
+        setConfigValues();
+
+        if (GameMode::showsGraphics())
+        {
+            gameInputState_ = InputManager::getInstance().createInputState("game");
+            keyBinder_ = new KeyBinder();
+            keyBinder_->loadBindings("keybindings.ini");
+            gameInputState_->setHandler(keyBinder_);
+
+            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
+            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
+
+            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
+            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
+
+            // create the global CameraManager
+            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
+        }
+
+        this->playerManager_ = new PlayerManager();
+
+        this->scope_GSLevel_ = new Scope<ScopeID::GSLevel>();
+
+        if (GameMode::isMaster())
+        {
+            this->loadLevel();
+        }
+
+        if (GameMode::showsGraphics())
+        {
+            // keybind console command
+            ccKeybind_ = createConsoleCommand(createFunctor(&GSLevel::keybind, this), "keybind");
+            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
+            ccTkeybind_ = createConsoleCommand(createFunctor(&GSLevel::tkeybind, this), "tkeybind");
+            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
+            // set our console command as callback for the key detector
+            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
+
+            // level is loaded: we can start capturing the input
+            InputManager::getInstance().enterState("game");
+            
+            // connect the HumanPlayer to the game
+            this->playerManager_->clientConnected(0);
+        }
+    }
+
+    void GSLevel::showIngameGUI(bool show)
+    {
+        if (show)
+        {
+            GUIManager::getInstance().showGUI("inGameTest");
+            GUIManager::getInstance().executeCode("showCursor()");
+            InputManager::getInstance().enterState("guiMouseOnly");
+        }
+        else
+        {
+            GUIManager::getInstance().executeCode("hideGUI(\"inGameTest\")");
+            GUIManager::getInstance().executeCode("hideCursor()");
+            InputManager::getInstance().leaveState("guiMouseOnly");
+        }
+    }
+
+    void GSLevel::deactivate()
+    {
+/*
+        // destroy console commands
+        if (this->ccKeybind_)
+        {
+            delete this->ccKeybind_;
+            this->ccKeybind_ = 0;
+        }
+        if (this->ccTkeybind_)
+        {
+            delete this->ccTkeybind_;
+            this->ccTkeybind_ = 0;
+        }
+*/
+
+        if (GameMode::showsGraphics())
+        {
+            // disconnect the HumanPlayer
+            this->playerManager_->clientDisconnected(0);
+            
+            // unload all compositors (this is only necessary because we don't yet destroy all resources!)
+            Ogre::CompositorManager::getSingleton().removeAll();
+        }
+
+        // this call will delete every BaseObject!
+        // But currently this will call methods of objects that exist no more
+        // The only 'memory leak' is the ParticleSpawer. They would be deleted here
+        // and call a sceneNode method that has already been destroy by the corresponding space ship.
+        //Loader::close();
+
+        if (GameMode::showsGraphics())
+        {
+            InputManager::getInstance().leaveState("game");
+        }
+
+        if (GameMode::isMaster())
+            this->unloadLevel();
+
+        if (this->cameraManager_)
+        {
+            delete this->cameraManager_;
+            this->cameraManager_ = 0;
+        }
+
+        if (this->playerManager_)
+        {
+            this->playerManager_->destroy();
+            this->playerManager_ = 0;
+        }
+
+        if (this->scope_GSLevel_)
+        {
+            delete this->scope_GSLevel_;
+            this->scope_GSLevel_ = NULL;
+        }
+
+        if (GameMode::showsGraphics())
+        {
+            gameInputState_->setHandler(0);
+            guiMouseOnlyInputState_->setHandler(0);
+            guiKeysOnlyInputState_->setHandler(0);
+            InputManager::getInstance().destroyState("game");
+            InputManager::getInstance().destroyState("guiKeysOnly");
+            InputManager::getInstance().destroyState("guiMouseOnly");
+            if (this->keyBinder_)
+            {
+                this->keyBinder_->destroy();
+                this->keyBinder_ = 0;
+            }
+        }
+    }
+
+    void GSLevel::update(const Clock& time)
+    {
+        // Note: Temporarily moved to GSGraphics.
+        //// Call the scene objects
+        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
+        //    it->tick(time.getDeltaTime() * this->timeFactor_);
+    }
+
+    void GSLevel::loadLevel()
+    {
+        // call the loader
+        COUT(0) << "Loading level..." << std::endl;
+        startFile_s = new XMLFile(LevelManager::getInstance().getDefaultLevel());
+        Loader::open(startFile_s);
+    }
+
+    void GSLevel::unloadLevel()
+    {
+        Loader::unload(startFile_s);
+
+        delete startFile_s;
+    }
+
+    void GSLevel::keybind(const std::string &command)
+    {
+        this->keybindInternal(command, false);
+    }
+
+    void GSLevel::tkeybind(const std::string &command)
+    {
+        this->keybindInternal(command, true);
+    }
+
+    /**
+    @brief
+        Assigns a command string to a key/button/axis. The name is determined via KeyDetector.
+    @param command
+        Command string that can be executed by the CommandExecutor
+        OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
+        the key/button/axis that has been activated. This is configured above in activate().
+    */
+    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
+    {
+        if (GameMode::showsGraphics())
+        {
+            static std::string bindingString = "";
+            static bool bTemporarySaved = false;
+            static bool bound = true;
+            // note: We use a long name to make 'sure' that the user doesn't use it accidentally.
+            // Howerver there will be no real issue if it happens anyway.
+            if (command.find(keyDetectorCallbackCode_) != 0)
+            {
+                if (bound)
+                {
+                    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+                    InputManager::getInstance().enterState("detector");
+                    bindingString = command;
+                    bTemporarySaved = bTemporary;
+                    bound = false;
+                }
+                //else:  We're still in a keybind command. ignore this call.
+            }
+            else
+            {
+                if (!bound)
+                {
+                    // user has pressed the key
+                    std::string name = command.substr(this->keyDetectorCallbackCode_.size());
+                    COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl;
+                    this->keyBinder_->setBinding(bindingString, name, bTemporarySaved);
+                    InputManager::getInstance().leaveState("detector");
+                    bound = true;
+                }
+                // else: A key was pressed within the same tick, ignore it.
+            }
+        }
+    }
+}

Modified: code/branches/core5/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSLevel.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSLevel.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,7 +29,7 @@
 #ifndef _GSLevel_H__
 #define _GSLevel_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 
 #include <string>
 #include "util/Scope.h"
@@ -38,7 +38,7 @@
 
 namespace orxonox
 {
-    class _GameStatesExport GSLevel : public GameState, public OrxonoxClass
+    class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
     {
     public:
         GSLevel(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSMainMenu.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSMainMenu.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,14 +29,14 @@
 #ifndef _GSMainMenu_H__
 #define _GSMainMenu_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 
 #include "util/OgreForwardRefs.h"
 #include "core/GameState.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSMainMenu : public GameState
+    class _OrxonoxExport GSMainMenu : public GameState
     {
     public:
         GSMainMenu(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSRoot.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSRoot.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,12 +29,12 @@
 #ifndef _GSRoot_H__
 #define _GSRoot_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSRoot : public GameState
+    class _OrxonoxExport GSRoot : public GameState
     {
     public:
         GSRoot(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSServer.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSServer.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSServer.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,14 +29,14 @@
 #ifndef _GSServer_H__
 #define _GSServer_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 
 #include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSServer : public GameState
+    class _OrxonoxExport GSServer : public GameState
     {
     public:
         GSServer(const GameStateInfo& info);

Modified: code/branches/core5/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSStandalone.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GSStandalone.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -29,12 +29,12 @@
 #ifndef _GSStandalone_H__
 #define _GSStandalone_H__
 
-#include "gamestates/GameStatesPrereqs.h"
+#include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
 
 namespace orxonox
 {
-    class _GameStatesExport GSStandalone : public GameState
+    class _OrxonoxExport GSStandalone : public GameState
     {
     public:
         GSStandalone(const GameStateInfo& info);

Deleted: code/branches/core5/src/orxonox/gamestates/GameStatesPrecompiledHeaders.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GameStatesPrecompiledHeaders.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GameStatesPrecompiledHeaders.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -1,58 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- at file
- at brief
-    Compilation of the most often used header files in the game states module
- at details
-    Updated: 19. September 2009
-    Total Files: 9
-*/
-
-#include "OrxonoxConfig.h"
-
-///////////////////////////////////////////
-/////          Stable Headers         /////
-///////////////////////////////////////////
-
-#include "util/SubString.h"       // 6
-#include "util/OgreForwardRefs.h" // 6
-
-///////////////////////////////////////////
-/////       All Rebuild Headers       /////
-///////////////////////////////////////////
-
-#include "core/GameState.h" // 9
-#include "core/Game.h"      // 9
-#include "util/MultiType.h" // 8
-
-
-// Just in case some header included windows.h
-#undef min
-#undef max

Deleted: code/branches/core5/src/orxonox/gamestates/GameStatesPrereqs.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GameStatesPrereqs.h	2009-09-28 21:31:39 UTC (rev 5832)
+++ code/branches/core5/src/orxonox/gamestates/GameStatesPrereqs.h	2009-09-30 16:13:09 UTC (rev 5842)
@@ -1,60 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-  @file
-  @brief Contains all the necessary forward declarations for all classes and structs.
-*/
-
-#ifndef _GameStatesPrereqs_H__
-#define _GameStatesPrereqs_H__
-
-#include "OrxonoxConfig.h"
-
-#include "OrxonoxPrereqs.h"
-
-//-----------------------------------------------------------------------
-// Shared library settings
-//-----------------------------------------------------------------------
-#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
-#  ifdef GAMESTATES_SHARED_BUILD
-#    define _GameStatesExport __declspec(dllexport)
-#  else
-#    if defined( __MINGW32__ )
-#      define _GameStatesExport
-#    else
-#      define _GameStatesExport __declspec(dllimport)
-#    endif
-#  endif
-#elif defined ( ORXONOX_GCC_VISIBILITY )
-#  define _GameStatesExport  __attribute__ ((visibility("default")))
-#else
-#  define _GameStatesExport
-#endif
-
-#endif /* _GameStatesPrereqs_H__ */




More information about the Orxonox-commit mailing list