| 1 | -- MainMenu.lua | 
|---|
| 2 |  | 
|---|
| 3 | local P = createMenuSheet("MainMenu") | 
|---|
| 4 | P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } | 
|---|
| 5 |  | 
|---|
| 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 |  | 
|---|
| 53 | -- events for MainMenu | 
|---|
| 54 | function P.QuickGameTestButton_clicked(e) | 
|---|
| 55 |     hideAllMenuSheets() | 
|---|
| 56 |     orxonox.execute("startGame") | 
|---|
| 57 | end | 
|---|
| 58 |  | 
|---|
| 59 | function P.SingleplayerButton_clicked(e) | 
|---|
| 60 |     showMenuSheet("SingleplayerMenu", true) | 
|---|
| 61 | end | 
|---|
| 62 |  | 
|---|
| 63 | function P.MultiplayerButton_clicked(e) | 
|---|
| 64 |     showMenuSheet("MultiplayerMenu", true) | 
|---|
| 65 | end | 
|---|
| 66 |  | 
|---|
| 67 | function P.SettingsButton_clicked(e) | 
|---|
| 68 |     showMenuSheet("SettingsMenu", true) | 
|---|
| 69 | end | 
|---|
| 70 |  | 
|---|
| 71 | function P.CreditsButton_clicked(e) | 
|---|
| 72 |     showMenuSheet("CreditsMenu", true) | 
|---|
| 73 | end | 
|---|
| 74 |  | 
|---|
| 75 | function P.ExitButton_clicked(e) | 
|---|
| 76 |     orxonox.execute("exit") | 
|---|
| 77 | end | 
|---|
| 78 |  | 
|---|
| 79 | function P.onKeyPressed()  | 
|---|
| 80 |     buttonIteratorHelper(P.buttonList, code, P, 6, 1) | 
|---|
| 81 | end | 
|---|
| 82 |  | 
|---|
| 83 | return P | 
|---|
| 84 |  | 
|---|