[6018] | 1 | -- InGameMenu.lua |
---|
| 2 | |
---|
[6746] | 3 | local P = createMenuSheet("InGameMenu") |
---|
[6748] | 4 | P.loadAlong = { "DecisionPopup" } |
---|
[6018] | 5 | |
---|
[7726] | 6 | function P.onLoad() |
---|
[8079] | 7 | P.multiplayerMode = "startClient" |
---|
[7726] | 8 | |
---|
[11052] | 9 | --button are arranged in a 5x1 matrix, the left lower item is nil |
---|
[8079] | 10 | P:setButton(1, 1, { |
---|
[7726] | 11 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"), |
---|
[8079] | 12 | ["callback"] = P.button_return_clicked |
---|
| 13 | }) |
---|
[7726] | 14 | |
---|
[8079] | 15 | P:setButton(2, 1, { |
---|
[11052] | 16 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReloadLevelButton"), |
---|
| 17 | ["callback"] = P.button_reloadLevel_clicked |
---|
| 18 | }) |
---|
| 19 | |
---|
| 20 | P:setButton(3, 1, { |
---|
[7726] | 21 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"), |
---|
[8079] | 22 | ["callback"] = P.button_mainmenu_clicked |
---|
| 23 | }) |
---|
[7726] | 24 | |
---|
[11052] | 25 | P:setButton(4, 1, { |
---|
[7726] | 26 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"), |
---|
[8079] | 27 | ["callback"] = P.button_settings_clicked |
---|
| 28 | }) |
---|
[7726] | 29 | |
---|
[11052] | 30 | P:setButton(5, 1, { |
---|
[7726] | 31 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"), |
---|
[8079] | 32 | ["callback"] = P.button_quit_clicked |
---|
| 33 | }) |
---|
[7726] | 34 | end |
---|
| 35 | |
---|
| 36 | function P.onShow() |
---|
[8079] | 37 | if P:hasSelection() == false then |
---|
| 38 | P:setSelection(1, 1) |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | orxonox.execute("setPause 1") |
---|
[7726] | 42 | end |
---|
| 43 | |
---|
[8079] | 44 | function P.onQuit() |
---|
| 45 | orxonox.execute("setPause 0") |
---|
| 46 | end |
---|
| 47 | |
---|
[6018] | 48 | -- events for ingamemenu |
---|
| 49 | function P.button_quit_clicked(e) |
---|
[9016] | 50 | openDecisionPopup( "Do you really want to quit the game?", InGameMenu.exitCallback ) |
---|
[6018] | 51 | end |
---|
| 52 | |
---|
| 53 | function P.button_mainmenu_clicked(e) |
---|
[9016] | 54 | openDecisionPopup( "Do you really want to return to the main menu?", InGameMenu.mainMenuCallback ) |
---|
[6018] | 55 | end |
---|
| 56 | |
---|
[6217] | 57 | function P.button_settings_clicked(e) |
---|
[6746] | 58 | showMenuSheet("SettingsMenu", true) |
---|
[6217] | 59 | end |
---|
| 60 | |
---|
[11052] | 61 | function P.button_reloadLevel_clicked(e) |
---|
| 62 | hideMenuSheet("InGameMenu") |
---|
| 63 | orxonox.execute("reloadLevel") |
---|
| 64 | end |
---|
| 65 | |
---|
[6019] | 66 | function P.button_return_clicked(e) |
---|
[6746] | 67 | hideMenuSheet("InGameMenu") |
---|
[6019] | 68 | end |
---|
| 69 | |
---|
[9016] | 70 | function P.mainMenuCallback(doExit) |
---|
[6048] | 71 | if doExit then |
---|
[9016] | 72 | orxonox.execute("startMainMenu") |
---|
[6746] | 73 | hideMenuSheet("InGameMenu") |
---|
[9016] | 74 | else |
---|
| 75 | P.onShow() |
---|
| 76 | end |
---|
| 77 | end |
---|
| 78 | |
---|
| 79 | function P.exitCallback(doExit) |
---|
| 80 | if doExit then |
---|
| 81 | hideMenuSheet("InGameMenu") |
---|
[6403] | 82 | orxonox.execute("exit") |
---|
[8079] | 83 | else |
---|
[7726] | 84 | P.onShow() |
---|
[6048] | 85 | end |
---|
| 86 | end |
---|
| 87 | |
---|
[6018] | 88 | return P |
---|
| 89 | |
---|