Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 6, 2011, 4:32:05 PM (14 years ago)
Author:
dafrick
Message:

Replacing hard coded keys for the menu navigation with keys specified in the keybindings.ini file (note: You have to delete your keybindings.ini file for it to be regenerated and work correctly).
The upside is, that now we need less hackish, stuff, it's better integrated, toggling of OrxonoxOverlays (e.g. QuestGUI and PickupInventory, among others) is working again. Closing the InGameConsole with ESC no longer requires a workaround to work.
The downside is, that now GUI sheets that require input, e.g. GraphicsMenu or MiscConfigMenu, no longer support menu navigation and ESC doesn't work there. However, I don't know how to work around that, yet. But since all that ESC business is a hack anyway, I'd rather have the hacks there…

Location:
code/branches/usability/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/src/libraries/core/GUIManager.cc

    r8033 r8035  
    103103    /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen";
    104104
     105    static const std::string __CC_navigateGUI_name = "navigateGUI";
     106
    105107    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
    106108    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
    107109    SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
     110    SetConsoleCommand(__CC_navigateGUI_name, &GUIManager::navigateGUI).deactivate();
     111
     112    //! Strings that specify modes for the GUI navigation.
     113    /*static*/ const std::string GUIManager::NAVIGATE_UP = "up";
     114    /*static*/ const std::string GUIManager::NAVIGATE_DOWN = "down";
     115    /*static*/ const std::string GUIManager::NAVIGATE_LEFT = "left";
     116    /*static*/ const std::string GUIManager::NAVIGATE_RIGHT = "right";
     117    /*static*/ const std::string GUIManager::NAVIGATE_ENTER = "enter";
    108118
    109119    /**
     
    364374            this->rootWindow_->setProperty("Alpha", "1.0");
    365375        this->rootWindow_->setProperty("Image", image);
     376    }
     377
     378    /**
     379    @brief
     380        Method to navigate the GUI, by specifying the mode of navigation.
     381    @param mode
     382        The mode of navigation, at this point can be either 'up', 'down', 'left', 'right' or 'enter'.
     383    */
     384    /*static*/ void GUIManager::navigateGUI(const std::string& mode)
     385    {
     386        if(mode == NAVIGATE_UP)
     387            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_UP + "\")");
     388        else if(mode == NAVIGATE_DOWN)
     389            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_DOWN + "\")");
     390        else if(mode == NAVIGATE_LEFT)
     391            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_LEFT + "\")");
     392        else if(mode == NAVIGATE_RIGHT)
     393            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_RIGHT + "\")");
     394        else if(mode == NAVIGATE_ENTER)
     395            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_ENTER + "\")");
     396    }
     397
     398    /**
     399    @brief
     400        Is called by lua to change whether there are any GUIs active at the moment.
     401    @param active
     402        Whether GUIs are active.
     403    */
     404    void GUIManager::guisActiveChanged(bool active)
     405    {
     406        if(this->GUIsActive_ == active)
     407            return;
     408        this->GUIsActive_ = active;
     409        if(this->GUIsActive_)
     410            ModifyConsoleCommand(__CC_navigateGUI_name).activate();
     411        else
     412            ModifyConsoleCommand(__CC_navigateGUI_name).deactivate();
    366413    }
    367414
  • code/branches/usability/src/libraries/core/GUIManager.h

    r8033 r8035  
    9494        void setBackgroundImage(const std::string& image);
    9595
     96        static void navigateGUI(const std::string& mode);
     97        void guisActiveChanged(bool active); // tolua_export
     98
    9699        //! Creates a new InputState to be used with a GUI Sheet
    97100        const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
     
    124127        template <typename FunctionType>
    125128        bool protectedCall(FunctionType function);
     129
     130        static const std::string NAVIGATE_UP;
     131        static const std::string NAVIGATE_DOWN;
     132        static const std::string NAVIGATE_LEFT;
     133        static const std::string NAVIGATE_RIGHT;
     134        static const std::string NAVIGATE_ENTER;
     135
     136        bool GUIsActive_; //!< Whether there are any GUIs active at a given moment.
    126137
    127138        // keyHandler functions
  • code/branches/usability/src/orxonox/gamestates/GSMainMenu.cc

    r7978 r8035  
    6868        RegisterRootObject(GSMainMenu);
    6969
    70         InputManager::getInstance().createInputState("MainMenuHackery", true, true)->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
     70        InputManager::getInstance().createInputState("MainMenuHackery")->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
    7171
    7272        // create an empty Scene
  • code/branches/usability/src/orxonox/overlays/InGameConsole.cc

    r8032 r8035  
    4949#include "core/ConfigValueIncludes.h"
    5050#include "core/command/ConsoleCommand.h"
    51 #include "core/GUIManager.h"
    5251#include "core/input/InputManager.h"
    5352#include "core/input/InputState.h"
     
    534533        {
    535534            this->bActive_ = false;
    536             GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed.
    537535            InputManager::getInstance().leaveState("console");
    538536            this->shell_->unregisterListener(this);
     
    611609    /*static*/ void InGameConsole::closeConsole()
    612610    {
    613         GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()");  // Notify the SheetManager in lua, that the console has been closed, but not by ESC.
    614611        InGameConsole::getInstance().deactivate();
    615612    }
Note: See TracChangeset for help on using the changeset viewer.