Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7922 was 7922, checked in by landauf, 14 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.7 KB
Line 
1-- MainMenu.lua
2
3local P = createMenuSheet("MainMenu")
4P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
5
6function P.onLoad()
7    --buttons are arranged in a 6x1 Matrix (list)
8    P:initButtons(6, 1)
9
10    P:setButton(1, 1, {
11            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
12            ["callback"]  = P.QuickGameTestButton_clicked
13    })
14
15    P:setButton(2, 1, {
16            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
17            ["callback"]  = P.SingleplayerButton_clicked
18    })
19
20    P:setButton(3, 1, {
21            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
22            ["callback"]  = P.MultiplayerButton_clicked
23    })
24
25    P:setButton(4, 1, {
26            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
27            ["callback"]  = P.SettingsButton_clicked
28    })
29
30    P:setButton(5, 1, {
31            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
32            ["callback"]  = P.CreditsButton_clicked
33    })
34
35    P:setButton(6, 1, {
36            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
37            ["callback"]  = P.ExitButton_clicked
38    })
39end
40
41-- events for MainMenu
42function P.QuickGameTestButton_clicked(e)
43    hideAllMenuSheets()
44    orxonox.execute("startGame")
45end
46
47function P.SingleplayerButton_clicked(e)
48    showMenuSheet("SingleplayerMenu", true)
49end
50
51function P.MultiplayerButton_clicked(e)
52    showMenuSheet("MultiplayerMenu", true)
53end
54
55function P.SettingsButton_clicked(e)
56    showMenuSheet("SettingsMenu", true)
57end
58
59function P.CreditsButton_clicked(e)
60    showMenuSheet("CreditsMenu", true)
61end
62
63function P.ExitButton_clicked(e)
64    orxonox.execute("exit")
65end
66
67return P
68
Note: See TracBrowser for help on using the repository browser.