Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 25, 2009, 11:53:04 PM (15 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
File:
1 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'.");
Note: See TracChangeset for help on using the changeset viewer.