[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") |
---|
[5578] | 12 | preselect = orxonox.LevelManager:getInstance():getDefaultLevel() |
---|
[5532] | 13 | orxonox.GUIManager:getInstance():getLevelList() --levellist variable ist set now |
---|
[5559] | 14 | table.sort(levellist) |
---|
[5527] | 15 | for k,v in pairs(levellist) do |
---|
[5532] | 16 | item = CEGUI.createListboxTextItem(v) |
---|
[5527] | 17 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
| 18 | CEGUI.toListbox(listbox):addItem(item) |
---|
[5532] | 19 | if v .. ".oxw" == preselect then |
---|
| 20 | listbox:setItemSelectState(item, true) |
---|
| 21 | end |
---|
[5527] | 22 | end |
---|
[5491] | 23 | end |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | -- events for mainmenu |
---|
| 27 | function P.button_quit_clicked(e) |
---|
[5527] | 28 | hideGUI() |
---|
| 29 | orxonox.CommandExecutor:execute("exit") |
---|
[5491] | 30 | end |
---|
| 31 | |
---|
| 32 | function P.button_standalone_clicked(e) |
---|
[5527] | 33 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
| 34 | if choice then |
---|
[5578] | 35 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
[5527] | 36 | orxonox.CommandExecutor:execute("startGame") |
---|
| 37 | toggleGUI() |
---|
| 38 | end |
---|
[5491] | 39 | end |
---|
| 40 | |
---|
| 41 | function P.button_server_clicked(e) |
---|
[5566] | 42 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
| 43 | if choice then |
---|
[5578] | 44 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
[5566] | 45 | orxonox.CommandExecutor:execute("startServer") |
---|
| 46 | toggleGUI() |
---|
| 47 | end |
---|
[5491] | 48 | end |
---|
| 49 | |
---|
| 50 | function P.button_dedicated_clicked(e) |
---|
[5566] | 51 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
| 52 | if choice then |
---|
[5578] | 53 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
[5566] | 54 | orxonox.CommandExecutor:execute("startDedicated") |
---|
| 55 | toggleGUI() |
---|
| 56 | end |
---|
[5491] | 57 | end |
---|
| 58 | |
---|
| 59 | function P.button_client_clicked(e) |
---|
[5566] | 60 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
| 61 | if choice then |
---|
[5578] | 62 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
[5566] | 63 | orxonox.CommandExecutor:execute("startClient") |
---|
| 64 | toggleGUI() |
---|
| 65 | end |
---|
[5491] | 66 | end |
---|
| 67 | |
---|
[5527] | 68 | function P.listbox_level_selectionchanged(e) |
---|
| 69 | if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then |
---|
| 70 | winMgr:getWindow("orxonox/StandaloneButton"):enable() |
---|
| 71 | else |
---|
| 72 | winMgr:getWindow("orxonox/StandaloneButton"):disable() |
---|
| 73 | end |
---|
| 74 | end |
---|
| 75 | |
---|
[5491] | 76 | return mainmenu_2 |
---|
| 77 | |
---|