[5661] | 1 | -- MainMenu.lua |
---|
[5491] | 2 | |
---|
[6746] | 3 | local P = createMenuSheet("MainMenu") |
---|
[6748] | 4 | P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } |
---|
[5491] | 5 | |
---|
[7588] | 6 | P.index = 0 |
---|
| 7 | |
---|
[6417] | 8 | -- events for MainMenu |
---|
| 9 | function P.QuickGameTestButton_clicked(e) |
---|
[7163] | 10 | hideAllMenuSheets() |
---|
[6417] | 11 | orxonox.execute("startGame") |
---|
[5491] | 12 | end |
---|
| 13 | |
---|
[7607] | 14 | function P.onShow() |
---|
| 15 | |
---|
| 16 | end |
---|
| 17 | |
---|
[6417] | 18 | function P.SingleplayerButton_clicked(e) |
---|
[6746] | 19 | showMenuSheet("SingleplayerMenu", true) |
---|
[5491] | 20 | end |
---|
| 21 | |
---|
[6417] | 22 | function P.MultiplayerButton_clicked(e) |
---|
[6746] | 23 | showMenuSheet("MultiplayerMenu", true) |
---|
[5491] | 24 | end |
---|
| 25 | |
---|
[6417] | 26 | function P.SettingsButton_clicked(e) |
---|
[6746] | 27 | showMenuSheet("SettingsMenu", true) |
---|
[5491] | 28 | end |
---|
| 29 | |
---|
[6417] | 30 | function P.CreditsButton_clicked(e) |
---|
[6746] | 31 | showMenuSheet("CreditsMenu", true) |
---|
[5491] | 32 | end |
---|
| 33 | |
---|
[6417] | 34 | function P.ExitButton_clicked(e) |
---|
| 35 | orxonox.execute("exit") |
---|
[5491] | 36 | end |
---|
| 37 | |
---|
[7607] | 38 | function P.onKeyPressed() |
---|
| 39 | --local we = tolua.cast(e, "CEGUI::KeyEventArgs") |
---|
| 40 | cout(0, code) |
---|
| 41 | if code == "15" then |
---|
| 42 | P.index = P.index + 1 |
---|
| 43 | local window = winMgr:getWindow("orxonox/MainMenuBackground") |
---|
| 44 | if P.index == window:getChildCount() then |
---|
| 45 | P.index = 1 |
---|
| 46 | end |
---|
| 47 | local child = window:getChildAtIdx(P.index-1) |
---|
| 48 | child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight") |
---|
| 49 | child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight") |
---|
| 50 | child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight") |
---|
| 51 | elseif code == "28" and P.index ~= 0 then |
---|
| 52 | if P.index == 1 then |
---|
| 53 | P.QuickGameTestButton_clicked() |
---|
| 54 | elseif P.index == 2 then |
---|
| 55 | P.SingleplayerButton_clicked() |
---|
| 56 | elseif P.index == 3 then |
---|
| 57 | P.MultiplayerButton_clicked() |
---|
| 58 | elseif P.index == 4 then |
---|
| 59 | P.SettingsButton_clicked() |
---|
| 60 | elseif P.index == 5 then |
---|
| 61 | P.CreditsButton_clicked() |
---|
| 62 | elseif P.index == 6 then |
---|
| 63 | P.ExitButton_clicked() |
---|
| 64 | end |
---|
| 65 | end |
---|
| 66 | end |
---|
| 67 | |
---|
| 68 | --[[function P.Key_clicked(e) |
---|
[7588] | 69 | local we = tolua.cast(e, "CEGUI::KeyEventArgs") |
---|
| 70 | cout(0, tostring(we.scancode)) |
---|
| 71 | if tostring(we.scancode) == "15" then |
---|
| 72 | P.index = P.index + 1 |
---|
| 73 | local window = winMgr:getWindow("orxonox/MainMenuBackground") |
---|
| 74 | if P.index == window:getChildCount() then |
---|
| 75 | P.index = 1 |
---|
| 76 | end |
---|
| 77 | local child = window:getChildAtIdx(P.index-1) |
---|
[7594] | 78 | child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight") |
---|
| 79 | child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight") |
---|
| 80 | child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight") |
---|
[7588] | 81 | elseif tostring(we.scancode) == "28" and P.index ~= 0 then |
---|
| 82 | if P.index == 1 then |
---|
| 83 | P.QuickGameTestButton_clicked() |
---|
| 84 | elseif P.index == 2 then |
---|
| 85 | P.SingleplayerButton_clicked() |
---|
| 86 | elseif P.index == 3 then |
---|
| 87 | P.MultiplayerButton_clicked() |
---|
| 88 | elseif P.index == 4 then |
---|
| 89 | P.SettingsButton_clicked() |
---|
| 90 | elseif P.index == 5 then |
---|
| 91 | P.CreditsButton_clicked() |
---|
| 92 | elseif P.index == 6 then |
---|
| 93 | P.ExitButton_clicked() |
---|
| 94 | end |
---|
| 95 | end |
---|
[7607] | 96 | end]]-- |
---|
[7588] | 97 | |
---|
[5661] | 98 | return P |
---|