[6018] | 1 | -- InGameMenu.lua |
---|
| 2 | |
---|
[6746] | 3 | local P = createMenuSheet("InGameMenu") |
---|
[6748] | 4 | P.loadAlong = { "DecisionPopup" } |
---|
[6018] | 5 | |
---|
[7726] | 6 | P.buttonList = {} |
---|
| 7 | |
---|
| 8 | function P.onLoad() |
---|
| 9 | P.multiplayerMode = "startClient" |
---|
| 10 | |
---|
| 11 | --button are arranged in a 4x1 matrix, the left lower item is nil |
---|
| 12 | local item = { |
---|
| 13 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"), |
---|
| 14 | ["function"] = P.button_settings_clicked |
---|
| 15 | } |
---|
| 16 | P.buttonList[1] = item |
---|
| 17 | |
---|
| 18 | local item = { |
---|
| 19 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"), |
---|
| 20 | ["function"] = P.button_mainmenu_clicked |
---|
| 21 | } |
---|
| 22 | P.buttonList[2] = item |
---|
| 23 | |
---|
| 24 | local item = { |
---|
| 25 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"), |
---|
| 26 | ["function"] = P.button_settings_clicked |
---|
| 27 | } |
---|
| 28 | P.buttonList[3] = item |
---|
| 29 | |
---|
| 30 | local item = { |
---|
| 31 | ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"), |
---|
| 32 | ["function"] = P.button_quit_clicked |
---|
| 33 | } |
---|
| 34 | P.buttonList[4] = item |
---|
| 35 | |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | function P.onShow() |
---|
| 39 | --indices to iterate through buttonlist |
---|
| 40 | P.oldindex = -2 |
---|
| 41 | P.index = -1 |
---|
| 42 | end |
---|
| 43 | |
---|
[6018] | 44 | -- events for ingamemenu |
---|
| 45 | function P.button_quit_clicked(e) |
---|
[6048] | 46 | openDecisionPopup( "Do you really want to quit the game?", InGameMenu.callback ) |
---|
[6018] | 47 | end |
---|
| 48 | |
---|
| 49 | function P.button_mainmenu_clicked(e) |
---|
[6019] | 50 | orxonox.Game:getInstance():popState() |
---|
| 51 | orxonox.Game:getInstance():popState() |
---|
[6746] | 52 | hideMenuSheet("InGameMenu") |
---|
[6018] | 53 | end |
---|
| 54 | |
---|
[6217] | 55 | function P.button_settings_clicked(e) |
---|
[6746] | 56 | showMenuSheet("SettingsMenu", true) |
---|
[6217] | 57 | end |
---|
| 58 | |
---|
[6019] | 59 | function P.button_return_clicked(e) |
---|
[6746] | 60 | hideMenuSheet("InGameMenu") |
---|
[6019] | 61 | end |
---|
| 62 | |
---|
[6048] | 63 | function P.callback(doExit) |
---|
| 64 | if doExit then |
---|
[6746] | 65 | hideMenuSheet("InGameMenu") |
---|
[6403] | 66 | orxonox.execute("exit") |
---|
[7726] | 67 | else |
---|
| 68 | P.onShow() |
---|
[6048] | 69 | end |
---|
| 70 | end |
---|
| 71 | |
---|
[7726] | 72 | function P.onKeyPressed() |
---|
| 73 | buttonIteratorHelper(P.buttonList, code, P, 4, 1) |
---|
| 74 | end |
---|
| 75 | |
---|
[6018] | 76 | return P |
---|
| 77 | |
---|