Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 25, 2009, 11:53:04 PM (16 years ago)
Author:
rgrieder
Message:
  • Started working on cleaning up the GameState mess ;)
  • Cleaned out GUIManager
  • Renamed GSGUI to GSMainMenu
  • "—state blah" has been changed to —server, —client, —standalone, —dedicated
  • —console starts the game in the console (no level loading there yet, but "loadMenu")
  • adjusted run scripts
Location:
code/branches/gui/src/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/Game.cc

    r2846 r2850  
    4040#include "util/Debug.h"
    4141#include "util/Exception.h"
     42#include "util/SubString.h"
    4243#include "Clock.h"
    4344#include "CommandLine.h"
     
    247248        // Check parent and all its grand parents
    248249        GameStateTreeNode* currentNode = lastRequestedNode;
    249         while (requestedNode == NULL && currentNode->parent_ != NULL)
     250        while (requestedNode == NULL && currentNode != NULL)
    250251        {
    251252            if (currentNode->state_ == state)
     
    260261    }
    261262
     263    void Game::requestStates(const std::string& names)
     264    {
     265        SubString tokens(names, ",;", " ");
     266        for (unsigned int i = 0; i < tokens.size(); ++i)
     267            this->requestState(tokens[i]);
     268    }
     269
    262270    void Game::popState()
    263271    {
     
    270278    GameState* Game::getState(const std::string& name)
    271279    {
    272         std::map<std::string, GameState*>::const_iterator it = allStates_s.find(name);
     280        std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(name));
    273281        if (it != allStates_s.end())
    274282            return it->second;
     
    356364    void Game::loadState(GameState* state)
    357365    {
     366        if (!this->activeStates_.empty())
     367            this->activeStates_.back()->activity_.topState = false;
    358368        state->activate();
     369        state->activity_.topState = true;
    359370        this->activeStates_.push_back(state);
    360371    }
     
    362373    void Game::unloadState(orxonox::GameState* state)
    363374    {
     375        state->activity_.topState = false;
    364376        state->deactivate();
    365377        this->activeStates_.pop_back();
     378        if (!this->activeStates_.empty())
     379            this->activeStates_.back()->activity_.topState = true;
    366380    }
    367381
    368382    /*static*/ bool Game::addGameState(GameState* state)
    369383    {
    370         std::map<std::string, GameState*>::const_iterator it = allStates_s.find(state->getName());
     384        std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(state->getName()));
    371385        if (it == allStates_s.end())
    372             allStates_s[state->getName()] = state;
     386            allStates_s[getLowercase(state->getName())] = state;
    373387        else
    374388            ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'.");
  • code/branches/gui/src/core/Game.h

    r2846 r2850  
    6666
    6767        void requestState(const std::string& name);
     68        void requestStates(const std::string& names);
    6869        void popState();
    6970
  • code/branches/gui/src/core/GameState.cc

    r2844 r2850  
    4949        , parent_(0)
    5050    {
    51         State temp = {false, false, false, false, false};
    52         this->activity_ = temp;
     51        this->activity_.activating   = false;
     52        this->activity_.active       = false;
     53        this->activity_.deactivating = false;
     54        this->activity_.suspended    = false;
     55        this->activity_.topState     = false;
     56        this->activity_.updating     = false;
    5357    }
    5458
  • code/branches/gui/src/core/GameState.h

    r2844 r2850  
    7474            unsigned updating     : 1;
    7575            unsigned suspended    : 1;
     76            unsigned topState     : 1;
    7677        };
    7778
     
    8182
    8283        const std::string& getName() const { return name_; }
    83         const State getActivity() const    { return this->activity_; }
     84        State getActivity() const    { return this->activity_; }
    8485        GameState* getParent() const       { return this->parent_; }
    8586
Note: See TracChangeset for help on using the changeset viewer.