[Orxonox-commit 1606] r6324 - in code/branches/presentation2/data/gui: layouts scripts

dafrick at orxonox.net dafrick at orxonox.net
Fri Dec 11 17:24:32 CET 2009


Author: dafrick
Date: 2009-12-11 17:24:32 +0100 (Fri, 11 Dec 2009)
New Revision: 6324

Modified:
   code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout
   code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
Log:
Improved KeyBindMenu further. This is the final version for the presentation, unless there are some complaints.


Modified: code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout
===================================================================
--- code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout	2009-12-11 13:22:58 UTC (rev 6323)
+++ code/branches/presentation2/data/gui/layouts/KeyBindMenu.layout	2009-12-11 16:24:32 UTC (rev 6324)
@@ -12,21 +12,21 @@
             <Property Name="HorzFormatting" Value="HorzCentred" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="VertFormatting" Value="TopAligned" />
-            <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.25,0},{0.8,0},{0.6,0}}" />
-            <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindText" >
+            <Property Name="UnifiedAreaRect" Value="{{0.1,0},{0.1,0},{0.9,0},{0.8,0}}" />
+            <Window Type="TaharezLook/StaticText" Name="orxonox/KeyBindWrapper" >
                 <Property Name="TextColours" Value="FF4444FF" />
                 <Property Name="InheritsAlpha" Value="False" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="HorzFormatting" Value="HorzCentred" />
                 <Property Name="VertFormatting" Value="TopAligned" />
-                <Property Name="UnifiedAreaRect" Value="{{0.041666,0},{0.15,0},{0.958333,0},{0.92,0}}" />
+                    <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.95,0}}" />
                 <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" />
                     <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                     <Property Name="HorzOverlapSize" Value="0.01" />
-                    <Property Name="UnifiedAreaRect" Value="{{0.04,0},{0.005,0},{0.999,0},{0.99,0}}" />
+                    <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
                     <Property Name="VertOverlapSize" Value="0.01" />
                     <Property Name="HorzScrollPosition" Value="0" />
                     <Property Name="VertScrollPosition" Value="0" />
@@ -36,7 +36,7 @@
         <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}}" />
+            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.825,0},{0.6,0},{0.875,0}}" />
             <Event Name="Clicked" Function="KeyBindMenu.KeyBindBackButton_clicked"/>
         </Window>
     </Window>

Modified: code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua	2009-12-11 13:22:58 UTC (rev 6323)
+++ code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua	2009-12-11 16:24:32 UTC (rev 6324)
@@ -55,62 +55,90 @@
     linesList = {}
 
     lineHeight = 35
+    commandWidth = 200
     buttonWidth = 170
     clearWidth = 20
+    spaceWidth = 10
     
-    local window = winMgr:getWindow("orxonox/KeyBindPane")
-
-    for k,v in pairs(commandList) do
-        local line = P.createLine(k)
-        table.insert(linesList, line)
-        window:addChildWindow(line)
-    end
+    P.createLines()
     
     local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
     orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
 end
 
+
+function P.KeyNameNiceifier(key)
+    local name = string.sub(key, string.find(key, '%.(.*)')+1)
+    local group = string.sub(key, string.find(key, '(.*)%.'))
+    group = string.sub(group,1,string.len(group)-1)
+    if( group == "Keys") then
+        return "Key " .. string.sub(name, string.find(name, 'Key(.*)')+3)
+    elseif( group == "MouseButtons") then
+        return "Mouse " .. name
+    end
+    return key
+end
+
 function P.createLine(k)
+    local offset = 0
     local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
     line:setHeight(CEGUI.UDim(0, lineHeight))
     line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
     
     local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
-    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, 200), CEGUI.UDim(1, 0)))
-    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
+    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(0.9, 0)))
+    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     command:setText(nameList[k])
     line:addChildWindow(command)
+    offset = offset + commandWidth + spaceWidth
     
     local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
-    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(1, 0)))
-    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 200), CEGUI.UDim(0, 0)))
+    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
+    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
     plus:setText("+")
     orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
     line:addChildWindow(plus)
+    offset = offset + clearWidth + spaceWidth
     
-    numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
+    local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
     for i=0,(numButtons-1) do
         local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
-        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.8, 0)))
-        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth))+200+clearWidth), CEGUI.UDim(0.1, 0)))
-        button:setText(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i))
+        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
+        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
+        local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
+        name = P.KeyNameNiceifier(name)
+        button:setText(name)
         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
         --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
         line:addChildWindow(button)
+        offset = offset + buttonWidth
         
         local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
-        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.8, 0)))
-        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth)+buttonWidth)+200+clearWidth), CEGUI.UDim(0.1, 0)))
+        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
+        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth+spaceWidth)+buttonWidth)+commandWidth+clearWidth+2*spaceWidth), CEGUI.UDim(0.15, 0)))
         clear:setText("X")
         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
         line:addChildWindow(clear)
+        offset = offset + clearWidth + spaceWidth
     end
     
-    line:setWidth(CEGUI.UDim(0, 200+numButtons*(buttonWidth+clearWidth)+clearWidth))
+    line:setWidth(CEGUI.UDim(0, offset+clearWidth))
     
     return line
 end
 
+function P.createLines()
+
+    local window = winMgr:getWindow("orxonox/KeyBindPane")
+
+    for k,v in pairs(commandList) do
+        local line = P.createLine(k)
+        table.insert(linesList, line)
+        window:addChildWindow(line)
+    end
+
+end
+
 function P.KeyBindButton_clicked(e)
     local we = CEGUI.toWindowEventArgs(e)
     local name = we.window:getName()
@@ -169,12 +197,7 @@
     
     linesList = {}
 
-    window = winMgr:getWindow("orxonox/KeyBindPane")
-    for q,w in pairs(commandList) do
-        local line = P.createLine(q)
-        table.insert(linesList, line)
-        window:addChildWindow(line)
-    end
+    P.createLines()
     
     if(InfoPopup ~= nil) then
         InfoPopup.close()




More information about the Orxonox-commit mailing list