Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 12:47:57 AM (13 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/ControlsMenu.lua

    r7689 r7922  
    22
    33local P = createMenuSheet("ControlsMenu")
    4 P.buttonList = {}
    54P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
    65
    76function P.onLoad()
    8     P.multiplayerMode = "startClient" 
     7    P.multiplayerMode = "startClient"
    98
    109    --buttons are arranged in a 3x1 matrix:
    11     local item = {
     10    P:initButtons(3, 1)
     11
     12    P:setButton(1, 1, {
    1213            ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
    13             ["function"]  = P.ControlsMouseControlsButton_clicked
    14     }
    15     P.buttonList[1] = item
     14            ["callback"]  = P.ControlsMouseControlsButton_clicked
     15    })
    1616
    17     local item = {
     17    P:setButton(2, 1, {
    1818            ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
    19             ["function"]  = P.ControlsKeyboardControlsButton_clicked
    20     }
    21     P.buttonList[2] = item
     19            ["callback"]  = P.ControlsKeyboardControlsButton_clicked
     20    })
    2221
    23     local item = {
     22    P:setButton(3, 1, {
    2423            ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
    25             ["function"]  = P.ControlsBackButton_clicked
    26     }
    27     P.buttonList[3] = item
    28 
    29 end
    30 
    31 function P.onShow()
    32     --indices to iterate through buttonlist
    33     P.oldindex = -2
    34     P.index = -1
     24            ["callback"]  = P.ControlsBackButton_clicked
     25    })
    3526end
    3627
     
    4738end
    4839
    49 function P.onKeyPressed()
    50     buttonIteratorHelper(P.buttonList, code, P, 3, 1)
    51 end
    52 
    5340return P
    5441
Note: See TracChangeset for help on using the changeset viewer.