Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7687


Ignore:
Timestamp:
Dec 1, 2010, 2:04:54 PM (13 years ago)
Author:
konrad
Message:

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

Location:
code/branches/menu/data/gui/scripts
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menu/data/gui/scripts/AudioMenu.lua

    r6746 r7687  
    22
    33local P = createMenuSheet("AudioMenu")
     4
     5P.buttonList = {}
     6
     7function P.onShow()
     8    P.oldindex = -2
     9    P.index = -1
     10end
    411
    512function P.onLoad()
     
    4249        listboxwindow:setItemSelectState(0,true)
    4350    end
     51
     52    local item = {
     53            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
     54            ["function"]  = P.AudioBackButton_clicked
     55    }
     56    P.buttonList[1] = item
    4457end
    4558
     
    172185end
    173186
     187function P.onKeyPressed()
     188    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
     189end
     190
    174191return P
    175192
  • code/branches/menu/data/gui/scripts/ControlsMenu.lua

    r6748 r7687  
    22
    33local P = createMenuSheet("ControlsMenu")
     4P.buttonList = {}
    45P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
     6
     7function P.onLoad()
     8    P.multiplayerMode = "startClient"
     9
     10    --buttons are arranged in a 3x1 matrix:
     11    local item = {
     12            ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
     13            ["function"]  = P.ControlsMouseControlsButton_clicked
     14    }
     15    P.buttonList[1] = item
     16
     17    local item = {
     18            ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
     19            ["function"]  = P.ControlsKeyboardControlsButton_clicked
     20    }
     21    P.buttonList[2] = item
     22
     23    local item = {
     24            ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
     25            ["function"]  = P.ControlsBackButton_clicked
     26    }
     27    P.buttonList[3] = item
     28
     29end
     30
     31function P.onShow()
     32    --indices to iterate through buttonlist
     33    P.oldindex = -2
     34    P.index = -1
     35end
    536
    637function P.ControlsMouseControlsButton_clicked(e)
     
    1647end
    1748
     49function P.onKeyPressed()
     50    buttonIteratorHelper(P.buttonList, code, P, 3, 1)
     51end
     52
    1853return P
    1954
  • code/branches/menu/data/gui/scripts/CreditsMenu.lua

    r7663 r7687  
    1414
    1515function P.onShow()
     16    --indices to iterate through buttonlist
    1617    P.oldindex = -2
    1718    P.index = -1
  • code/branches/menu/data/gui/scripts/GUITools.lua

    r7663 r7687  
    5555end
    5656
     57--function to iterate through a menu sheet by using arrowkeys
    5758
    5859--@arguments:
    5960--  list: 2-dimensional table, arguments are items that contain a button and its function
     61--        !!note: each button can only be in the list once!!
    6062--  code: code of any key on the keyboard
    6163--  P: menusheet
    62 --  n: number of rows
    63 --  m: number of colums
     64--  n: number of rows of the buttontable
     65--  m: number of colums of the buttontable
    6466
    6567function buttonIteratorHelper(list, code, P, n, m)
     68
     69    --after a key (down,up,left,right) is pressed the index of the current button has to be updated   
    6670
    6771    --key down
     
    7276        else
    7377            P.oldindex = P.index
    74             P.index = (P.index + m) % (m*n)
    75 
    76             while list[P.index+1] == nil do
     78            P.index = (P.index + m) % (m*n)     --modulo operation works as a "wrap around" in the button menu
     79                                               
     80            while list[P.index+1] == nil do     
    7781                P.oldindex = P.index
    7882                P.index = (P.index + m) % (m*n)
     
    98102
    99103            while list[P.index+1] == nil do
    100                 cout(0,P.index)
    101104                P.oldindex = P.index
    102105                P.index = (P.index-m)%(m*n)
     
    162165    end
    163166       
     167    --to update the new current button
    164168    if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
    165169
     
    171175
    172176        --teste ob der Button nicht schon gehighlightet ist
    173         cout(0,child:getProperty("NormalImageRightEdge"))
    174177        if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then
    175178            --nop
     
    189192        end
    190193
     194        --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
    191195        local i = 1
    192196        while i < (n*m) do
     
    220224    end
    221225
    222     cout(0, P.oldindex)
    223     cout(0, P.index)
    224 
    225 end
    226 
     226end
     227
     228--write index and oldindex on the console
     229--works like buttonIteratorHelper
    227230function indexTester(list,code,P,n,m)
    228231    --key down
  • code/branches/menu/data/gui/scripts/GraphicsMenu.lua

    r6746 r7687  
    22
    33local P = createMenuSheet("GraphicsMenu")
     4
     5P.buttonList = {}
     6
     7function P.onShow()
     8    --indices to iterate through buttonlist (trivial in this menu sheet)
     9    P.oldindex = -2
     10    P.index = -1
     11end
    412
    513function P.onLoad()
     
    8391    scrollbar_active = false
    8492    block = false
     93
     94    local item = {
     95            ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
     96            ["function"]  = P.GraphicsBackButton_clicked
     97    }
     98    P.buttonList[1] = item
    8599end
    86100
     
    195209end
    196210
     211function P.onKeyPressed()
     212    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
     213end
     214
    197215return P
    198216
  • code/branches/menu/data/gui/scripts/HostMenu.lua

    r7587 r7687  
    44
    55P.multiplayerMode = "startServer"
     6
     7P.buttonList = {}
     8
     9function P.onLoad()
     10    P.multiplayerMode = "startClient"
     11
     12    local item = {
     13            ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"),
     14            ["function"]  = P.HostMenuStartButton_clicked
     15    }
     16    P.buttonList[1] = item
     17
     18    local item = {
     19            ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"),
     20            ["function"]  = P.HostMenuBackButton_clicked
     21    }
     22    P.buttonList[2] = item
     23end
    624
    725function P.onShow()
     
    1937        P.showLevelList()
    2038    end
     39
     40    P.oldindex = -2
     41    P.index = -1
    2142
    2243end
     
    80101
    81102
     103function P.onKeyPressed()
     104    buttonIteratorHelper(P.buttonList, code, P, 1, 2)
     105end
     106
     107
    82108
    83109return P
  • code/branches/menu/data/gui/scripts/MainMenu.lua

    r7663 r7687  
    66P.buttonList = {}
    77
    8 P.testArray = {}
    9 
    10 
    118function P.onLoad()
     9    --buttons are arranged in a 6x1 Matrix (list)
    1210    local item = {
    1311            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
     
    4846
    4947function P.onShow()
     48    --indices to iterate through buttonlist
    5049    P.oldindex = -2
    5150    P.index = -1
     
    7877end
    7978
    80 
    81 --[[
    82 list = {}
    83 local item =
    84 {
    85     ["button"] = buttonWindow,
    86     ["function"]  = buttonFunction,
    87 }
    88 table.insert(list, item)
    89 item = list[i]
    90 
    91 for i,item in pairs(list) do
    92     button = item["button"]
    93 end
    94 
    95 --]]
    96 --[[
    97 function createList()
    98     list = {}
    99 
    100     local j
    101     while j < P.loadAlong
    102         local item =
    103         {
    104             ["button"] = buttonWindow,
    105             ["function"]  = buttonFunction,
    106         }
    107         table.insert(list, item)
    108     end
    109 
    110 --]]
    111 
    11279function P.onKeyPressed()
    113     cout(0,code)
    11480    buttonIteratorHelper(P.buttonList, code, P, 6, 1)
    115     --indexTester(P.buttonList,code,P,6,1)
    11681end
    11782
  • code/branches/menu/data/gui/scripts/MultiplayerMenu.lua

    r7663 r7687  
    88    P.multiplayerMode = "startClient"
    99
     10    --button are arranged in a 2x2 matrix, the left lower item is nil
    1011    local item = {
    1112            ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton2"),
    12             ["function"]  = P.MultiplayerJoinButton_clicked
     13            ["function"]  = P.MultiplayerJoinButton2_clicked
    1314    }
    1415    P.buttonList[1] = item
     
    1617    local item = {
    1718            ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton2"),
    18             ["function"]  = P.MultiplayerHostButton_clicked
     19            ["function"]  = P.MultiplayerHostButton2_clicked
    1920    }
    2021    P.buttonList[2] = item
     
    3031function P.onShow()
    3132    P.showServerList()
     33
     34    --indices to iterate through buttonlist
    3235    P.oldindex = -2
    3336    P.index = -1
     
    133136
    134137function P.onKeyPressed()
    135     cout(0,code)
    136138    buttonIteratorHelper(P.buttonList, code, P, 2, 2)
    137     --indexTester(P.buttonList,code,P,2,3)
    138139end
    139140
  • code/branches/menu/data/gui/scripts/SettingsMenu.lua

    r7663 r7687  
    88function P.onLoad()
    99    --"Gameplay" and "Multiplayer Options" are not integrated in the list
    10    
     10    --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
    1111    local item = {
    1212            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
     
    4343
    4444function P.onShow()
     45    --indices to iterate through buttonlist
    4546    P.oldindex = 3
    4647    P.index = 2
     
    7677
    7778function P.onKeyPressed()
    78     cout(0,code)
    7979    buttonIteratorHelper(P.buttonList, code, P, 4, 2)
    80     --indexTester(P.buttonList,code,P,4,2)
    8180end
    8281
  • code/branches/menu/data/gui/scripts/SingleplayerMenu.lua

    r7163 r7687  
    22
    33local P = createMenuSheet("SingleplayerMenu")
     4
     5P.buttonList = {}
    46
    57function P.onLoad()
     
    2830    end
    2931
     32    --buttons are arranged in a 1x2 matrix
     33    local item = {
     34            ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
     35            ["function"]  = P.SingleplayerStartButton_clicked
     36    }
     37    P.buttonList[1] = item
     38
     39    local item = {
     40            ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
     41            ["function"]  = P.SingleplayerBackButton_clicked
     42    }
     43    P.buttonList[2] = item
     44
     45end
     46
     47function P.onShow()
     48    --indices to iterate through buttonlist
     49    P.oldindex = -2
     50    P.index = -1
    3051end
    3152
     
    4364end
    4465
     66function P.onKeyPressed()
     67    buttonIteratorHelper(P.buttonList, code, P, 1, 2)
     68end
     69
    4570return P
    4671
Note: See TracChangeset for help on using the changeset viewer.