Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/data/gui/scripts/InGameMenu.lua @ 7928

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

more improvements for keyboard control of menus:

  • added setSelectionNear(r, c) function which tries to select the button closest to the given row/column
  • no initialization required anymore, the button-table grows dynamically if new buttons are inserted
  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1-- InGameMenu.lua
2
3local P = createMenuSheet("InGameMenu")
4P.loadAlong = { "DecisionPopup" }
5
6function P.onLoad()
7    P.multiplayerMode = "startClient"
8
9    --button are arranged in a 4x1 matrix, the left lower item is nil
10    P:setButton(1, 1, {
11            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"),
12            ["callback"]  = P.button_return_clicked
13    })
14
15    P:setButton(2, 1, {
16            ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"),
17            ["callback"]  = P.button_mainmenu_clicked
18    })
19
20    P:setButton(3, 1, {
21            ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"),
22            ["callback"]  = P.button_settings_clicked
23    })
24
25    P:setButton(4, 1, {
26            ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"),
27            ["callback"]  = P.button_quit_clicked
28    })
29end
30
31function P.onShow()
32    if P:hasSelection() == false then
33        P:setSelection(1, 1)
34    end
35end
36
37-- events for ingamemenu
38function P.button_quit_clicked(e)
39    openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback )
40end
41
42function P.button_mainmenu_clicked(e)
43    orxonox.execute("startMainMenu")
44    hideMenuSheet("InGameMenu")
45end
46
47function P.button_settings_clicked(e)
48    showMenuSheet("SettingsMenu", true)
49end
50
51function P.button_return_clicked(e)
52    hideMenuSheet("InGameMenu")
53end
54
55function P.callback(doExit)
56    if doExit then
57        hideMenuSheet("InGameMenu")
58        orxonox.execute("exit")
59    else
60        P.onShow()
61    end
62end
63
64return P
65
Note: See TracBrowser for help on using the repository browser.