[5661] | 1 | -- MainMenu.lua |
---|
[5491] | 2 | |
---|
[6746] | 3 | local P = createMenuSheet("MainMenu") |
---|
[6748] | 4 | P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } |
---|
[5491] | 5 | |
---|
[7689] | 6 | P.buttonList = {} |
---|
| 7 | |
---|
| 8 | function P.onLoad() |
---|
| 9 | --buttons are arranged in a 6x1 Matrix (list) |
---|
| 10 | local item = { |
---|
| 11 | ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"), |
---|
| 12 | ["function"] = P.QuickGameTestButton_clicked |
---|
| 13 | } |
---|
| 14 | table.insert(P.buttonList,item) |
---|
| 15 | |
---|
| 16 | item = { |
---|
| 17 | ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"), |
---|
| 18 | ["function"] = P.SingleplayerButton_clicked |
---|
| 19 | } |
---|
| 20 | table.insert(P.buttonList,item) |
---|
| 21 | |
---|
| 22 | item = { |
---|
| 23 | ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"), |
---|
| 24 | ["function"] = P.MultiplayerButton_clicked |
---|
| 25 | } |
---|
| 26 | table.insert(P.buttonList,item) |
---|
| 27 | |
---|
| 28 | item = { |
---|
| 29 | ["button"] = winMgr:getWindow("orxonox/SettingsButton"), |
---|
| 30 | ["function"] = P.SettingsButton_clicked |
---|
| 31 | } |
---|
| 32 | table.insert(P.buttonList,item) |
---|
| 33 | |
---|
| 34 | item = { |
---|
| 35 | ["button"] = winMgr:getWindow("orxonox/CreditsButton"), |
---|
| 36 | ["function"] = P.CreditsButton_clicked |
---|
| 37 | } |
---|
| 38 | table.insert(P.buttonList,item) |
---|
| 39 | |
---|
| 40 | item = { |
---|
| 41 | ["button"] = winMgr:getWindow("orxonox/ExitButton"), |
---|
| 42 | ["function"] = P.ExitButton_clicked |
---|
| 43 | } |
---|
| 44 | table.insert(P.buttonList,item) |
---|
| 45 | end |
---|
| 46 | |
---|
| 47 | function P.onShow() |
---|
| 48 | --indices to iterate through buttonlist |
---|
| 49 | P.oldindex = -2 |
---|
| 50 | P.index = -1 |
---|
| 51 | end |
---|
| 52 | |
---|
[6417] | 53 | -- events for MainMenu |
---|
| 54 | function P.QuickGameTestButton_clicked(e) |
---|
[7163] | 55 | hideAllMenuSheets() |
---|
[6417] | 56 | orxonox.execute("startGame") |
---|
[5491] | 57 | end |
---|
| 58 | |
---|
[6417] | 59 | function P.SingleplayerButton_clicked(e) |
---|
[6746] | 60 | showMenuSheet("SingleplayerMenu", true) |
---|
[5491] | 61 | end |
---|
| 62 | |
---|
[6417] | 63 | function P.MultiplayerButton_clicked(e) |
---|
[6746] | 64 | showMenuSheet("MultiplayerMenu", true) |
---|
[5491] | 65 | end |
---|
| 66 | |
---|
[6417] | 67 | function P.SettingsButton_clicked(e) |
---|
[6746] | 68 | showMenuSheet("SettingsMenu", true) |
---|
[5491] | 69 | end |
---|
| 70 | |
---|
[6417] | 71 | function P.CreditsButton_clicked(e) |
---|
[6746] | 72 | showMenuSheet("CreditsMenu", true) |
---|
[5491] | 73 | end |
---|
| 74 | |
---|
[6417] | 75 | function P.ExitButton_clicked(e) |
---|
| 76 | orxonox.execute("exit") |
---|
[5491] | 77 | end |
---|
| 78 | |
---|
[7689] | 79 | function P.onKeyPressed() |
---|
| 80 | buttonIteratorHelper(P.buttonList, code, P, 6, 1) |
---|
| 81 | end |
---|
| 82 | |
---|
[5661] | 83 | return P |
---|
[5491] | 84 | |
---|