[Orxonox-commit 2991] r7687 - code/branches/menu/data/gui/scripts

konrad at orxonox.net konrad at orxonox.net
Wed Dec 1 14:04:55 CET 2010


Author: konrad
Date: 2010-12-01 14:04:54 +0100 (Wed, 01 Dec 2010)
New Revision: 7687

Modified:
   code/branches/menu/data/gui/scripts/AudioMenu.lua
   code/branches/menu/data/gui/scripts/ControlsMenu.lua
   code/branches/menu/data/gui/scripts/CreditsMenu.lua
   code/branches/menu/data/gui/scripts/GUITools.lua
   code/branches/menu/data/gui/scripts/GraphicsMenu.lua
   code/branches/menu/data/gui/scripts/HostMenu.lua
   code/branches/menu/data/gui/scripts/MainMenu.lua
   code/branches/menu/data/gui/scripts/MultiplayerMenu.lua
   code/branches/menu/data/gui/scripts/SettingsMenu.lua
   code/branches/menu/data/gui/scripts/SingleplayerMenu.lua
Log:

--function to iterate throgh a menusheet by using arrowkeys is added


Modified: code/branches/menu/data/gui/scripts/AudioMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/AudioMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/AudioMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -2,6 +2,13 @@
 
 local P = createMenuSheet("AudioMenu")
 
+P.buttonList = {}
+
+function P.onShow()
+    P.oldindex = -2
+    P.index = -1
+end
+
 function P.onLoad()
     soundMgr = orxonox.SoundManager:getInstance()
     block = false
@@ -41,6 +48,12 @@
     else
         listboxwindow:setItemSelectState(0,true)
     end
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
+            ["function"]  = P.AudioBackButton_clicked
+    }
+    P.buttonList[1] = item
 end
 
 function P.AudioMasterScrollbar_changed(e)
@@ -171,5 +184,9 @@
     hideMenuSheet(P.name)
 end
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
 return P
 

Modified: code/branches/menu/data/gui/scripts/ControlsMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/ControlsMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/ControlsMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -1,8 +1,39 @@
 -- ControlsMenu.lua
 
 local P = createMenuSheet("ControlsMenu")
+P.buttonList = {}
 P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
 
+function P.onLoad()
+    P.multiplayerMode = "startClient" 
+
+    --buttons are arranged in a 3x1 matrix:
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
+            ["function"]  = P.ControlsMouseControlsButton_clicked
+    }
+    P.buttonList[1] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
+            ["function"]  = P.ControlsKeyboardControlsButton_clicked
+    }
+    P.buttonList[2] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
+            ["function"]  = P.ControlsBackButton_clicked
+    }
+    P.buttonList[3] = item
+
+end
+
+function P.onShow()
+    --indices to iterate through buttonlist
+    P.oldindex = -2
+    P.index = -1
+end
+
 function P.ControlsMouseControlsButton_clicked(e)
     showMenuSheet("MouseControlsMenu", true)
 end
@@ -15,5 +46,9 @@
     hideMenuSheet(P.name)
 end
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 3, 1)
+end
+
 return P
 

Modified: code/branches/menu/data/gui/scripts/CreditsMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/CreditsMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/CreditsMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -13,6 +13,7 @@
 end
 
 function P.onShow()
+    --indices to iterate through buttonlist
     P.oldindex = -2
     P.index = -1
 end

Modified: code/branches/menu/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/menu/data/gui/scripts/GUITools.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/GUITools.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -54,16 +54,20 @@
     return height
 end
 
+--function to iterate through a menu sheet by using arrowkeys
 
 -- at arguments:
 --  list: 2-dimensional table, arguments are items that contain a button and its function
+--        !!note: each button can only be in the list once!!
 --  code: code of any key on the keyboard
 --  P: menusheet
---  n: number of rows
---  m: number of colums
+--  n: number of rows of the buttontable
+--  m: number of colums of the buttontable
 
 function buttonIteratorHelper(list, code, P, n, m)
 
+    --after a key (down,up,left,right) is pressed the index of the current button has to be updated    
+
     --key down
     if code == "208" then
         if P.index < 0 then     -- initial status
