[Orxonox-commit 1305] r6023 - in code/branches/ingamemenu: data/gui/scripts src/libraries/core src/orxonox/gamestates
scheusso at orxonox.net
scheusso at orxonox.net
Wed Nov 4 13:59:39 CET 2009
Author: scheusso
Date: 2009-11-04 13:59:39 +0100 (Wed, 04 Nov 2009)
New Revision: 6023
Modified:
code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua
code/branches/ingamemenu/src/libraries/core/GUIManager.cc
code/branches/ingamemenu/src/libraries/core/GUIManager.h
code/branches/ingamemenu/src/libraries/core/LuaState.cc
code/branches/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc
Log:
clean cursor handling in GUIManager/lua code
change in output level of lua error messages
Modified: code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua 2009-11-04 11:51:05 UTC (rev 6022)
+++ code/branches/ingamemenu/data/gui/scripts/InitialiseGUI.lua 2009-11-04 12:59:39 UTC (rev 6023)
@@ -13,7 +13,11 @@
system:setDefaultTooltip("TaharezLook/Tooltip")
loadedGUIs = {}
-root = nil;
+cursorVisibility = {}
+activeSheets = {}
+nrOfActiveSheets = 0
+root = nil
+bShowsCursor = false
-- loads the GUI with the specified filename
-- be sure to set the global variable "filename" before calling this function
@@ -35,14 +39,19 @@
return loadedGui
end
-function showGUI(filename, ptr)
- gui = showGUI(filename)
+function showGUI(filename, bCursorVisible, ptr)
+ gui = showGUI(filename, bCursorVisible)
gui.overlay = ptr
end
-- shows the specified and loads it if not loaded already
-- be sure to set the global variable "filename" before calling this function
-function showGUI(filename)
+function showGUI(filename, bCursorVisible)
+-- bCursorVisibile=false
+ if bCursorVisible == nil then
+ cursorVisibility= true
+ end
+
if root == nil then
root = winMgr:createWindow("TaharezLook/StaticImage", "AbsoluteRootWindow")
root:setProperty("Alpha", "0.0")
@@ -60,24 +69,63 @@
end
root:addChildWindow(currentGUI.window)
+ if bCursorVisible then
+ showCursor()
+ else
+ hideCursor()
+ end
+ cursorVisibility[filename]=bCursorVisible
+
+ nrOfActiveSheets = nrOfActiveSheets + 1
+ table.insert(activeSheets, filename)
+ activeSheets[nrOfActiveSheets] = filename
+
currentGUI:show()
showing = true
return currentGUI
end
function hideCursor()
- cursor:hide()
+ if bShowsCursor==true then
+ bShowsCursor=false
+ cursor:hide()
+ end
end
function showCursor()
- cursor:show()
+ if bShowsCursor==false then
+ bShowsCursor=true
+ cursor:show()
+ end
end
function hideGUI(filename)
local currentGUI = loadedGUIs[filename]
- if currentGUI ~= nil then
- currentGUI:hide()
- root:removeChildWindow(currentGUI.window)
- showing = false
+ if currentGUI == nil then
+ return
end
+ currentGUI:hide()
+ root:removeChildWindow(currentGUI.window)
+ showing = false
+ i=1
+ while activeSheets[i] do
+ if activeSheets[i+1] == nil then
+ if activeSheets[i-1] ~= nil then
+ if cursorVisibility[ activeSheets[i-1] ] == true then
+ showCursor()
+ else
+ hideCursor()
+ end
+ else
+ hideCursor()
+ end
+ end
+ if activeSheets[i] == filename then
+ table.remove( activeSheets, i )
+ nrOfActiveSheets = nrOfActiveSheets-1
+ else
+ i = i+1
+ end
+ end
+ cursorVisibility[filename] = nil -- remove the cursor visibility of the current gui from the table
end
Modified: code/branches/ingamemenu/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/ingamemenu/src/libraries/core/GUIManager.cc 2009-11-04 11:51:05 UTC (rev 6022)
+++ code/branches/ingamemenu/src/libraries/core/GUIManager.cc 2009-11-04 12:59:39 UTC (rev 6023)
@@ -49,6 +49,7 @@
#endif
#include "util/Clock.h"
+#include "util/Convert.h"
#include "util/Debug.h"
#include "util/Exception.h"
#include "util/OrxAssert.h"
@@ -87,7 +88,7 @@
GUIManager* GUIManager::singletonPtr_s = 0;
- SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User);
+ SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, true);
SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
/**
@@ -208,24 +209,24 @@
The function executes the Lua function with the same name in case the GUIManager is ready.
For more details check out loadGUI_2.lua where the function presides.
*/
- /*static*/ void GUIManager::showGUI(const std::string& name)
+ /*static*/ void GUIManager::showGUI(const std::string& name, bool showCursor)
{
std::pair<std::set<std::string>::iterator,bool> result = GUIManager::getInstance().showingGUIs_.insert(name);
if(result.second == false) //!< GUI already showing.
return;
if(GUIManager::getInstance().showingGUIs_.size() == 1 && result.second == true) //!< If it's the first GUI.
{
- GUIManager::getInstance().executeCode("showCursor()");
+// GUIManager::getInstance().executeCode("showCursor()");
InputManager::getInstance().enterState("guiMouseOnly");
}
- GUIManager::getInstance().executeCode("showGUI(\"" + name + "\")");
+ GUIManager::getInstance().executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ")");
}
/**
@brief
Hack-ish. Needed for GUIOverlay.
*/
- void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr)
+ void GUIManager::showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor)
{
std::pair<std::set<std::string>::iterator,bool> result = this->showingGUIs_.insert(name);
if(result.second == false) //!< GUI already showing.
@@ -235,7 +236,7 @@
this->executeCode("showCursor()");
InputManager::getInstance().enterState("guiMouseOnly");
}
- this->executeCode("showGUI(\"" + name + "\", " + ptr + ")");
+ this->executeCode("showGUI(\"" + name + "\", " + multi_cast<std::string>(showCursor) + ", " + ptr + ")");
}
/**
@@ -257,11 +258,6 @@
}
}
- /*static*/ void GUIManager::hideCursor()
- {
- GUIManager::getInstance().executeCode("hideCursor()");
- }
-
void GUIManager::keyPressed(const KeyEvent& evt)
{
guiSystem_->injectKeyDown(evt.getKeyCode());
Modified: code/branches/ingamemenu/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/ingamemenu/src/libraries/core/GUIManager.h 2009-11-04 11:51:05 UTC (rev 6022)
+++ code/branches/ingamemenu/src/libraries/core/GUIManager.h 2009-11-04 12:59:39 UTC (rev 6023)
@@ -67,10 +67,9 @@
void update(const Clock& time);
- static void showGUI(const std::string& name);
- void showGUIExtra(const std::string& name, const std::string& ptr);
+ static void showGUI(const std::string& name, bool showCursor=true);
+ void showGUIExtra(const std::string& name, const std::string& ptr, bool showCursor=true);
static void hideGUI(const std::string& name);
- static void hideCursor();
void setCamera(Ogre::Camera* camera);
Ogre::Camera* getCamera() { return this->camera_; }
Modified: code/branches/ingamemenu/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/ingamemenu/src/libraries/core/LuaState.cc 2009-11-04 11:51:05 UTC (rev 6022)
+++ code/branches/ingamemenu/src/libraries/core/LuaState.cc 2009-11-04 12:59:39 UTC (rev 6023)
@@ -163,7 +163,7 @@
std::string origin;
if (sourceFileInfo != NULL)
origin = " originating from " + sourceFileInfo_->filename;
- COUT(2) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
+ COUT(1) << "Error in Lua-script" << origin << ": " << lua_tostring(luaState_, -1) << std::endl;
// return value is nil
lua_pushnil(luaState_);
}
Modified: code/branches/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc 2009-11-04 11:51:05 UTC (rev 6022)
+++ code/branches/ingamemenu/src/orxonox/gamestates/GSMainMenu.cc 2009-11-04 12:59:39 UTC (rev 6023)
@@ -81,8 +81,7 @@
void GSMainMenu::activate()
{
// show main menu
- GUIManager::showGUI("MainMenu");
- GUIManager::hideCursor();
+ GUIManager::getInstance().showGUI("MainMenu", false);
GUIManager::getInstance().setCamera(this->camera_);
GraphicsManager::getInstance().setCamera(this->camera_);
@@ -111,9 +110,9 @@
}
InputManager::getInstance().leaveState("mainMenu");
- GUIManager::hideGUI("MainMenu");
GUIManager::getInstance().setCamera(0);
+ GUIManager::hideGUI("MainMenu");
GraphicsManager::getInstance().setCamera(0);
}
More information about the Orxonox-commit
mailing list