Changeset 2850 for code/branches/gui/src/core
- Timestamp:
- Mar 25, 2009, 11:53:04 PM (16 years ago)
- Location:
- code/branches/gui/src/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gui/src/core/Game.cc
r2846 r2850 40 40 #include "util/Debug.h" 41 41 #include "util/Exception.h" 42 #include "util/SubString.h" 42 43 #include "Clock.h" 43 44 #include "CommandLine.h" … … 247 248 // Check parent and all its grand parents 248 249 GameStateTreeNode* currentNode = lastRequestedNode; 249 while (requestedNode == NULL && currentNode ->parent_!= NULL)250 while (requestedNode == NULL && currentNode != NULL) 250 251 { 251 252 if (currentNode->state_ == state) … … 260 261 } 261 262 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 262 270 void Game::popState() 263 271 { … … 270 278 GameState* Game::getState(const std::string& name) 271 279 { 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)); 273 281 if (it != allStates_s.end()) 274 282 return it->second; … … 356 364 void Game::loadState(GameState* state) 357 365 { 366 if (!this->activeStates_.empty()) 367 this->activeStates_.back()->activity_.topState = false; 358 368 state->activate(); 369 state->activity_.topState = true; 359 370 this->activeStates_.push_back(state); 360 371 } … … 362 373 void Game::unloadState(orxonox::GameState* state) 363 374 { 375 state->activity_.topState = false; 364 376 state->deactivate(); 365 377 this->activeStates_.pop_back(); 378 if (!this->activeStates_.empty()) 379 this->activeStates_.back()->activity_.topState = true; 366 380 } 367 381 368 382 /*static*/ bool Game::addGameState(GameState* state) 369 383 { 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())); 371 385 if (it == allStates_s.end()) 372 allStates_s[ state->getName()] = state;386 allStates_s[getLowercase(state->getName())] = state; 373 387 else 374 388 ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'."); -
code/branches/gui/src/core/Game.h
r2846 r2850 66 66 67 67 void requestState(const std::string& name); 68 void requestStates(const std::string& names); 68 69 void popState(); 69 70 -
code/branches/gui/src/core/GameState.cc
r2844 r2850 49 49 , parent_(0) 50 50 { 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; 53 57 } 54 58 -
code/branches/gui/src/core/GameState.h
r2844 r2850 74 74 unsigned updating : 1; 75 75 unsigned suspended : 1; 76 unsigned topState : 1; 76 77 }; 77 78 … … 81 82 82 83 const std::string& getName() const { return name_; } 83 constState getActivity() const { return this->activity_; }84 State getActivity() const { return this->activity_; } 84 85 GameState* getParent() const { return this->parent_; } 85 86
Note: See TracChangeset
for help on using the changeset viewer.