@@ -71,9 +75,9 @@
             P.oldindex = -1
         else
             P.oldindex = P.index
-            P.index = (P.index + m) % (m*n)
-
-            while list[P.index+1] == nil do
+            P.index = (P.index + m) % (m*n)     --modulo operation works as a "wrap around" in the button menu
+                                                
+            while list[P.index+1] == nil do     
                 P.oldindex = P.index
                 P.index = (P.index + m) % (m*n)
             end
@@ -97,7 +101,6 @@
             P.index = (P.index -m) % (m*n)
 
             while list[P.index+1] == nil do
-                cout(0,P.index)
                 P.oldindex = P.index
                 P.index = (P.index-m)%(m*n)
             end
@@ -161,6 +164,7 @@
         end
     end
        
+    --to update the new current button
     if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
 
         local system = CEGUI.System:getSingleton()
@@ -170,7 +174,6 @@
         local child = item["button"] 
 
         --teste ob der Button nicht schon gehighlightet ist
-        cout(0,child:getProperty("NormalImageRightEdge"))
         if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
             --nop
         else
@@ -188,6 +191,7 @@
             end
         end
 
+        --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
         local i = 1
         while i < (n*m) do
             if i == P.index +1 then 
@@ -219,11 +223,10 @@
         foo()
     end
 
-    cout(0, P.oldindex)
-    cout(0, P.index)
-
 end
 
+--write index and oldindex on the console
+--works like buttonIteratorHelper
 function indexTester(list,code,P,n,m)
     --key down
     if code == "208" then

Modified: code/branches/menu/data/gui/scripts/GraphicsMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/GraphicsMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/GraphicsMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -2,6 +2,14 @@
 
 local P = createMenuSheet("GraphicsMenu")
 
+P.buttonList = {}
+
+function P.onShow()
+    --indices to iterate through buttonlist (trivial in this menu sheet)
+    P.oldindex = -2
+    P.index = -1
+end
+
 function P.onLoad()
     block = true
     file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
@@ -82,6 +90,12 @@
     end
     scrollbar_active = false
     block = false
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
+            ["function"]  = P.GraphicsBackButton_clicked
+    }
+    P.buttonList[1] = item
 end
 
 function P.GraphicsResolutionListbox_changed(e)
@@ -194,5 +208,9 @@
     hideMenuSheet(P.name)
 end
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
+end
+
 return P
 

Modified: code/branches/menu/data/gui/scripts/HostMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/HostMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/HostMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -4,6 +4,24 @@
 
 P.multiplayerMode = "startServer"
 
+P.buttonList = {}
+
+function P.onLoad()
+    P.multiplayerMode = "startClient" 
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"),
+            ["function"]  = P.HostMenuStartButton_clicked
+    }
+    P.buttonList[1] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"),
+            ["function"]  = P.HostMenuBackButton_clicked
+    }
+    P.buttonList[2] = item
+end
+
 function P.onShow()
     if P.multiplayerMode == "startServer" then
         local window = winMgr:getWindow("orxonox/HostMenuHostButton")
@@ -19,6 +37,9 @@
         P.showLevelList()
     end
 
+    P.oldindex = -2
+    P.index = -1
+
 end
 
 function P.HostMenuBuildServerButton_clicked(e)
@@ -79,5 +100,10 @@
 end
 
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 1, 2)
+end
 
+
+
 return P

Modified: code/branches/menu/data/gui/scripts/MainMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/MainMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/MainMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -5,10 +5,8 @@
 
 P.buttonList = {}
 
-P.testArray = {}
-
-
 function P.onLoad()
