1 | -- InGameMenu.lua |
---|
2 | |
---|
3 | local P = createMenuSheet("InGameMenu") |
---|
4 | P.loadAlong = { "DecisionPopup" } |
---|
5 | |
---|
6 | function P.onLoad() |
---|
7 | P.multiplayerMode = "startClient" |
---|
8 | |
---|
9 | --button are arranged in a 4x1 matrix, the left lower item is nil |
---|
10 | P:initButtons(4, 1) |
---|
11 | |
---|
12 | P:setButton(1, 1, { |
---|
13 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"), |
---|
14 | ["callback"] = P.button_return_clicked |
---|
15 | }) |
---|
16 | |
---|
17 | P:setButton(2, 1, { |
---|
18 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"), |
---|
19 | ["callback"] = P.button_mainmenu_clicked |
---|
20 | }) |
---|
21 | |
---|
22 | P:setButton(3, 1, { |
---|
23 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"), |
---|
24 | ["callback"] = P.button_settings_clicked |
---|
25 | }) |
---|
26 | |
---|
27 | P:setButton(4, 1, { |
---|
28 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"), |
---|
29 | ["callback"] = P.button_quit_clicked |
---|
30 | }) |
---|
31 | end |
---|
32 | |
---|
33 | function P.onShow() |
---|
34 | if P:hasSelection() == false then |
---|
35 | P:setSelection(1, 1) |
---|
36 | end |
---|
37 | end |
---|
38 | |
---|
39 | -- events for ingamemenu |
---|
40 | function P.button_quit_clicked(e) |
---|
41 | openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback ) |
---|
42 | end |
---|
43 | |
---|
44 | function P.button_mainmenu_clicked(e) |
---|
45 | orxonox.execute("startMainMenu") |
---|
46 | hideMenuSheet("InGameMenu") |
---|
47 | end |
---|
48 | |
---|
49 | function P.button_settings_clicked(e) |
---|
50 | showMenuSheet("SettingsMenu", true) |
---|
51 | end |
---|
52 | |
---|
53 | function P.button_return_clicked(e) |
---|
54 | hideMenuSheet("InGameMenu") |
---|
55 | end |
---|
56 | |
---|
57 | function P.callback(doExit) |
---|
58 | if doExit then |
---|
59 | hideMenuSheet("InGameMenu") |
---|
60 | orxonox.execute("exit") |
---|
61 | else |
---|
62 | P.onShow() |
---|
63 | end |
---|
64 | end |
---|
65 | |
---|
66 | return P |
---|
67 | |
---|