Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 12:47:57 AM (14 years ago)
Author:
landauf
Message:

implemented new keyboard control of menu buttons with these new features:

  • more intuitive placement of buttons in table (row/column format instead of linear index)
  • no need to overwrite onShow() and onKeyPressed() functions, no need for P.buttonList
  • highlights the selected button in a different layout than mouse hovering
  • remembers the selection while moving through the menu hierarchy, but resets it if the menu is closed
  • allows preselected button (for example "Yes" in decision popup)
  • when opening a menu, the first selected button is not always the upper left, but instead depends on the pressed key (e.g. the 'up' key selects the button at the bottom, while the 'down' key selects the button at the top. once a button is selected, the keys behave as usual)

+ fixed wrong callback function in ingame menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/data/gui/scripts/MultiplayerMenu.lua

    r7916 r7922  
    22
    33local P = createMenuSheet("MultiplayerMenu")
    4 
    5 P.buttonList = {}
    64
    75--joinMode is 1 for choice "LAN" and 2 for "Internet"
     
    1311
    1412    --button are arranged in a 2x2 matrix, the left lower item is nil
    15     local item = {
     13    P:initButtons(2, 2)
     14
     15    P:setButton(1, 1, {
    1616            ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton"),
    17             ["function"]  = P.MultiplayerJoinButton_clicked
    18     }
    19     P.buttonList[1] = item
     17            ["callback"]  = P.MultiplayerJoinButton_clicked
     18    })
    2019
    21     local item = {
     20    P:setButton(1, 2, {
    2221            ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton"),
    23             ["function"]  = P.MultiplayerHostButton_clicked
    24     }
    25     P.buttonList[2] = item
     22            ["callback"]  = P.MultiplayerHostButton_clicked
     23    })
    2624
    27     local item = {
     25    P:setButton(2, 2, {
    2826            ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"),
    29             ["function"]  = P.MultiplayerBackButton_clicked
    30     }
    31     P.buttonList[4] = item
     27            ["callback"]  = P.MultiplayerBackButton_clicked
     28    })
    3229end
    3330
    3431function P.onShow()
    3532    --P.showServerList()
    36 
    37     --indices to iterate through buttonlist
    38     P.oldindex = -2
    39     P.index = -1
    4033
    4134    if P.joinMode == 1 then
     
    158151end
    159152
    160 function P.onKeyPressed()
    161     buttonIteratorHelper(P.buttonList, code, P, 2, 2)
    162 end
    163 
    164153return P
    165154
Note: See TracChangeset for help on using the changeset viewer.