Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/data/gui/scripts/ControlsMenu.lua @ 7922

Last change on this file since 7922 was 7922, checked in by landauf, 13 years ago

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

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1-- ControlsMenu.lua
2
3local P = createMenuSheet("ControlsMenu")
4P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
5
6function P.onLoad()
7    P.multiplayerMode = "startClient"
8
9    --buttons are arranged in a 3x1 matrix:
10    P:initButtons(3, 1)
11
12    P:setButton(1, 1, {
13            ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
14            ["callback"]  = P.ControlsMouseControlsButton_clicked
15    })
16
17    P:setButton(2, 1, {
18            ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
19            ["callback"]  = P.ControlsKeyboardControlsButton_clicked
20    })
21
22    P:setButton(3, 1, {
23            ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
24            ["callback"]  = P.ControlsBackButton_clicked
25    })
26end
27
28function P.ControlsMouseControlsButton_clicked(e)
29    showMenuSheet("MouseControlsMenu", true)
30end
31
32function P.ControlsKeyboardControlsButton_clicked(e)
33    showMenuSheet("KeyBindMenu", true)
34end
35
36function P.ControlsBackButton_clicked(e)
37    hideMenuSheet(P.name)
38end
39
40return P
41
Note: See TracBrowser for help on using the repository browser.