Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/data/gui/scripts/SettingsMenu.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.8 KB
Line 
1-- SettingsMenu.lua
2
3local P = createMenuSheet("SettingsMenu")
4P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" }
5
6function P.onLoad()
7    --"Gameplay" and "Multiplayer Options" are not integrated in the list
8    --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
9    P:initButtons(4, 2)
10
11    P:setButton(1, 2, {
12            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
13            ["callback"]  = P.SettingsGraphicsButton_clicked
14    })
15
16    P:setButton(2, 2, {
17            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"),
18            ["callback"]  = P.SettingsAudioButton_clicked
19    })
20
21    P:setButton(3, 1, {
22            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
23            ["callback"]  = P.SettingsControlsButton_clicked
24    })
25
26    P:setButton(3, 2, {
27            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
28            ["callback"]  = P.SettingsMiscellaneousButton_clicked
29    })
30
31    P:setButton(4, 1, {
32            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
33            ["callback"]  = P.SettingsBackButton_clicked
34    })
35end
36
37function P.SettingsGameplayButton_clicked(e)
38    showMenuSheet("GameplayMenu", true)
39end
40
41function P.SettingsMultiplayerOptionsButton_clicked(e)
42    showMenuSheet("MultiplayerOptionsMenu", true)
43end
44
45function P.SettingsControlsButton_clicked(e)
46    showMenuSheet("ControlsMenu", true)
47end
48
49function P.SettingsGraphicsButton_clicked(e)
50    showMenuSheet("GraphicsMenu", true)
51end
52
53function P.SettingsAudioButton_clicked(e)
54    showMenuSheet("AudioMenu", true)
55end
56
57function P.SettingsMiscellaneousButton_clicked(e)
58    showMenuSheet("MiscConfigMenu", true)
59end
60
61function P.SettingsBackButton_clicked(e)
62    hideMenuSheet(P.name)
63end
64
65return P
66
Note: See TracBrowser for help on using the repository browser.