[Orxonox-commit 3335] r8023 - in code/branches/usability: data/gui/scripts src/libraries/core/input

landauf at orxonox.net landauf at orxonox.net
Sat Mar 5 23:07:39 CET 2011


Author: landauf
Date: 2011-03-05 23:07:39 +0100 (Sat, 05 Mar 2011)
New Revision: 8023

Modified:
   code/branches/usability/data/gui/scripts/GraphicsMenu.lua
   code/branches/usability/data/gui/scripts/SheetManager.lua
   code/branches/usability/src/libraries/core/input/InputManager.cc
   code/branches/usability/src/libraries/core/input/InputManager.h
Log:
update exclusive mouse mode and cursor visibility when changing fullscreen/window mode

Modified: code/branches/usability/data/gui/scripts/GraphicsMenu.lua
===================================================================
--- code/branches/usability/data/gui/scripts/GraphicsMenu.lua	2011-03-05 19:39:21 UTC (rev 8022)
+++ code/branches/usability/data/gui/scripts/GraphicsMenu.lua	2011-03-05 22:07:39 UTC (rev 8023)
@@ -336,6 +336,9 @@
 
     -- prompt for confirmation
     openDecisionPopup("Do you want to keep these settings? (Settings will be reverted in 10 seconds if not accepted)", GraphicsMenu.callback_ApplyDecisionPopup)
+    if checkedFullscreen then
+        showCursor()
+    end
 end
 
 function P.callback_ApplyDecisionPopup(pressedOK)

Modified: code/branches/usability/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/usability/data/gui/scripts/SheetManager.lua	2011-03-05 19:39:21 UTC (rev 8022)
+++ code/branches/usability/data/gui/scripts/SheetManager.lua	2011-03-05 22:07:39 UTC (rev 8023)
@@ -9,27 +9,22 @@
 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
 
------------------------
---- Local functions ---
------------------------
+------------------------
+--- Global functions ---
+------------------------
 
-local function hideCursor()
+function hideCursor()
     if cursor:isVisible() then
         cursor:hide()
     end
 end
 
-local function showCursor()
+function showCursor()
     if not cursor:isVisible() and inputMgr:isMouseExclusive() then
         cursor:show()
     end
 end
 
-
-------------------------
---- Global functions ---
-------------------------
-
 -- Loads the GUI with the specified name
 -- The name corresponds to the filename of the *.lua and *.layout files
 -- but without the extension
@@ -256,10 +251,22 @@
 end
 
 function windowResized(e)
-    local sheet = activeMenuSheets[activeMenuSheets.size]
-    if sheet then
-        sheet.sheet:windowResized()
+    for name, sheet in pairs(loadedSheets) do
+        if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
+            inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
+        else
+            inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
+        end
     end
+    local sheetTuple = activeMenuSheets[activeMenuSheets.size]
+    if sheetTuple then
+        if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
+            showCursor()
+        else
+            hideCursor()
+        end
+        sheetTuple.sheet:windowResized()
+    end
 end
 
 function setBackgroundImage(imageSet, imageName)

Modified: code/branches/usability/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/usability/src/libraries/core/input/InputManager.cc	2011-03-05 19:39:21 UTC (rev 8022)
+++ code/branches/usability/src/libraries/core/input/InputManager.cc	2011-03-05 22:07:39 UTC (rev 8023)
@@ -640,4 +640,20 @@
         statesByName_.erase(state->getName());
         state->destroy();
     }
+
+    bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
+    {
+        if (name == "empty")
+        {
+            COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;
+            return false;
+        }
+        std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
+        if (it != statesByName_.end())
+        {
+            it->second->setMouseExclusive(value);
+            return true;
+        }
+        return false;
+    }
 }

Modified: code/branches/usability/src/libraries/core/input/InputManager.h
===================================================================
--- code/branches/usability/src/libraries/core/input/InputManager.h	2011-03-05 19:39:21 UTC (rev 8022)
+++ code/branches/usability/src/libraries/core/input/InputManager.h	2011-03-05 22:07:39 UTC (rev 8023)
@@ -162,6 +162,13 @@
             - The removal process is being postponed if InputManager::preUpdate() is currently running.
         */
         bool destroyState(const std::string& name); // tolua_export
+        /**
+        @brief
+            Changes the mouse mode of an input state.
+        @return
+            True if the call was successful, fals if the name was not found
+        */
+        bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
 
         //-------------------------------
         // Various getters and setters




More information about the Orxonox-commit mailing list