Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 21, 2009, 8:47:11 PM (15 years ago)
Author:
rgrieder
Message:

Upgrade number two for the InputManager: An InputState can have two new properties. You can tell it to always receive input, no matter what the input stack actually is. Secondly there is a 'transparent' option to be kind of invisible to the other states. I have found no use yet, but three more lines weren't a big deal ;)
This change ultimately supersedes the need for a master InputState.

File:
1 edited

Legend:

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

    r2805 r2816  
    3939#include "core/input/InputManager.h"
    4040#include "core/input/KeyBinder.h"
    41 #include "core/input/ExtendedInputState.h"
     41#include "core/input/SimpleInputState.h"
    4242#include "core/Loader.h"
    4343#include "core/XMLFile.h"
     
    5757        , graphicsManager_(0)
    5858        , masterKeyBinder_(0)
     59        , masterInputState_(0)
    5960        , debugOverlay_(0)
    6061    {
     
    9192        renderWindow->getCustomAttribute("WINDOW", &windowHnd);
    9293        inputManager_->initialise(windowHnd, renderWindow->getWidth(), renderWindow->getHeight(), true);
    93         // Configure master input state with a KeyBinder
     94
     95        masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true);
    9496        masterKeyBinder_ = new KeyBinder();
    9597        masterKeyBinder_->loadBindings("masterKeybindings.ini");
    96         inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
     98        masterInputState_->setKeyHandler(masterKeyBinder_);
    9799
    98100        // Load the InGameConsole
     
    103105        guiManager_ = new GUIManager();
    104106        guiManager_->initialise(renderWindow);
     107
     108        InputManager::getInstance().requestEnterState("master");
    105109    }
    106110
    107111    void GSGraphics::leave()
    108112    {
     113        if (Core::showsGraphics())
     114            InputManager::getInstance().requestLeaveState("master");
     115
    109116        delete this->guiManager_;
    110117
     
    119126
    120127        delete graphicsManager_;
     128
     129        if (Core::showsGraphics())
     130        {
     131            masterInputState_->setHandler(0);
     132            InputManager::getInstance().requestDestroyState("master");
     133            if (this->masterKeyBinder_)
     134            {
     135                delete this->masterKeyBinder_;
     136                this->masterKeyBinder_ = 0;
     137            }
     138        }
    121139    }
    122140
Note: See TracChangeset for help on using the changeset viewer.