[Orxonox-commit 3345] r8033 - in code/branches/usability: data/gui/scripts src/libraries/core

dafrick at orxonox.net dafrick at orxonox.net
Sun Mar 6 14:30:24 CET 2011


Author: dafrick
Date: 2011-03-06 14:30:24 +0100 (Sun, 06 Mar 2011)
New Revision: 8033

Modified:
   code/branches/usability/data/gui/scripts/SheetManager.lua
   code/branches/usability/src/libraries/core/GUIManager.cc
   code/branches/usability/src/libraries/core/GUIManager.h
Log:
Adding toggleGUI functionality, not yet used, though. Toggling of QuestGUI needs another approach.


Modified: code/branches/usability/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/usability/data/gui/scripts/SheetManager.lua	2011-03-06 13:23:39 UTC (rev 8032)
+++ code/branches/usability/data/gui/scripts/SheetManager.lua	2011-03-06 13:30:24 UTC (rev 8033)
@@ -88,7 +88,8 @@
     {
         ["sheet"]          = menuSheet,
         ["bHidePrevious"]  = bHidePrevious,
-        ["bNoInput"]       = bNoInput
+        ["bNoInput"]       = bNoInput,
+        ["name"]           = name
     }
     table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     activeMenuSheets[name] = sheetTuple -- name access
@@ -297,6 +298,16 @@
     bInGameConsoleClosed = not bInGameConsoleClosed;
 end
 
+function getGUIFirstActive(name, bHidePrevious, bNoInput)
+    local sheet = activeMenuSheets.topSheetTuple
+    -- If the topmost gui sheet has the input name
+    if sheet ~= nil and sheet.name == name then
+        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
+    else
+        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
+    end
+end
+
 ----------------------
 --- Initialisation ---
 ----------------------

Modified: code/branches/usability/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/usability/src/libraries/core/GUIManager.cc	2011-03-06 13:23:39 UTC (rev 8032)
+++ code/branches/usability/src/libraries/core/GUIManager.cc	2011-03-06 13:30:24 UTC (rev 8033)
@@ -104,6 +104,7 @@
 
     SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
     SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
+    SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
 
     /**
     @brief
@@ -283,6 +284,29 @@
         GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")");
     }
 
+    /**
+    @brief
+        Toggles specified GUI.
+        If the GUI with the input name is already shown and on the top, it is hidden, else it is shown.
+    */
+    /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput)
+    {
+        GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")");
+    }
+
+    /**
+    @brief
+        Helper method to toggle a specified GUI.
+        Is called by lua.
+    */
+    void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show)
+    {
+        if(show)
+            GUIManager::showGUI(name, bHidePrevious, bNoInput);
+        else
+            GUIManager::hideGUI(name);
+    }
+
     const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::Value useKeyboard, bool bBlockJoyStick)
     {
         InputState* state = InputManager::getInstance().createInputState(name);

Modified: code/branches/usability/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/usability/src/libraries/core/GUIManager.h	2011-03-06 13:23:39 UTC (rev 8032)
+++ code/branches/usability/src/libraries/core/GUIManager.h	2011-03-06 13:30:24 UTC (rev 8033)
@@ -87,6 +87,8 @@
         static void showGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false);
         void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false);
         static void hideGUI(const std::string& name);
+        static void toggleGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false);
+        void toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show); // tolua_export
         void keyESC();
         void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export
         void setBackgroundImage(const std::string& image);




More information about the Orxonox-commit mailing list