Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2008, 5:50:42 PM (16 years ago)
Author:
rgrieder
Message:

Modified the GameState hierarchy so that you can get the parent with the actual type by calling getParent().

Location:
code/branches/gui/src/orxonox
Files:
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/Main.cc

    r1672 r1688  
    130130    GSClient client;
    131131    GSGUI gui;
    132     GSIO io;
    133132    GSIOConsole ioConsole;
    134133
     
    139138    graphics.addChild(&gui);
    140139
    141     root.addChild(&io);
    142     io.addChild(&ioConsole);
     140    root.addChild(&ioConsole);
    143141
    144142    root.feedCommandLine(argc, argv);
  • code/branches/gui/src/orxonox/OrxonoxPrereqs.h

    r1674 r1688  
    120120    //gui
    121121    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;
    122133}
    123134
  • code/branches/gui/src/orxonox/gamestates/GSGUI.cc

    r1686 r1688  
    3939{
    4040    GSGUI::GSGUI()
    41         : GameState("gui")
     41        : GameStateTyped<GSGraphics>("gui")
    4242    {
    4343    }
     
    4949    void GSGUI::enter()
    5050    {
     51        guiManager_ = getParent()->getGUIManager();
     52
    5153        // 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());
    5456    }
    5557
    5658    void GSGUI::leave()
    5759    {
    58         GUIManager::getInstance().hideGUI();
     60        guiManager_->hideGUI();
    5961    }
    6062
     
    6264    {
    6365        // tick CEGUI
    64         GUIManager::getInstance().tick(time.getDeltaTime());
     66        guiManager_->tick(time.getDeltaTime());
    6567
    6668        this->tickChild(time);
  • code/branches/gui/src/orxonox/gamestates/GSGUI.h

    r1674 r1688  
    3232#include "OrxonoxPrereqs.h"
    3333#include "core/GameState.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSGUI : public GameState
     38    class _OrxonoxExport GSGUI : public GameStateTyped<GSGraphics>
    3839    {
    3940    public:
     
    4546        void leave();
    4647        void ticked(const Clock& time);
     48
     49        GUIManager* guiManager_;
    4750    };
    4851}
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.cc

    r1686 r1688  
    5757{
    5858    GSGraphics::GSGraphics()
    59         : GameState("graphics")
     59        : GameStateTyped<GSRoot>("graphics")
    6060        , ogreRoot_(0)
    6161        , inputManager_(0)
     
    7777    void GSGraphics::setConfigValues()
    7878    {
    79         SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
     79        SetConfigValue(resourceFile_, "resources.cfg").description("Location of the resources file in the data path.");
    8080        SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated.");
    8181    }
     
    8585        setConfigValues();
    8686
    87         this->ogreRoot_ = Ogre::Root::getSingletonPtr();
     87        this->ogreRoot_ = getParent()->getOgreRoot();
    8888
    8989        this->declareResources();
     
    9494
    9595        // 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_;
    100100
    101101
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.h

    r1686 r1688  
    3535#include "core/GameState.h"
    3636#include "core/OrxonoxClass.h"
     37#include "GSRoot.h"
    3738
    3839namespace orxonox
    3940{
    40     class _OrxonoxExport GSGraphics : public GameState, public OrxonoxClass, public Ogre::WindowEventListener
     41    class _OrxonoxExport GSGraphics : public GameStateTyped<GSRoot>, public OrxonoxClass, public Ogre::WindowEventListener
    4142    {
    4243        friend class ClassIdentifier<GSGraphics>;
     
    4445        GSGraphics();
    4546        ~GSGraphics();
     47
     48        Ogre::Viewport* getViewport() { return this->viewport_; }
     49        GUIManager* getGUIManager() { return this->guiManager_; }
    4650
    4751    private:
  • code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc

    r1674 r1688  
    4242{
    4343    GSIOConsole::GSIOConsole()
    44         : GameState("ioConsole")
     44        : GameStateTyped<GSRoot>("ioConsole")
    4545    {
    4646    }
  • code/branches/gui/src/orxonox/gamestates/GSIOConsole.h

    r1674 r1688  
    3333#include <OgrePrerequisites.h>
    3434#include "core/GameState.h"
     35#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSIOConsole : public GameState
     39    class _OrxonoxExport GSIOConsole : public GameStateTyped<GSRoot>
    3940    {
    4041    public:
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r1686 r1688  
    4545{
    4646    GSLevel::GSLevel(const std::string& name)
    47         : GameState(name)
     47        : GameStateTyped<GSGraphics>(name)
    4848        , timeFactor_(1.0f)
    4949        , sceneManager_(0)
     
    6868
    6969        // 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");
    7271        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
     72
     73        // temporary hack
    7374        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
    7475
     
    9899        delete this->radar_;
    99100
    100         GraphicsEngine::getInstance().getOgreRoot()->destroySceneManager(this->sceneManager_);
     101        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    101102
    102103        inputState_->setHandler(0);
  • code/branches/gui/src/orxonox/gamestates/GSLevel.h

    r1686 r1688  
    3333#include <OgrePrerequisites.h>
    3434#include "core/GameState.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSLevel : public GameState
     39    class _OrxonoxExport GSLevel : public GameStateTyped<GSGraphics>
    3940    {
    4041    public:
  • code/branches/gui/src/orxonox/gamestates/GSRoot.h

    r1686 r1688  
    4949        { requestState("root"); }
    5050
     51        Ogre::Root* getOgreRoot() { return this->ogreRoot_; }
     52        GraphicsEngine* getGraphicsEngine() { return this->graphicsEngine_; }
     53
    5154    private:
    5255        void enter();
Note: See TracChangeset for help on using the changeset viewer.