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/GSRoot.cc

    r2843 r2844  
    3232#include "util/Exception.h"
    3333#include "util/Debug.h"
     34#include "core/Clock.h"
    3435#include "core/Core.h"
    35 #include "core/CoreIncludes.h"
    3636#include "core/ConsoleCommand.h"
    3737#include "tools/TimeFactorListener.h"
    3838#include "tools/Timer.h"
    3939#include "objects/Tickable.h"
    40 #include "Game.h"
     40#include "core/Game.h"
    4141
    4242namespace orxonox
    4343{
    44     GSRoot::GSRoot()
    45         : RootGameState("root")
     44    AddGameState(GSRoot, "root");
     45
     46    GSRoot::GSRoot(const std::string& name)
     47        : GameState(name)
    4648        , timeFactor_(1.0f)
    4749        , bPaused_(false)
     
    5658    }
    5759
    58     void GSRoot::enter()
     60    void GSRoot::activate()
    5961    {
    6062        // reset game speed to normal
    6163        timeFactor_ = 1.0f;
    62 
    63         {
    64             // add console commands
    65             FunctorMember01<GameState, const std::string&>* functor = createFunctor(&GameState::requestState);
    66             functor->setObject(this);
    67             this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
    68             CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
    69         }
    7064
    7165        {
     
    8680    }
    8781
    88     void GSRoot::leave()
     82    void GSRoot::deactivate()
    8983    {
    90         // destroy console commands
    91         delete this->ccSelectGameState_;
    92 
    9384        if (this->ccSetTimeFactor_)
    9485        {
     
    10495    }
    10596
    106     void GSRoot::ticked(const Clock& time)
     97    void GSRoot::update(const Clock& time)
    10798    {
    10899        uint64_t timeBeforeTick = time.getRealMicroseconds();
     
    129120        // Also add our tick time to the list in GSRoot
    130121        Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
    131 
    132         this->tickChild(time);
    133122    }
    134123
Note: See TracChangeset for help on using the changeset viewer.