Changeset 5782 for sandbox/src/libraries/core/Game.cc
- Timestamp:
- Sep 24, 2009, 11:32:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/src/libraries/core/Game.cc
r5747 r5782 45 45 #include "Clock.h" 46 46 #include "CommandLine.h" 47 #include "ConsoleCommand.h"48 47 #include "Core.h" 49 48 #include "CoreIncludes.h" 50 49 #include "ConfigValueIncludes.h" 51 #include "GameMode.h"52 50 #include "GameState.h" 53 51 54 52 namespace orxonox 55 53 { 56 static void stop_game()57 { Game::getInstance().stop(); }58 SetConsoleCommandShortcutExternAlias(stop_game, "exit");59 60 54 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; 61 55 Game* Game::singletonPtr_s = 0; … … 506 500 void Game::loadGraphics() 507 501 { 508 if (!GameMode::bShowsGraphics_s)509 {510 core_->loadGraphics();511 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);512 GameMode::bShowsGraphics_s = true;513 514 // Construct all the GameStates that require graphics515 for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();516 it != gameStateDeclarations_s.end(); ++it)517 {518 if (it->second.bGraphicsMode)519 {520 // Game state loading failure is serious --> don't catch521 shared_ptr<GameState> gameState = GameStateFactory::fabricate(it->second);522 if (!constructedStates_.insert(std::make_pair(523 it->second.stateName, gameState)).second)524 assert(false); // GameState was already created!525 }526 }527 graphicsUnloader.Dismiss();528 }529 502 } 530 503 531 504 void Game::unloadGraphics() 532 505 { 533 if (GameMode::bShowsGraphics_s)534 {535 // Destroy all the GameStates that require graphics536 for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)537 {538 if (it->second->getInfo().bGraphicsMode)539 constructedStates_.erase(it++);540 else541 ++it;542 }543 544 core_->unloadGraphics();545 GameMode::bShowsGraphics_s = false;546 }547 506 } 548 507 … … 563 522 // If state requires graphics, load it 564 523 Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics); 565 if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())524 if (gameStateDeclarations_s[name].bGraphicsMode) 566 525 this->loadGraphics(); 567 526 else
Note: See TracChangeset
for help on using the changeset viewer.