Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2009, 11:34:51 PM (15 years ago)
Author:
bknecht
Message:

Including some features to use only mouse or keys in a GUI, also cleaning up the calls to GUIManager, also trying to show and hide a GUI just by tabbing a key. Anyways, more features to come soonsvn status

File:
1 edited

Legend:

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

    r2850 r2869  
    5656
    5757    SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
     58    SetConsoleCommand(GSLevel, showIngameGUI, true).keybindMode(KeybindMode::OnPress).keybindMode(KeybindMode::OnRelease);
    5859
    5960    GSLevel::GSLevel(const std::string& name)
    6061        : GameState(name)
    6162        , keyBinder_(0)
    62         , inputState_(0)
     63        , gameInputState_(0)
     64        , guiMouseOnlyInputState_(0)
     65        , guiKeysOnlyInputState_(0)
    6366        , radar_(0)
    6467        , startFile_(0)
     
    8790        if (GameMode::showsGraphics())
    8891        {
    89             {
    90                 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::toggleGUI);
    91                 functor->setObject(this);
    92                 this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
    93                 CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
    94             }
    95 
    96             inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
     92            gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
    9793            keyBinder_ = new KeyBinder();
    9894            keyBinder_->loadBindings("keybindings.ini");
    99             inputState_->setHandler(keyBinder_);
     95            gameInputState_->setHandler(keyBinder_);
     96
     97            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
     98            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
     99
     100            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
     101            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    100102
    101103            // create the global CameraManager
     
    138140    }
    139141
     142    void GSLevel::showIngameGUI(bool show)
     143    {
     144        COUT(0) << "*** Call works with \"" << (show ? "true" : "false") << "\" as param" << std::endl;
     145        if (show)
     146        {
     147            GUIManager::getInstancePtr()->showGUI("inGameTest");
     148            InputManager::getInstance().requestEnterState("guiMouseOnly");
     149        }
     150        else
     151        {
     152            GUIManager::getInstancePtr()->executeCode("hideGUI(inGameTest)");
     153            InputManager::getInstance().requestLeaveState("guiMouseOnly");
     154        }
     155    }
     156
    140157    void GSLevel::deactivate()
    141158    {
     
    150167            delete this->ccTkeybind_;
    151168            this->ccTkeybind_ = 0;
    152         }
    153         if (this->ccToggleGUI_)
    154         {
    155             delete this->ccToggleGUI_;
    156             this->ccToggleGUI_ = 0;
    157169        }
    158170
     
    196208        if (GameMode::showsGraphics())
    197209        {
    198             inputState_->setHandler(0);
     210            gameInputState_->setHandler(0);
     211            guiMouseOnlyInputState_->setHandler(0);
     212            guiKeysOnlyInputState_->setHandler(0);
    199213            InputManager::getInstance().requestDestroyState("game");
    200214            if (this->keyBinder_)
     
    233247
    234248        delete this->startFile_;
    235     }
    236 
    237     void GSLevel::toggleGUI()
    238     {
    239         if (GameMode::showsGraphics())
    240         {
    241             GUIManager::getInstance().executeCode("toggleGUI()");
    242         }
    243249    }
    244250
Note: See TracChangeset for help on using the changeset viewer.