| [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 | |
|---|
| 9 | --button are arranged in a 4x1 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, { |
|---|
| [7726] | 16 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"), |
|---|
| [8079] | 17 | ["callback"] = P.button_mainmenu_clicked |
|---|
| 18 | }) |
|---|
| [7726] | 19 | |
|---|
| [8079] | 20 | P:setButton(3, 1, { |
|---|
| [7726] | 21 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"), |
|---|
| [8079] | 22 | ["callback"] = P.button_settings_clicked |
|---|
| 23 | }) |
|---|
| [7726] | 24 | |
|---|
| [8079] | 25 | P:setButton(4, 1, { |
|---|
| [7726] | 26 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"), |
|---|
| [8079] | 27 | ["callback"] = P.button_quit_clicked |
|---|
| 28 | }) |
|---|
| [7726] | 29 | end |
|---|
| 30 | |
|---|
| 31 | function P.onShow() |
|---|
| [8079] | 32 | if P:hasSelection() == false then |
|---|
| 33 | P:setSelection(1, 1) |
|---|
| 34 | end |
|---|
| 35 | |
|---|
| 36 | orxonox.execute("setPause 1") |
|---|
| [7726] | 37 | end |
|---|
| 38 | |
|---|
| [8079] | 39 | function P.onQuit() |
|---|
| 40 | orxonox.execute("setPause 0") |
|---|
| 41 | end |
|---|
| 42 | |
|---|
| [6018] | 43 | -- events for ingamemenu |
|---|
| 44 | function P.button_quit_clicked(e) |
|---|
| [9016] | 45 | openDecisionPopup( "Do you really want to quit the game?", InGameMenu.exitCallback ) |
|---|
| [6018] | 46 | end |
|---|
| 47 | |
|---|
| 48 | function P.button_mainmenu_clicked(e) |
|---|
| [9016] | 49 | openDecisionPopup( "Do you really want to return to the main menu?", InGameMenu.mainMenuCallback ) |
|---|
| [6018] | 50 | end |
|---|
| 51 | |
|---|
| [6217] | 52 | function P.button_settings_clicked(e) |
|---|
| [6746] | 53 | showMenuSheet("SettingsMenu", true) |
|---|
| [6217] | 54 | end |
|---|
| 55 | |
|---|
| [6019] | 56 | function P.button_return_clicked(e) |
|---|
| [6746] | 57 | hideMenuSheet("InGameMenu") |
|---|
| [6019] | 58 | end |
|---|
| 59 | |
|---|
| [9016] | 60 | function P.mainMenuCallback(doExit) |
|---|
| [6048] | 61 | if doExit then |
|---|
| [9016] | 62 | orxonox.execute("startMainMenu") |
|---|
| [6746] | 63 | hideMenuSheet("InGameMenu") |
|---|
| [9016] | 64 | else |
|---|
| 65 | P.onShow() |
|---|
| 66 | end |
|---|
| 67 | end |
|---|
| 68 | |
|---|
| 69 | function P.exitCallback(doExit) |
|---|
| 70 | if doExit then |
|---|
| 71 | hideMenuSheet("InGameMenu") |
|---|
| [6403] | 72 | orxonox.execute("exit") |
|---|
| [8079] | 73 | else |
|---|
| [7726] | 74 | P.onShow() |
|---|
| [6048] | 75 | end |
|---|
| 76 | end |
|---|
| 77 | |
|---|
| [6018] | 78 | return P |
|---|
| 79 | |
|---|