Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3357 for code/branches


Ignore:
Timestamp:
Jul 27, 2009, 1:57:28 PM (15 years ago)
Author:
rgrieder
Message:

Moved some GameState code from activate/deactivate to the c'tor and d'tor. This should allow for faster GS switching.
But be careful: Only load in the c'tor what you're sure is available. For instance GSLevel doesn't require graphics, it's just an option. So loading graphical stuff in in the c'tor would be fatal because at this time it is not yet clear whether there will even be graphics (GameMode::showsGraphics() will yield false!).

Location:
code/branches/resource/src/orxonox/gamestates
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/orxonox/gamestates/GSGraphics.cc

    r3355 r3357  
    6565        , debugOverlay_(0)
    6666    {
     67        // load master key bindings
     68        masterInputState_ = InputManager::getInstance().createInputState("master", true);
     69        masterKeyBinder_ = new KeyBinder();
    6770    }
    6871
    6972    GSGraphics::~GSGraphics()
    7073    {
     74        InputManager::getInstance().destroyState("master");
     75        delete this->masterKeyBinder_;
    7176    }
    7277
     
    9297        this->debugOverlay_ = new XMLFile(Core::getMediaPathString() + "overlay/debug.oxo");
    9398        Loader::open(debugOverlay_);
    94         // load master key bindings
    95         masterInputState_ = InputManager::getInstance().createInputState("master", true);
    96         masterKeyBinder_ = new KeyBinder();
     99
    97100        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    98101        masterInputState_->setKeyHandler(masterKeyBinder_);
     
    130133        }
    131134*/
    132 
    133         masterInputState_->setHandler(0);
    134         InputManager::getInstance().destroyState("master");
    135         delete this->masterKeyBinder_;
    136135
    137136        delete this->console_;
  • code/branches/resource/src/orxonox/gamestates/GSMainMenu.cc

    r3355 r3357  
    4949        , inputState_(0)
    5050    {
    51     }
    52 
    53     GSMainMenu::~GSMainMenu()
    54     {
    55     }
    56 
    57     void GSMainMenu::activate()
    58     {
    5951        inputState_ = InputManager::getInstance().createInputState("mainMenu");
    6052        inputState_->setHandler(GUIManager::getInstancePtr());
     
    6557        // and a Camera
    6658        this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
     59    }
    6760
     61    GSMainMenu::~GSMainMenu()
     62    {
     63        InputManager::getInstance().destroyState("mainMenu");
     64
     65        this->scene_->getSceneManager()->destroyCamera(this->camera_);
     66        delete this->scene_;
     67    }
     68
     69    void GSMainMenu::activate()
     70    {
    6871        // show main menu
    6972        GUIManager::getInstance().showGUI("mainmenu_4");
     
    107110
    108111        InputManager::getInstance().leaveState("mainMenu");
    109         InputManager::getInstance().destroyState("mainMenu");
    110112
    111113        GUIManager::getInstance().setCamera(0);
    112114        GraphicsManager::getInstance().setCamera(0);
    113         this->scene_->getSceneManager()->destroyCamera(this->camera_);
    114         delete this->scene_;
    115115
    116116/*
Note: See TracChangeset for help on using the changeset viewer.