[Orxonox-commit 1548] r6266 - in code/branches/presentation2: data/gui/layouts data/gui/scripts src/libraries/core/input
dafrick at orxonox.net
dafrick at orxonox.net
Mon Dec 7 21:45:40 CET 2009
Author: dafrick
Date: 2009-12-07 21:45:39 +0100 (Mon, 07 Dec 2009)
New Revision: 6266
Added:
code/branches/presentation2/data/gui/layouts/InfoPopup.layout
code/branches/presentation2/data/gui/scripts/InfoPopup.lua
Modified:
code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout
code/branches/presentation2/data/gui/scripts/DecisionPopup.lua
code/branches/presentation2/data/gui/scripts/GUITools.lua
code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua
code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc
code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h
Log:
KeyBindMenu is working now. (Apart from some minor faults)
Found some commandExecutor("show/hideGUI ...") in DecisionPopup, and another possible bug.
Added an InfoPopup
Added: code/branches/presentation2/data/gui/layouts/InfoPopup.layout
===================================================================
--- code/branches/presentation2/data/gui/layouts/InfoPopup.layout (rev 0)
+++ code/branches/presentation2/data/gui/layouts/InfoPopup.layout 2009-12-07 20:45:39 UTC (rev 6266)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="DefaultWindow" Name="orxonox/InfoPopup_RootWindow" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/InfoPopup_Background" >
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Property Name="Alpha" Value="0.6" />
+ <Window Type="TaharezLook/Button" Name="orxonox/InfoPopup_close" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Close" />
+ <Property Name="Alpha" Value="0.7" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.55,0},{0.6,0},{0.6,0}}" />
+ <Event Name="Clicked" Function="InfoPopup.close"/>
+ </Window>
+ <Window Type="TaharezLook/StaticText" Name="orxonox/InfoPopup_text" >
+ <Property Name="Text" Value="Template text" />
+ <Property Name="HorzFormatting" Value="WordWrapCentred" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.4,0},{0.8,0},{0.5,0}}" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="Alpha" Value="0.8" />
+ </Window>
+ </Window>
+ </Window>
+</GUILayout>
Modified: code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout
===================================================================
--- code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout 2009-12-07 20:45:39 UTC (rev 6266)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<GUILayout >
- <Window Type="DefaultWindow" Name="orxonox/KeyBindBackground" >
+ <Window Type="DefaultWindow" Name="orxonox/KeyBindMenu/Background" >
<Property Name="InheritsAlpha" Value="False" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
@@ -13,7 +13,7 @@
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="VertFormatting" Value="TopAligned" />
<Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.325,0},{0.75,0},{0.6,0}}" />
- <Window Type="TaharezLook/ScrollablePane" Name="orxonox/KeyBindPane/" >
+ <Window Type="TaharezLook/ScrollablePane" Name="orxonox/KeyBindPane" >
<Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
<Property Name="HorzStepSize" Value="0.1" />
<Property Name="VertStepSize" Value="0.1" />
@@ -23,16 +23,13 @@
<Property Name="VertOverlapSize" Value="0.01" />
<Property Name="HorzScrollPosition" Value="0" />
<Property Name="VertScrollPosition" Value="0" />
- <AutoWindow NameSuffix="__auto_container__" >
- <Property Name="ContentArea" Value="l:0 t:0 r:0 b:0" />
- <Property Name="ChildExtentsArea" Value="l:0 t:0 r:0 b:0" />
- </AutoWindow>
</Window>
</Window>
<Window Type="TaharezLook/Button" Name="orxonox/KeyBindBackButton" >
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.625,0},{0.6,0},{0.675,0}}" />
+ <Event Name="Clicked" Function="KeyBindMenu.KeyBindBackButton_clicked"/>
</Window>
</Window>
</GUILayout>
Modified: code/branches/presentation2/data/gui/scripts/DecisionPopup.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/DecisionPopup.lua 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/data/gui/scripts/DecisionPopup.lua 2009-12-07 20:45:39 UTC (rev 6266)
@@ -27,14 +27,14 @@
if P.functionPtr ~= nil then
P.functionPtr(true)
end
- orxonox.CommandExecutor:execute("hideGUI DecisionPopup")
+ hideGUI("DecisionPopup")
end
function P.button_no(e)
if P.functionPtr ~= nil then
P.functionPtr(false)
end
- orxonox.CommandExecutor:execute("hideGUI DecisionPopup")
+ hideGUI("DecisionPopup")
end
return P
Modified: code/branches/presentation2/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/GUITools.lua 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/data/gui/scripts/GUITools.lua 2009-12-07 20:45:39 UTC (rev 6266)
@@ -1,6 +1,11 @@
function openDecisionPopup( text, callbackPtr )
- orxonox.CommandExecutor:execute("showGUI DecisionPopup false true")
--- showGUI("DecisionPopup", false, true)
- DecisionPopup.setCallback(InGameMenu.callback)
+ showGUI("DecisionPopup", false, true)
+ DecisionPopup.setCallback(callbackPtr)
DecisionPopup.setText(text)
-end
\ No newline at end of file
+end
+
+function openInfoPopup( text, functionPtr )
+ showGUI("InfoPopup", false, true)
+ InfoPopup.setDo(functionPtr)
+ InfoPopup.setText(text)
+end
Added: code/branches/presentation2/data/gui/scripts/InfoPopup.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/InfoPopup.lua (rev 0)
+++ code/branches/presentation2/data/gui/scripts/InfoPopup.lua 2009-12-07 20:45:39 UTC (rev 6266)
@@ -0,0 +1,34 @@
+-- InfoPopup.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ InfoPopup = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "InfoPopup"
+P.layoutString = "InfoPopup.layout"
+
+function P:init()
+end
+
+function P.setDo(functionPtr)
+ P.functionPtr = functionPtr
+ if P.functionPtr ~= nil then
+ P.functionPtr()
+ end
+end
+
+function P.setText( text )
+ winMgr:getWindow("orxonox/InfoPopup_text"):setText( text )
+end
+
+-- events for ingamemenu
+function P.close(e)
+ hideGUI("InfoPopup")
+end
+
+return P
+
Modified: code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/data/gui/scripts/InitialiseGUI.lua 2009-12-07 20:45:39 UTC (rev 6266)
@@ -221,3 +221,7 @@
end
return nil
end
+
+function test(e)
+ debug(0, "Blubb")
+end
Modified: code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua 2009-12-07 20:45:39 UTC (rev 6266)
@@ -1,18 +1,66 @@
--- NewMouseControlsMenu.lua
+-- KeyBindMenu.lua
BasicGUI = require("BasicGUI")
local P = BasicGUI:new() --inherit everything from the gui package
if _REQUIREDNAME == nil then
- NewMouseControlsMenu = P
+ KeyBindMenu = P
else
_G[_REQUIREDNAME] = P
end
-P.filename = "NewMouseControlsMenu"
-P.layoutString = "NewMouseControlsMenu.layout"
+P.filename = "KeyBindMenu"
+P.layoutString = "KeyBindMenu.layout"
+function P:init()
+ commandList = {}
+ table.insert(commandList, "fire 0")
+ table.insert(commandList, "fire 1")
+ table.insert(commandList, "fire 2")
+
+ local lineHeight = 30
+
+ local window = winMgr:getWindow("orxonox/KeyBindPane")
+
+ for k,v in pairs(commandList) do
+ local button = winMgr:createWindow("TaharezLook/Button", "orxonox/KeyBindPane/Binding" .. k .. "/Button")
+ local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
+ local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
+
+ line:setSize(CEGUI.UVector2(CEGUI.UDim(1,-13),CEGUI.UDim(0, lineHeight)))
+ button:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(1, 0)))
+ command:setSize(CEGUI.UVector2(CEGUI.UDim(0.6, 0), CEGUI.UDim(1, 0)))
+
+ button:setPosition(CEGUI.UVector2(CEGUI.UDim(0.6, 0),CEGUI.UDim(0, 0)))
+ command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0),CEGUI.UDim(0, 0)))
+ line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0),CEGUI.UDim(0, lineHeight*(k-1))))
+
+ button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(v))
+ command:setText(v)
+
+ orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
+ --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
+
+ line:addChildWindow(command)
+ line:addChildWindow(button)
+ window:addChildWindow(line)
+ end
+end
+
+function P.KeyBindButton_clicked(e)
+ local we = CEGUI.toWindowEventArgs(e)
+ local name = we.window:getName()
+ commandNr = tonumber(string.match(name, "%d+"))
+
+ openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind)
+
+end
+
+function P.keybind()
+ orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
+end
+
function P.KeyBindBackButton_clicked(e)
- hideGUI("NewMouseControlsMenu")
+ hideGUI("KeyBindMenu")
debug("event: back")
end
Modified: code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc 2009-12-07 20:45:39 UTC (rev 6266)
@@ -37,6 +37,8 @@
#include "InputManager.h"
#include "KeyDetector.h"
+#include <CEGUIWindow.h>
+
namespace orxonox
{
ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
@@ -90,6 +92,11 @@
else
this->bDefaultFileLoaded_ = false;
}
+
+ void KeyBinderManager::subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function)
+ {
+ window->subscribeScriptedEvent(event, function);
+ }
void KeyBinderManager::load(const std::string& filename)
{
Modified: code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h 2009-12-07 13:23:46 UTC (rev 6265)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinderManager.h 2009-12-07 20:45:39 UTC (rev 6266)
@@ -36,6 +36,8 @@
#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
+#include <CEGUIForwardRefs.h>
+
namespace orxonox //tolua_export
{ //tolua_export
/**
@@ -78,6 +80,8 @@
//! Selects the default KeyBinder as current one
void setToDefault()
{ this->setCurrent(this->defaultFilename_); }
+
+ void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
//! Returns a pointer to a KeyBinder (creates it if not yet loaded)
KeyBinder* get(const std::string& name);
@@ -90,8 +94,7 @@
void unload(const std::string& filename);
//! Bind 'command' to any key pressed after this call (use with care!)
- inline void keybind(const std::string& command)
- { this->keybindInternal(command, false); }
+ inline void keybind(const std::string& command) { this->keybindInternal(command, false); } //tolua_export
//! Bind 'command' to any key pressed after this call (use with care!), but temporarily (no file save)
inline void tkeybind(const std::string& command)
{ this->keybindInternal(command, true); }
More information about the Orxonox-commit
mailing list