[Orxonox-commit 2904] r7607 - in code/branches/menu/data/gui: layouts scripts

dafrick at orxonox.net dafrick at orxonox.net
Tue Nov 2 23:30:44 CET 2010


Author: dafrick
Date: 2010-11-02 23:30:44 +0100 (Tue, 02 Nov 2010)
New Revision: 7607

Modified:
   code/branches/menu/data/gui/layouts/MainMenu.layout
   code/branches/menu/data/gui/scripts/GUISheet.lua
   code/branches/menu/data/gui/scripts/MainMenu.lua
   code/branches/menu/data/gui/scripts/SheetManager.lua
Log:
Some improvement on keypressed behaviour. Lua is acting up a little, though, don't yet know why exactly...


Modified: code/branches/menu/data/gui/layouts/MainMenu.layout
===================================================================
--- code/branches/menu/data/gui/layouts/MainMenu.layout	2010-11-02 21:36:20 UTC (rev 7606)
+++ code/branches/menu/data/gui/layouts/MainMenu.layout	2010-11-02 22:30:44 UTC (rev 7607)
@@ -7,6 +7,7 @@
         <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
         <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1.0,0},{1.0,0}}" />
         <Property Name="BackgroundEnabled" Value="False" />
+        <Event Name="KeyDown" Function="MainMenu.Key_clicked"/>
         <Window Type="MenuWidgets/Button" Name="orxonox/QuickGameTestButton" >
             <Property Name="Text" Value="Quickstart" />
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" />
@@ -42,6 +43,5 @@
             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
             <Event Name="Clicked" Function="MainMenu.ExitButton_clicked"/>
         </Window>
-        <Event Name="KeyDown" Function="MainMenu.Key_clicked"/>
     </Window>
 </GUILayout>

Modified: code/branches/menu/data/gui/scripts/GUISheet.lua
===================================================================
--- code/branches/menu/data/gui/scripts/GUISheet.lua	2010-11-02 21:36:20 UTC (rev 7606)
+++ code/branches/menu/data/gui/scripts/GUISheet.lua	2010-11-02 22:30:44 UTC (rev 7607)
@@ -63,4 +63,7 @@
     return self
 end
 
+function P:onKeyPressed(e)
+end
+
 return P

Modified: code/branches/menu/data/gui/scripts/MainMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/MainMenu.lua	2010-11-02 21:36:20 UTC (rev 7606)
+++ code/branches/menu/data/gui/scripts/MainMenu.lua	2010-11-02 22:30:44 UTC (rev 7607)
@@ -11,6 +11,10 @@
     orxonox.execute("startGame")
 end
 
+function P.onShow()
+
+end
+
 function P.SingleplayerButton_clicked(e)
     showMenuSheet("SingleplayerMenu", true)
 end
@@ -31,7 +35,37 @@
     orxonox.execute("exit")
 end
 
-function P.Key_clicked(e)
+function P.onKeyPressed()
+    --local we = tolua.cast(e, "CEGUI::KeyEventArgs")
+    cout(0, code)
+    if code == "15" then
+        P.index = P.index + 1
+        local window = winMgr:getWindow("orxonox/MainMenuBackground")
+        if P.index == window:getChildCount() then
+            P.index = 1
+        end
+        local child = window:getChildAtIdx(P.index-1)
+        child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
+        child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
+        child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
+    elseif code == "28" and P.index ~= 0 then
+        if P.index == 1 then
+            P.QuickGameTestButton_clicked()
+        elseif P.index == 2 then
+            P.SingleplayerButton_clicked()
+        elseif P.index == 3 then
+            P.MultiplayerButton_clicked()
+        elseif P.index == 4 then
+            P.SettingsButton_clicked()
+        elseif P.index == 5 then
+            P.CreditsButton_clicked()
+        elseif P.index == 6 then
+            P.ExitButton_clicked()
+        end
+    end
+end
+
+--[[function P.Key_clicked(e)
     local we = tolua.cast(e, "CEGUI::KeyEventArgs")
     cout(0, tostring(we.scancode))
     if tostring(we.scancode) == "15" then
@@ -59,7 +93,6 @@
             P.ExitButton_clicked()
         end
     end
-end
+end]]--
 
 return P
-

Modified: code/branches/menu/data/gui/scripts/SheetManager.lua
===================================================================
--- code/branches/menu/data/gui/scripts/SheetManager.lua	2010-11-02 21:36:20 UTC (rev 7606)
+++ code/branches/menu/data/gui/scripts/SheetManager.lua	2010-11-02 22:30:44 UTC (rev 7607)
@@ -4,6 +4,7 @@
 local loadedSheets = {}
 local activeMenuSheets = {size = 0, topSheetTuple = nil}
 local menuSheetsRoot = guiMgr:getMenuRootWindow()
+orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
 
 -----------------------
 --- Local functions ---
@@ -119,6 +120,7 @@
     end
 
     menuSheet:show()
+    menuSheetsRoot:activate()
 
     return menuSheet
 end
@@ -212,6 +214,13 @@
     end
 end
 
+function keyPressed(e)
+    local we = tolua.cast(e, "CEGUI::KeyEventArgs")
+    local sheet = activeMenuSheets[activeMenuSheets.size]
+    code = tostring(we.scancode)
+    sheet.sheet:onKeyPressed()
+end
+
 function setBackgroundImage(imageSet, imageName)
     guiMgr:setBackgroundImage(imageSet, imageName)
 end




More information about the Orxonox-commit mailing list