Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 25, 2009, 5:23:00 PM (15 years ago)
Author:
rgrieder
Message:

Implemented new GameState concept. It doesn't differ that much from the old one, but there's still lots of changes.
The most important change is that one GameState can occur multiple times in the hierarchy.

Short log:

  • No RootGameState anymore. Simply the highest is root.
  • Game::requestGameState(name) can refer to the parent, grandparent, great-grandparent, etc. or one of the children.
  • Requested states are saved. So if you select "level", the next request (even right after the call) will be relative to "level"
  • Game::popState() will simply unload the current one
  • Re added Main.cc again because Game as well as GameState have been moved to the core
  • Adapted all GameStates to the new system

Things should already work, except for network support because standalone only works with a little hack.
We can now start creating a better hierarchy.

File:
1 edited

Legend:

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

    r2817 r2844  
    3232#include <OgreViewport.h>
    3333#include "core/Clock.h"
     34#include "core/ConsoleCommand.h"
    3435#include "core/input/InputManager.h"
    3536#include "core/input/SimpleInputState.h"
    3637#include "gui/GUIManager.h"
    3738#include "GraphicsManager.h"
     39#include "core/Game.h"
    3840
    3941namespace orxonox
    4042{
    41     GSGUI::GSGUI()
    42         : GameState("gui")
     43    AddGameState(GSGUI, "gui");
     44
     45    GSGUI::GSGUI(const std::string& name)
     46        : GameState(name)
    4347    {
    4448    }
     
    4852    }
    4953
    50     void GSGUI::enter()
     54    void GSGUI::activate()
    5155    {
    5256        guiManager_ = GUIManager::getInstancePtr();
     
    5660        guiManager_->showGUI("MainMenu", 0);
    5761        GraphicsManager::getInstance().getViewport()->setCamera(guiManager_->getCamera());
     62
     63        {
     64            // time factor console command
     65            FunctorMember<GSGUI>* functor = createFunctor(&GSGUI::startGame);
     66            functor->setObject(this);
     67            this->ccStartGame_ = createConsoleCommand(functor, "startGame");
     68            CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_);
     69        }
    5870    }
    5971
    60     void GSGUI::leave()
     72    void GSGUI::deactivate()
    6173    {
     74        if (this->ccStartGame_)
     75        {
     76            delete this->ccStartGame_;
     77            this->ccStartGame_ = 0;
     78        }
     79
    6280        guiManager_->hideGUI();
    6381    }
    6482
    65     void GSGUI::ticked(const Clock& time)
     83    void GSGUI::update(const Clock& time)
    6684    {
    6785        // tick CEGUI
    6886        guiManager_->update(time);
     87    }
    6988
    70         this->tickChild(time);
     89    void GSGUI::startGame()
     90    {
     91        // HACK - HACK
     92        Game::getInstance().popState();
     93        Game::getInstance().requestState("standalone");
     94        Game::getInstance().requestState("level");
    7195    }
    7296}
Note: See TracChangeset for help on using the changeset viewer.