Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 6, 2011, 2:30:24 PM (13 years ago)
Author:
dafrick
Message:

Adding toggleGUI functionality, not yet used, though. Toggling of QuestGUI needs another approach.

Location:
code/branches/usability
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/data/gui/scripts/SheetManager.lua

    r8032 r8033  
    8989        ["sheet"]          = menuSheet,
    9090        ["bHidePrevious"]  = bHidePrevious,
    91         ["bNoInput"]       = bNoInput
     91        ["bNoInput"]       = bNoInput,
     92        ["name"]           = name
    9293    }
    9394    table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     
    298299end
    299300
     301function getGUIFirstActive(name, bHidePrevious, bNoInput)
     302    local sheet = activeMenuSheets.topSheetTuple
     303    -- If the topmost gui sheet has the input name
     304    if sheet ~= nil and sheet.name == name then
     305        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
     306    else
     307        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
     308    end
     309end
     310
    300311----------------------
    301312--- Initialisation ---
  • code/branches/usability/src/libraries/core/GUIManager.cc

    r7994 r8033  
    105105    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
    106106    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
     107    SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
    107108
    108109    /**
     
    282283    {
    283284        GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")");
     285    }
     286
     287    /**
     288    @brief
     289        Toggles specified GUI.
     290        If the GUI with the input name is already shown and on the top, it is hidden, else it is shown.
     291    */
     292    /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput)
     293    {
     294        GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")");
     295    }
     296
     297    /**
     298    @brief
     299        Helper method to toggle a specified GUI.
     300        Is called by lua.
     301    */
     302    void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show)
     303    {
     304        if(show)
     305            GUIManager::showGUI(name, bHidePrevious, bNoInput);
     306        else
     307            GUIManager::hideGUI(name);
    284308    }
    285309
  • code/branches/usability/src/libraries/core/GUIManager.h

    r7874 r8033  
    8888        void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false);
    8989        static void hideGUI(const std::string& name);
     90        static void toggleGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false);
     91        void toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show); // tolua_export
    9092        void keyESC();
    9193        void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export
Note: See TracChangeset for help on using the changeset viewer.