[5661] | 1 | -- MainMenu.lua |
---|
[5491] | 2 | |
---|
[6746] | 3 | local P = createMenuSheet("MainMenu") |
---|
[6748] | 4 | P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } |
---|
[5491] | 5 | |
---|
[7663] | 6 | P.buttonList = {} |
---|
[7588] | 7 | |
---|
[7663] | 8 | P.testArray = {} |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | function P.onLoad() |
---|
| 12 | local item = { |
---|
| 13 | ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"), |
---|
| 14 | ["function"] = P.QuickGameTestButton_clicked |
---|
| 15 | } |
---|
| 16 | table.insert(P.buttonList,item) |
---|
| 17 | |
---|
| 18 | item = { |
---|
| 19 | ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"), |
---|
| 20 | ["function"] = P.SingleplayerButton_clicked |
---|
| 21 | } |
---|
| 22 | table.insert(P.buttonList,item) |
---|
| 23 | |
---|
| 24 | item = { |
---|
| 25 | ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"), |
---|
| 26 | ["function"] = P.MultiplayerButton_clicked |
---|
| 27 | } |
---|
| 28 | table.insert(P.buttonList,item) |
---|
| 29 | |
---|
| 30 | item = { |
---|
| 31 | ["button"] = winMgr:getWindow("orxonox/SettingsButton"), |
---|
| 32 | ["function"] = P.SettingsButton_clicked |
---|
| 33 | } |
---|
| 34 | table.insert(P.buttonList,item) |
---|
| 35 | |
---|
| 36 | item = { |
---|
| 37 | ["button"] = winMgr:getWindow("orxonox/CreditsButton"), |
---|
| 38 | ["function"] = P.CreditsButton_clicked |
---|
| 39 | } |
---|
| 40 | table.insert(P.buttonList,item) |
---|
| 41 | |
---|
| 42 | item = { |
---|
| 43 | ["button"] = winMgr:getWindow("orxonox/ExitButton"), |
---|
| 44 | ["function"] = P.ExitButton_clicked |
---|
| 45 | } |
---|
| 46 | table.insert(P.buttonList,item) |
---|
| 47 | end |
---|
| 48 | |
---|
| 49 | function P.onShow() |
---|
| 50 | P.oldindex = -2 |
---|
| 51 | P.index = -1 |
---|
| 52 | end |
---|
| 53 | |
---|
[6417] | 54 | -- events for MainMenu |
---|
| 55 | function P.QuickGameTestButton_clicked(e) |
---|
[7163] | 56 | hideAllMenuSheets() |
---|
[6417] | 57 | orxonox.execute("startGame") |
---|
[5491] | 58 | end |
---|
| 59 | |
---|
[6417] | 60 | function P.SingleplayerButton_clicked(e) |
---|
[6746] | 61 | showMenuSheet("SingleplayerMenu", true) |
---|
[5491] | 62 | end |
---|
| 63 | |
---|
[6417] | 64 | function P.MultiplayerButton_clicked(e) |
---|
[6746] | 65 | showMenuSheet("MultiplayerMenu", true) |
---|
[5491] | 66 | end |
---|
| 67 | |
---|
[6417] | 68 | function P.SettingsButton_clicked(e) |
---|
[6746] | 69 | showMenuSheet("SettingsMenu", true) |
---|
[5491] | 70 | end |
---|
| 71 | |
---|
[6417] | 72 | function P.CreditsButton_clicked(e) |
---|
[6746] | 73 | showMenuSheet("CreditsMenu", true) |
---|
[5491] | 74 | end |
---|
| 75 | |
---|
[6417] | 76 | function P.ExitButton_clicked(e) |
---|
| 77 | orxonox.execute("exit") |
---|
[5491] | 78 | end |
---|
| 79 | |
---|
[7663] | 80 | |
---|
| 81 | --[[ |
---|
| 82 | list = {} |
---|
| 83 | local item = |
---|
| 84 | { |
---|
| 85 | ["button"] = buttonWindow, |
---|
| 86 | ["function"] = buttonFunction, |
---|
| 87 | } |
---|
| 88 | table.insert(list, item) |
---|
| 89 | item = list[i] |
---|
| 90 | |
---|
| 91 | for i,item in pairs(list) do |
---|
| 92 | button = item["button"] |
---|
| 93 | end |
---|
| 94 | |
---|
| 95 | --]] |
---|
| 96 | --[[ |
---|
| 97 | function createList() |
---|
| 98 | list = {} |
---|
| 99 | |
---|
| 100 | local j |
---|
| 101 | while j < P.loadAlong |
---|
| 102 | local item = |
---|
| 103 | { |
---|
| 104 | ["button"] = buttonWindow, |
---|
| 105 | ["function"] = buttonFunction, |
---|
| 106 | } |
---|
| 107 | table.insert(list, item) |
---|
[7607] | 108 | end |
---|
[7663] | 109 | |
---|
| 110 | --]] |
---|
| 111 | |
---|
| 112 | function P.onKeyPressed() |
---|
| 113 | cout(0,code) |
---|
| 114 | buttonIteratorHelper(P.buttonList, code, P, 6, 1) |
---|
| 115 | --indexTester(P.buttonList,code,P,6,1) |
---|
[7607] | 116 | end |
---|
| 117 | |
---|
[5661] | 118 | return P |
---|
[7663] | 119 | |
---|