Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2009, 11:32:39 AM (15 years ago)
Author:
rgrieder
Message:

Applied changes to the real sandbox this time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/src/libraries/core/Game.cc

    r5747 r5782  
    4545#include "Clock.h"
    4646#include "CommandLine.h"
    47 #include "ConsoleCommand.h"
    4847#include "Core.h"
    4948#include "CoreIncludes.h"
    5049#include "ConfigValueIncludes.h"
    51 #include "GameMode.h"
    5250#include "GameState.h"
    5351
    5452namespace orxonox
    5553{
    56     static void stop_game()
    57         { Game::getInstance().stop(); }
    58     SetConsoleCommandShortcutExternAlias(stop_game, "exit");
    59 
    6054    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
    6155    Game* Game::singletonPtr_s = 0;
     
    506500    void Game::loadGraphics()
    507501    {
    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 graphics
    515             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 catch
    521                     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         }
    529502    }
    530503
    531504    void Game::unloadGraphics()
    532505    {
    533         if (GameMode::bShowsGraphics_s)
    534         {
    535             // Destroy all the GameStates that require graphics
    536             for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)
    537             {
    538                 if (it->second->getInfo().bGraphicsMode)
    539                     constructedStates_.erase(it++);
    540                 else
    541                     ++it;
    542             }
    543 
    544             core_->unloadGraphics();
    545             GameMode::bShowsGraphics_s = false;
    546         }
    547506    }
    548507
     
    563522        // If state requires graphics, load it
    564523        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
    565         if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
     524        if (gameStateDeclarations_s[name].bGraphicsMode)
    566525            this->loadGraphics();
    567526        else
Note: See TracChangeset for help on using the changeset viewer.