Changeset 1688 for code/branches/gui/src
- Timestamp:
- Aug 31, 2008, 5:50:42 PM (16 years ago)
- Location:
- code/branches/gui/src
- Files:
-
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/CorePrereqs.h
r1674 r1688 163 163 // game states 164 164 class GameState; 165 template <class ParentType> 166 class GameStateTyped; 165 167 class RootGameState; 166 168 -
code/branches/gui/src/core/GameState.cc
r1674 r1688 45 45 GameState::GameState(const std::string& name) 46 46 : name_(name) 47 , parent_(0)47 //, parent_(0) 48 48 , activeChild_(0) 49 //, bPause Parent_(false)49 //, bPausegetParent()(false) 50 50 { 51 51 Operations temp = {false, false, false, false, false}; … … 103 103 104 104 // mark us as parent 105 state-> parent_ = this;105 state->setParent(this); 106 106 } 107 107 … … 178 178 this->allChildren_[grandchild->getName()] = grandchild; 179 179 this->grandchildrenToChildren_[grandchild] = child; 180 if (this-> parent_)181 this-> parent_->grandchildAdded(this, grandchild);180 if (this->getParent()) 181 this->getParent()->grandchildAdded(this, grandchild); 182 182 } 183 183 … … 196 196 this->allChildren_.erase(grandchild->getName()); 197 197 this->grandchildrenToChildren_.erase(grandchild); 198 if (this-> parent_)199 this-> parent_->grandchildRemoved(grandchild);198 if (this->getParent()) 199 this->getParent()->grandchildRemoved(grandchild); 200 200 } 201 201 … … 208 208 GameState* GameState::getState(const std::string& name) 209 209 { 210 if (this-> parent_)211 return this-> parent_->getState(name);210 if (this->getParent()) 211 return this->getParent()->getState(name); 212 212 else 213 213 { … … 227 227 GameState* GameState::getRoot() 228 228 { 229 if (this-> parent_)230 return this-> parent_->getRoot();229 if (this->getParent()) 230 return this->getParent()->getRoot(); 231 231 else 232 232 return this; -
code/branches/gui/src/core/GameState.h
r1686 r1688 41 41 #include <vector> 42 42 #include <map> 43 #include <cassert> 43 44 #include "util/Integers.h" 44 45 #include "Clock.h" … … 63 64 { 64 65 friend class RootGameState; 66 template <class ParentType> 67 friend class GameStateTyped; 65 68 66 69 public: … … 79 82 80 83 public: 81 GameState(const std::string& name);82 84 virtual ~GameState(); 83 85 … … 88 90 GameState* getState(const std::string& name); 89 91 GameState* getRoot(); 90 GameState* getParent() const { return this->parent_; }91 92 //! Returns the currently active game state 92 93 virtual GameState* getCurrentState(); … … 107 108 void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); } 108 109 110 virtual GameState* getParent() const = 0; 111 virtual void setParent(GameState* state) = 0; 112 109 113 private: 114 // Making the constructor private ensures that game states 115 // are always derivates of GameStateTyped<T>. Note the friend declaration above. 116 GameState(const std::string& name); 117 110 118 //! Performs a transition to 'destination' 111 119 virtual void makeTransition(GameState* source, GameState* destination); … … 120 128 const std::string name_; 121 129 Operations operation_; 122 GameState* parent_;123 130 GameState* activeChild_; 124 131 //bool bPauseParent_; … … 126 133 std::map<GameState*, GameState*> grandchildrenToChildren_; 127 134 }; 135 136 template <class ParentType> 137 class GameStateTyped : public GameState 138 { 139 public: 140 GameStateTyped(const std::string& name) : GameState(name) { } 141 virtual ~GameStateTyped() { } 142 143 ParentType* getParent() const 144 { return parent_; } 145 146 protected: 147 void setParent(GameState* state) 148 { 149 assert(dynamic_cast<ParentType*>(state) != 0); 150 this->parent_ = dynamic_cast<ParentType*>(state); 151 } 152 153 private: 154 ParentType* parent_; 155 }; 128 156 } 129 157 -
code/branches/gui/src/core/RootGameState.cc
r1674 r1688 39 39 40 40 RootGameState::RootGameState(const std::string& name) 41 : GameState (name)41 : GameStateTyped<GameState>(name) 42 42 , stateRequest_("") 43 43 { -
code/branches/gui/src/core/RootGameState.h
r1674 r1688 35 35 namespace orxonox 36 36 { 37 class _CoreExport RootGameState : public GameState 37 class _CoreExport RootGameState : public GameStateTyped<GameState> 38 38 { 39 39 public: -
code/branches/gui/src/orxonox/Main.cc
r1672 r1688 130 130 GSClient client; 131 131 GSGUI gui; 132 GSIO io;133 132 GSIOConsole ioConsole; 134 133 … … 139 138 graphics.addChild(&gui); 140 139 141 root.addChild(&io); 142 io.addChild(&ioConsole); 140 root.addChild(&ioConsole); 143 141 144 142 root.feedCommandLine(argc, argv); -
code/branches/gui/src/orxonox/OrxonoxPrereqs.h
r1674 r1688 120 120 //gui 121 121 class GUIManager; 122 123 // game states 124 class GSRoot; 125 class GSGraphics; 126 class GSIO; 127 class GSIOConsole; 128 class GSLevel; 129 class GSStandalone; 130 class GSServer; 131 class GSClient; 132 class GSGUI; 122 133 } 123 134 -
code/branches/gui/src/orxonox/gamestates/GSGUI.cc
r1686 r1688 39 39 { 40 40 GSGUI::GSGUI() 41 : GameState ("gui")41 : GameStateTyped<GSGraphics>("gui") 42 42 { 43 43 } … … 49 49 void GSGUI::enter() 50 50 { 51 guiManager_ = getParent()->getGUIManager(); 52 51 53 // show main menu 52 GUIManager::getInstance().showGUI("MainMenu", 0);53 GraphicsEngine::getInstance().getViewport()->setCamera(GUIManager::getInstance().getCamera());54 guiManager_->showGUI("MainMenu", 0); 55 getParent()->getViewport()->setCamera(guiManager_->getCamera()); 54 56 } 55 57 56 58 void GSGUI::leave() 57 59 { 58 GUIManager::getInstance().hideGUI();60 guiManager_->hideGUI(); 59 61 } 60 62 … … 62 64 { 63 65 // tick CEGUI 64 GUIManager::getInstance().tick(time.getDeltaTime());66 guiManager_->tick(time.getDeltaTime()); 65 67 66 68 this->tickChild(time); -
code/branches/gui/src/orxonox/gamestates/GSGUI.h
r1674 r1688 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "core/GameState.h" 34 #include "GSGraphics.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GSGUI : public GameState 38 class _OrxonoxExport GSGUI : public GameStateTyped<GSGraphics> 38 39 { 39 40 public: … … 45 46 void leave(); 46 47 void ticked(const Clock& time); 48 49 GUIManager* guiManager_; 47 50 }; 48 51 } -
code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
r1686 r1688 57 57 { 58 58 GSGraphics::GSGraphics() 59 : GameState ("graphics")59 : GameStateTyped<GSRoot>("graphics") 60 60 , ogreRoot_(0) 61 61 , inputManager_(0) … … 77 77 void GSGraphics::setConfigValues() 78 78 { 79 SetConfigValue(resourceFile_, 79 SetConfigValue(resourceFile_, "resources.cfg").description("Location of the resources file in the data path."); 80 80 SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated."); 81 81 } … … 85 85 setConfigValues(); 86 86 87 this->ogreRoot_ = Ogre::Root::getSingletonPtr();87 this->ogreRoot_ = getParent()->getOgreRoot(); 88 88 89 89 this->declareResources(); … … 94 94 95 95 // HACK: temporary: 96 GraphicsEngine & graphicsEngine = GraphicsEngine::getInstance();97 graphicsEngine .renderWindow_= this->renderWindow_;98 graphicsEngine .root_= this->ogreRoot_;99 graphicsEngine .viewport_= this->viewport_;96 GraphicsEngine* graphicsEngine = getParent()->getGraphicsEngine(); 97 graphicsEngine->renderWindow_ = this->renderWindow_; 98 graphicsEngine->root_ = this->ogreRoot_; 99 graphicsEngine->viewport_ = this->viewport_; 100 100 101 101 -
code/branches/gui/src/orxonox/gamestates/GSGraphics.h
r1686 r1688 35 35 #include "core/GameState.h" 36 36 #include "core/OrxonoxClass.h" 37 #include "GSRoot.h" 37 38 38 39 namespace orxonox 39 40 { 40 class _OrxonoxExport GSGraphics : public GameState , public OrxonoxClass, public Ogre::WindowEventListener41 class _OrxonoxExport GSGraphics : public GameStateTyped<GSRoot>, public OrxonoxClass, public Ogre::WindowEventListener 41 42 { 42 43 friend class ClassIdentifier<GSGraphics>; … … 44 45 GSGraphics(); 45 46 ~GSGraphics(); 47 48 Ogre::Viewport* getViewport() { return this->viewport_; } 49 GUIManager* getGUIManager() { return this->guiManager_; } 46 50 47 51 private: -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
r1674 r1688 42 42 { 43 43 GSIOConsole::GSIOConsole() 44 : GameState ("ioConsole")44 : GameStateTyped<GSRoot>("ioConsole") 45 45 { 46 46 } -
code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
r1674 r1688 33 33 #include <OgrePrerequisites.h> 34 34 #include "core/GameState.h" 35 #include "GSRoot.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSIOConsole : public GameState 39 class _OrxonoxExport GSIOConsole : public GameStateTyped<GSRoot> 39 40 { 40 41 public: -
code/branches/gui/src/orxonox/gamestates/GSLevel.cc
r1686 r1688 45 45 { 46 46 GSLevel::GSLevel(const std::string& name) 47 : GameState (name)47 : GameStateTyped<GSGraphics>(name) 48 48 , timeFactor_(1.0f) 49 49 , sceneManager_(0) … … 68 68 69 69 // create Ogre SceneManager for the level 70 this->sceneManager_ = GraphicsEngine::getInstance().getOgreRoot()-> 71 createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager"); 70 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager"); 72 71 COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl; 72 73 // temporary hack 73 74 GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_); 74 75 … … 98 99 delete this->radar_; 99 100 100 GraphicsEngine::getInstance().getOgreRoot()->destroySceneManager(this->sceneManager_);101 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 101 102 102 103 inputState_->setHandler(0); -
code/branches/gui/src/orxonox/gamestates/GSLevel.h
r1686 r1688 33 33 #include <OgrePrerequisites.h> 34 34 #include "core/GameState.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSLevel : public GameState 39 class _OrxonoxExport GSLevel : public GameStateTyped<GSGraphics> 39 40 { 40 41 public: -
code/branches/gui/src/orxonox/gamestates/GSRoot.h
r1686 r1688 49 49 { requestState("root"); } 50 50 51 Ogre::Root* getOgreRoot() { return this->ogreRoot_; } 52 GraphicsEngine* getGraphicsEngine() { return this->graphicsEngine_; } 53 51 54 private: 52 55 void enter();
Note: See TracChangeset
for help on using the changeset viewer.