[Orxonox-commit 3391] r8078 - in code/branches/usability: data/defaultConfig data/gui/scripts src/libraries/core src/orxonox/gamestates src/orxonox/overlays
dafrick at orxonox.net
dafrick at orxonox.net
Tue Mar 15 21:09:58 CET 2011
Author: dafrick
Date: 2011-03-15 21:09:58 +0100 (Tue, 15 Mar 2011)
New Revision: 8078
Modified:
code/branches/usability/data/defaultConfig/keybindings.ini
code/branches/usability/data/gui/scripts/GUISheet.lua
code/branches/usability/data/gui/scripts/GraphicsMenu.lua
code/branches/usability/data/gui/scripts/MenuSheet.lua
code/branches/usability/data/gui/scripts/SheetManager.lua
code/branches/usability/src/libraries/core/GUIManager.cc
code/branches/usability/src/libraries/core/GUIManager.h
code/branches/usability/src/orxonox/gamestates/GSMainMenu.cc
code/branches/usability/src/orxonox/overlays/InGameConsole.cc
Log:
Reverting changes made in revision 8035, that based the menu navigation on console commands, due to implemential difficulties of the hacks to make menu navigation work fully.
So, at the moment, we'll have to make due with the old version of the menu navigation implementation.
Modified: code/branches/usability/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/usability/data/defaultConfig/keybindings.ini 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/data/defaultConfig/keybindings.ini 2011-03-15 20:09:58 UTC (rev 8078)
@@ -18,7 +18,7 @@
KeyD="scale 1 moveRightLeft"
KeyDelete="scale 1 rotateRoll"
KeyDivide=
-KeyDown="scale -1 moveFrontBack | navigateGUI down"
+KeyDown="scale -1 moveFrontBack"
KeyE="scale -1 rotateRoll"
KeyEnd=boost
KeyEquals=
@@ -51,7 +51,7 @@
KeyKana=
KeyKanji=
KeyL=
-KeyLeft="scale -1 moveRightLeft | navigateGUI left"
+KeyLeft="scale -1 moveRightLeft"
KeyLeftAlt=
KeyLeftBracket=
KeyLeftControl=mouseLook
@@ -92,7 +92,7 @@
KeyNumpad9=
KeyNumpadAdd=
KeyNumpadComma=
-KeyNumpadEnter="navigateGUI enter"
+KeyNumpadEnter=
KeyNumpadEquals=
KeyNumpadPeriod=
KeyNumpadSubtract=
@@ -107,8 +107,8 @@
KeyPreviousTrack=
KeyQ="scale 1 rotateRoll"
KeyR="scale 1 moveUpDown"
-KeyReturn="navigateGUI enter"
-KeyRight="scale 1 moveRightLeft | navigateGUI right"
+KeyReturn=
+KeyRight="scale 1 moveRightLeft"
KeyRightAlt=
KeyRightBracket=
KeyRightControl="scale -1 moveUpDown"
@@ -125,7 +125,7 @@
KeyT="onpress fire 3"
KeyTab="NewHumanController changeMode"
KeyU=""
-KeyUP="scale 1 moveFrontBack | navigateGUI up"
+KeyUP="scale 1 moveFrontBack"
KeyUnassigned="InGameConsole openConsole"
KeyUnderline=
KeyUnlabeled=
Modified: code/branches/usability/data/gui/scripts/GUISheet.lua
===================================================================
--- code/branches/usability/data/gui/scripts/GUISheet.lua 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/data/gui/scripts/GUISheet.lua 2011-03-15 20:09:58 UTC (rev 8078)
@@ -28,7 +28,7 @@
end
-- Override this function if you want to react on keystrokes
-function P:onKeyPressed(mode)
+function P:onKeyPressed()
end
-- Override this function if you want to update the gui after the window was resized
@@ -84,22 +84,22 @@
end
-- Handles key pressed while the gui sheed is displayed
-function P:keyPressed(mode)
+function P:keyPressed()
if self.buttons then
- if mode == "down" then -- key down
+ if code == "208" then -- key down
self:moveSelectionRow(1)
- elseif mode == "up" then -- key up
+ elseif code == "200" then -- key up
self:moveSelectionRow(-1)
- elseif mode == "right" then -- key right
+ elseif code == "205" then -- key right
self:moveSelectionColumn(1)
- elseif mode == "left" then -- key left
+ elseif code == "203" then -- key left
self:moveSelectionColumn(-1)
- elseif mode == "enter" then -- key enter or key numpad enter
+ elseif code == "28" or code == "156" then -- key enter or key numpad enter
self:pressSelectedButton()
end
end
- self:onKeyPressed(mode)
+ self:onKeyPressed()
end
function P:windowResized()
Modified: code/branches/usability/data/gui/scripts/GraphicsMenu.lua
===================================================================
--- code/branches/usability/data/gui/scripts/GraphicsMenu.lua 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/data/gui/scripts/GraphicsMenu.lua 2011-03-15 20:09:58 UTC (rev 8078)
@@ -1,6 +1,6 @@
-- GraphicsMenu.lua
-local P = createMenuSheet("GraphicsMenu", true, TriBool.True, TriBool.True)
+local P = createMenuSheet("GraphicsMenu")
P.resolutionList = {"custom", "640 x 480", "720 x 480", "720 x 576", "800 x 600", "1024 x 600", "1024 x 768", "1152 x 864", "1280 x 720", "1280 x 800", "1280 x 960", "1280 x 1024", "1360 x 768", "1440 x 900", "1600 x 900", "1600 x 1200", "1680 x 1050"}
P.schemeList = {"TaharezGreen", "Orxonox"}
Modified: code/branches/usability/data/gui/scripts/MenuSheet.lua
===================================================================
--- code/branches/usability/data/gui/scripts/MenuSheet.lua 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/data/gui/scripts/MenuSheet.lua 2011-03-15 20:09:58 UTC (rev 8078)
@@ -15,7 +15,7 @@
local newSheet = GUISheet.new(_name)
newSheet.bHidePrevious = handleDefArg(_bHidePrevious, true)
newSheet.tShowCursor = handleDefArg(_tShowCusor, TriBool.True)
- newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, TriBool.Dontcare)
+ newSheet.tUseKeyboard = handleDefArg(_tUseKeyboard, TriBool.True)
newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
setmetatable(newSheet, P)
Modified: code/branches/usability/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/usability/data/gui/scripts/SheetManager.lua 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/data/gui/scripts/SheetManager.lua 2011-03-15 20:09:58 UTC (rev 8078)
@@ -4,8 +4,9 @@
local loadedSheets = {}
local activeMenuSheets = {size = 0, topSheetTuple = nil}
local menuSheetsRoot = guiMgr:getMenuRootWindow()
+local bInGameConsoleClosed = false
local mainMenuLoaded = false
---orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
+orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
------------------------
@@ -132,10 +133,6 @@
menuSheet:setSelectionNear(1, 1)
end
- if activeMenuSheets.size > 0 then
- guiMgr:guisActiveChanged(true)
- end
-
return menuSheet
end
@@ -206,10 +203,6 @@
hideCursor()
end
- if activeMenuSheets.size == 0 then
- guiMgr:guisActiveChanged(false)
- end
-
sheetTuple.sheet:quit()
end
@@ -223,7 +216,13 @@
function keyESC()
-- HUGE, very HUGE hacks!
- -- Count the number of sheets that don't need input until the first that does.
+ -- If the InGameConsole is active, ignore the ESC command.
+ if bInGameConsoleClosed == true then
+ bInGameConsoleClosed = false
+ return
+ end
+
+ -- Count the number of sheets that don't need input till the first that does.
local counter = noInputSheetIndex()
-- If the first sheet that needs input is the MainMenu.
@@ -237,11 +236,19 @@
end
end
--- Function to navigate the GUI, is called by the GUIManager, whenever a relevant key is pressed.
--- The mode specifies the action to be taken.
-function navigateGUI(mode)
+function keyPressed(e)
+ local we = tolua.cast(e, "CEGUI::KeyEventArgs")
local sheet = activeMenuSheets[activeMenuSheets.size]
- sheet.sheet:keyPressed(mode)
+ code = tostring(we.scancode)
+ -- Some preprocessing
+ if not mainMenuLoaded and not sheet.bNoInput then
+ if code == "1" then
+ keyESC()
+ elseif code == "0"then
+ orxonox.CommandExecutor:execute("InGameConsole openConsole")
+ end
+ end
+ sheet.sheet:keyPressed()
end
function windowResized(e)
@@ -287,6 +294,10 @@
return counter
end
+function inGameConsoleClosed()
+ bInGameConsoleClosed = not bInGameConsoleClosed;
+end
+
function getGUIFirstActive(name, bHidePrevious, bNoInput)
local sheet = activeMenuSheets.topSheetTuple
-- If the topmost gui sheet has the input name
Modified: code/branches/usability/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/usability/src/libraries/core/GUIManager.cc 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/src/libraries/core/GUIManager.cc 2011-03-15 20:09:58 UTC (rev 8078)
@@ -102,20 +102,10 @@
GUIManager* GUIManager::singletonPtr_s = 0;
/*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen";
- static const std::string __CC_navigateGUI_name = "navigateGUI";
-
SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
- SetConsoleCommand(__CC_navigateGUI_name, &GUIManager::navigateGUI).deactivate();
- //! Strings that specify modes for the GUI navigation.
- /*static*/ const std::string GUIManager::NAVIGATE_UP = "up";
- /*static*/ const std::string GUIManager::NAVIGATE_DOWN = "down";
- /*static*/ const std::string GUIManager::NAVIGATE_LEFT = "left";
- /*static*/ const std::string GUIManager::NAVIGATE_RIGHT = "right";
- /*static*/ const std::string GUIManager::NAVIGATE_ENTER = "enter";
-
/**
@brief
Constructs the GUIManager by starting up CEGUI
@@ -375,43 +365,6 @@
this->rootWindow_->setProperty("Image", image);
}
- /**
- @brief
- Method to navigate the GUI, by specifying the mode of navigation.
- @param mode
- The mode of navigation, at this point can be either 'up', 'down', 'left', 'right' or 'enter'.
- */
- /*static*/ void GUIManager::navigateGUI(const std::string& mode)
- {
- if(mode == NAVIGATE_UP)
- GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_UP + "\")");
- else if(mode == NAVIGATE_DOWN)
- GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_DOWN + "\")");
- else if(mode == NAVIGATE_LEFT)
- GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_LEFT + "\")");
- else if(mode == NAVIGATE_RIGHT)
- GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_RIGHT + "\")");
- else if(mode == NAVIGATE_ENTER)
- GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_ENTER + "\")");
- }
-
- /**
- @brief
- Is called by lua to change whether there are any GUIs active at the moment.
- @param active
- Whether GUIs are active.
- */
- void GUIManager::guisActiveChanged(bool active)
- {
- if(this->GUIsActive_ == active)
- return;
- this->GUIsActive_ = active;
- if(this->GUIsActive_)
- ModifyConsoleCommand(__CC_navigateGUI_name).activate();
- else
- ModifyConsoleCommand(__CC_navigateGUI_name).deactivate();
- }
-
void GUIManager::buttonPressed(const KeyEvent& evt)
{
this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode()));
Modified: code/branches/usability/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/usability/src/libraries/core/GUIManager.h 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/src/libraries/core/GUIManager.h 2011-03-15 20:09:58 UTC (rev 8078)
@@ -94,9 +94,6 @@
void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export
void setBackgroundImage(const std::string& image);
- static void navigateGUI(const std::string& mode);
- void guisActiveChanged(bool active); // tolua_export
-
/**
@brief Helper method to get the developer's mode without having to export Core.h.
@see Core::inDevMode
@@ -134,14 +131,6 @@
template <typename FunctionType>
bool protectedCall(FunctionType function);
- static const std::string NAVIGATE_UP;
- static const std::string NAVIGATE_DOWN;
- static const std::string NAVIGATE_LEFT;
- static const std::string NAVIGATE_RIGHT;
- static const std::string NAVIGATE_ENTER;
-
- bool GUIsActive_; //!< Whether there are any GUIs active at a given moment.
-
// keyHandler functions
void buttonPressed (const KeyEvent& evt);
void buttonReleased(const KeyEvent& evt);
Modified: code/branches/usability/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/usability/src/orxonox/gamestates/GSMainMenu.cc 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/src/orxonox/gamestates/GSMainMenu.cc 2011-03-15 20:09:58 UTC (rev 8078)
@@ -67,7 +67,7 @@
{
RegisterRootObject(GSMainMenu);
- InputManager::getInstance().createInputState("MainMenuHackery")->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
+ InputManager::getInstance().createInputState("MainMenuHackery", true, true)->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
// create an empty Scene
this->scene_ = new Scene(NULL);
Modified: code/branches/usability/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/usability/src/orxonox/overlays/InGameConsole.cc 2011-03-15 20:00:05 UTC (rev 8077)
+++ code/branches/usability/src/orxonox/overlays/InGameConsole.cc 2011-03-15 20:09:58 UTC (rev 8078)
@@ -48,6 +48,7 @@
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/command/ConsoleCommand.h"
+#include "core/GUIManager.h"
#include "core/input/InputManager.h"
#include "core/input/InputState.h"
#include "core/input/InputBuffer.h"
@@ -532,6 +533,7 @@
if (this->bActive_)
{
this->bActive_ = false;
+ GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed.
InputManager::getInstance().leaveState("console");
this->shell_->unregisterListener(this);
@@ -608,6 +610,7 @@
*/
/*static*/ void InGameConsole::closeConsole()
{
+ GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed, but not by ESC.
InGameConsole::getInstance().deactivate();
}
More information about the Orxonox-commit
mailing list