Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2869 for code


Ignore:
Timestamp:
Mar 30, 2009, 11:34:51 PM (16 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

Location:
code/branches/gui/src/orxonox
Files:
8 edited

Legend:

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

    r2854 r2869  
    3636#include "core/ConfigValueIncludes.h"
    3737#include "core/Clock.h"
     38#include "core/ConsoleCommand.h"
    3839#include "core/Core.h"
    3940#include "core/CoreIncludes.h"
     
    110111        guiManager_->initialise(renderWindow);
    111112
     113        FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI);
     114        functor->setObject(this);
     115        this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
     116        CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
     117
     118
    112119        InputManager::getInstance().requestEnterState("master");
    113120    }
     
    115122    void GSGraphics::deactivate()
    116123    {
     124
     125        if (this->ccToggleGUI_)
     126        {
     127            delete this->ccToggleGUI_;
     128            this->ccToggleGUI_ = 0;
     129        }
     130
    117131        masterInputState_->setHandler(0);
    118132        InputManager::getInstance().requestDestroyState("master");
     
    131145
    132146        GameMode::setShowsGraphics(false);
     147    }
     148
     149    void GSGraphics::toggleGUI()
     150    {
     151            GUIManager::getInstance().executeCode("toggleGUI()");
    133152    }
    134153
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.h

    r2844 r2869  
    4747        void update(const Clock& time);
    4848
     49        void toggleGUI();
     50
    4951    private:
    5052        // Window events from WindowEventListener
     
    6163        SimpleInputState*     masterInputState_;
    6264        XMLFile*              debugOverlay_;
     65        ConsoleCommand*       ccToggleGUI_;
    6366    };
    6467}
  • 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
  • code/branches/gui/src/orxonox/gamestates/GSLevel.h

    r2850 r2869  
    4747        void update(const Clock& time);
    4848
    49         void toggleGUI();
     49        static void showIngameGUI(bool show);
    5050
    5151    protected:
     
    5858        void keybindInternal(const std::string& command, bool bTemporary);
    5959
    60         KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    61         SimpleInputState*     inputState_;
    62         Radar*                radar_;            //!< represents the Radar (not the HUD part)
    63         XMLFile*              startFile_;        //!< current hard coded default level
     60        KeyBinder*            keyBinder_;               //!< tool that loads and manages the input bindings
     61        SimpleInputState*     gameInputState_;          //!< input state for normal ingame playing
     62        SimpleInputState*     guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
     63        SimpleInputState*     guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
     64        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
     65        XMLFile*              startFile_;               //!< current hard coded default level
    6466        CameraManager*        cameraManager_;
    6567        LevelManager*         levelManager_;
     
    7274        ConsoleCommand*       ccKeybind_;
    7375        ConsoleCommand*       ccTkeybind_;
    74         ConsoleCommand*       ccToggleGUI_;
    7576    };
    7677}
  • code/branches/gui/src/orxonox/gamestates/GSMainMenu.cc

    r2853 r2869  
    8383    void GSMainMenu::deactivate()
    8484    {
    85         InputManager::getInstance().requestLeaveState("game");
    86         InputManager::getInstance().requestDestroyState("game");
     85        InputManager::getInstance().requestLeaveState("mainMenu");
     86        InputManager::getInstance().requestDestroyState("mainMenu");
    8787
    8888        if (this->ccStartGame_)
     
    9191            this->ccStartGame_ = 0;
    9292        }
    93 
    94         GUIManager::getInstance().executeCode("hideGUI()");
    9593    }
    9694
  • code/branches/gui/src/orxonox/gamestates/GSStandalone.cc

    r2848 r2869  
    5555    {
    5656        GameMode::setIsStandalone(true);
    57 
    58         guiManager_ = GUIManager::getInstancePtr();
    59         // not sure if necessary
    60         // guiManager_->loadScene("IngameMenu");
    6157    }
    6258
     
    6864    void GSStandalone::update(const Clock& time)
    6965    {
    70         //Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
    71         //COUT(0) << "** " << viewport->getCamera()->getSceneManager() << std::endl;
    72         //guiManager_->testFct();
    73         //Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
    74         //guiManager_->showGUI("IngameMenu", viewport->getCamera()->getSceneManager());
    75 
    76         // tick CEGUI
    77         guiManager_->update(time);
    7866    }
    7967}
  • code/branches/gui/src/orxonox/gamestates/GSStandalone.h

    r2844 r2869  
    4646
    4747    private:
    48         GUIManager* guiManager_;
    4948    };
    5049}
  • code/branches/gui/src/orxonox/gui/GUIManager.cc

    r2853 r2869  
    2323 *      Reto Grieder
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    195195        if (state_ != Uninitialised)
    196196        {
    197             COUT(3) << "Loading GUI " << name << std::endl;
     197            //COUT(3) << "Loading GUI " << name << std::endl;
    198198            try
    199199            {
Note: See TracChangeset for help on using the changeset viewer.