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