+    --buttons are arranged in a 6x1 Matrix (list)
     local item = {
             ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
             ["function"]  = P.QuickGameTestButton_clicked
@@ -47,6 +45,7 @@
 end
 
 function P.onShow()
+    --indices to iterate through buttonlist
     P.oldindex = -2
     P.index = -1
 end
@@ -77,42 +76,8 @@
     orxonox.execute("exit")
 end
 
-
---[[
-list = {}
-local item =
-{
-    ["button"] = buttonWindow,
-    ["function"]  = buttonFunction,
-}
-table.insert(list, item)
-item = list[i]
-
-for i,item in pairs(list) do
-    button = item["button"]
-end
-
---]]
---[[
-function createList()
-    list = {}
-
-    local j 
-    while j < P.loadAlong 
-        local item =
-        {
-            ["button"] = buttonWindow,
-            ["function"]  = buttonFunction,
-        }
-        table.insert(list, item)
-    end
-
---]]
-
 function P.onKeyPressed() 
-    cout(0,code)
     buttonIteratorHelper(P.buttonList, code, P, 6, 1)
-    --indexTester(P.buttonList,code,P,6,1)
 end
 
 return P

Modified: code/branches/menu/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/MultiplayerMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/MultiplayerMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -7,15 +7,16 @@
 function P.onLoad()
     P.multiplayerMode = "startClient" 
 
+    --button are arranged in a 2x2 matrix, the left lower item is nil
     local item = {
             ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton2"),
-            ["function"]  = P.MultiplayerJoinButton_clicked
+            ["function"]  = P.MultiplayerJoinButton2_clicked
     }
     P.buttonList[1] = item
 
     local item = {
             ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton2"),
-            ["function"]  = P.MultiplayerHostButton_clicked
+            ["function"]  = P.MultiplayerHostButton2_clicked
     }
     P.buttonList[2] = item
 
@@ -29,6 +30,8 @@
 
 function P.onShow()
     P.showServerList()
+
+    --indices to iterate through buttonlist
     P.oldindex = -2
     P.index = -1
 end
@@ -132,9 +135,7 @@
 end
 
 function P.onKeyPressed() 
-    cout(0,code)
     buttonIteratorHelper(P.buttonList, code, P, 2, 2)
-    --indexTester(P.buttonList,code,P,2,3)
 end
 
 return P

Modified: code/branches/menu/data/gui/scripts/SettingsMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/SettingsMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/SettingsMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -7,7 +7,7 @@
 
 function P.onLoad()
     --"Gameplay" and "Multiplayer Options" are not integrated in the list
-    
+    --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
     local item = {
             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
             ["function"]  = P.SettingsGraphicsButton_clicked
@@ -42,6 +42,7 @@
 end
 
 function P.onShow()
+    --indices to iterate through buttonlist
     P.oldindex = 3
     P.index = 2
 end
@@ -75,9 +76,7 @@
 end
 
 function P.onKeyPressed() 
-    cout(0,code)
     buttonIteratorHelper(P.buttonList, code, P, 4, 2)
-    --indexTester(P.buttonList,code,P,4,2)
 end
 
 return P

Modified: code/branches/menu/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/menu/data/gui/scripts/SingleplayerMenu.lua	2010-12-01 13:01:48 UTC (rev 7686)
+++ code/branches/menu/data/gui/scripts/SingleplayerMenu.lua	2010-12-01 13:04:54 UTC (rev 7687)
@@ -2,6 +2,8 @@
 
 local P = createMenuSheet("SingleplayerMenu")
 
+P.buttonList = {}
+
 function P.onLoad()
     listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
     preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
@@ -27,8 +29,27 @@
         end
     end
 
+    --buttons are arranged in a 1x2 matrix
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
+            ["function"]  = P.SingleplayerStartButton_clicked
+    }
+    P.buttonList[1] = item
+
+    local item = {
+            ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
+            ["function"]  = P.SingleplayerBackButton_clicked
+    }
+    P.buttonList[2] = item
+
 end
 
+function P.onShow()
+    --indices to iterate through buttonlist
+    P.oldindex = -2
+    P.index = -1
+end
+
 function P.SingleplayerStartButton_clicked(e)
     local choice = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")):getFirstSelectedItem()
     if choice then
@@ -42,5 +63,9 @@
     hideMenuSheet(P.name)
 end
 
+function P.onKeyPressed() 
+    buttonIteratorHelper(P.buttonList, code, P, 1, 2)
+end
+
 return P
 




More information about the Orxonox-commit mailing list