[5491] | 1 | -- mainmenu_2.lua |
---|
| 2 | gui = require("gui") |
---|
| 3 | local P = gui:new() --inherit everything from the gui package |
---|
| 4 | |
---|
| 5 | mainmenu_2 = P |
---|
| 6 | |
---|
| 7 | P.filename = "mainmenu_2" |
---|
| 8 | P.layoutString = "MainMenu_2.layout" |
---|
| 9 | |
---|
[5523] | 10 | function P:init() |
---|
[5527] | 11 | listbox = winMgr:getWindow("orxonox/LevelListbox") |
---|
[5532] | 12 | preselect = orxonox.Game:getInstance():getLevel() |
---|
| 13 | orxonox.GUIManager:getInstance():getLevelList() --levellist variable ist set now |
---|
[5527] | 14 | for k,v in pairs(levellist) do |
---|
[5532] | 15 | item = CEGUI.createListboxTextItem(v) |
---|
[5527] | 16 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
| 17 | CEGUI.toListbox(listbox):addItem(item) |
---|
[5532] | 18 | if v .. ".oxw" == preselect then |
---|
| 19 | listbox:setItemSelectState(item, true) |
---|
| 20 | end |
---|
[5527] | 21 | end |
---|
[5491] | 22 | end |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | -- events for mainmenu |
---|
| 26 | function P.button_quit_clicked(e) |
---|
[5527] | 27 | hideGUI() |
---|
| 28 | orxonox.CommandExecutor:execute("exit") |
---|
[5491] | 29 | end |
---|
| 30 | |
---|
| 31 | function P.button_standalone_clicked(e) |
---|
[5527] | 32 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
| 33 | if choice then |
---|
[5532] | 34 | orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw") |
---|
[5527] | 35 | orxonox.CommandExecutor:execute("startGame") |
---|
| 36 | toggleGUI() |
---|
| 37 | end |
---|
[5491] | 38 | end |
---|
| 39 | |
---|
| 40 | function P.button_server_clicked(e) |
---|
| 41 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
| 42 | hideGUI() |
---|
| 43 | end |
---|
| 44 | |
---|
| 45 | function P.button_dedicated_clicked(e) |
---|
| 46 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
| 47 | hideGUI() |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | function P.button_client_clicked(e) |
---|
| 51 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
| 52 | hideGUI() |
---|
| 53 | end |
---|
| 54 | |
---|
[5527] | 55 | function P.listbox_level_selectionchanged(e) |
---|
| 56 | if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then |
---|
| 57 | winMgr:getWindow("orxonox/StandaloneButton"):enable() |
---|
| 58 | else |
---|
| 59 | winMgr:getWindow("orxonox/StandaloneButton"):disable() |
---|
| 60 | end |
---|
| 61 | end |
---|
| 62 | |
---|
[5491] | 63 | return mainmenu_2 |
---|
| 64 | |
---|