[6363] | 1 | -- MultiplayerMenu.lua |
---|
| 2 | |
---|
| 3 | BasicGUI = require("BasicGUI") |
---|
[6459] | 4 | local P = BasicGUI:new("MultiplayerMenu") |
---|
[6363] | 5 | if _REQUIREDNAME == nil then |
---|
| 6 | MultiplayerMenu = P |
---|
| 7 | else |
---|
| 8 | _G[_REQUIREDNAME] = P |
---|
| 9 | end |
---|
| 10 | |
---|
| 11 | function P:init() |
---|
| 12 | listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox") |
---|
| 13 | preselect = orxonox.LevelManager:getInstance():getDefaultLevel() |
---|
| 14 | orxonox.LevelManager:getInstance():compileAvailableLevelList() |
---|
| 15 | local levelList = {} |
---|
| 16 | local index = 0 |
---|
| 17 | local level = "" |
---|
| 18 | while true do |
---|
| 19 | level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) |
---|
| 20 | if level == "" then |
---|
| 21 | break |
---|
| 22 | end |
---|
| 23 | table.insert(levelList, level) |
---|
| 24 | index = index + 1 |
---|
| 25 | end |
---|
| 26 | table.sort(levelList) |
---|
| 27 | for k,v in pairs(levelList) do |
---|
[6388] | 28 | item = CEGUI.createListboxTextItem(v) |
---|
[6363] | 29 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
| 30 | CEGUI.toListbox(listbox):addItem(item) |
---|
| 31 | if v .. ".oxw" == preselect then |
---|
| 32 | listbox:setItemSelectState(item, true) |
---|
| 33 | end |
---|
| 34 | end |
---|
| 35 | local multiplayerMode = "startClient" |
---|
| 36 | if multiplayerMode == "startClient" then |
---|
| 37 | window = winMgr:getWindow("orxonox/MultiplayerJoinButton") |
---|
| 38 | button = tolua.cast(window,"CEGUI::RadioButton") |
---|
| 39 | button:setSelected(true) |
---|
| 40 | end |
---|
| 41 | if multiplayerMode == "startServer" then |
---|
| 42 | window = winMgr:getWindow("orxonox/MultiplayerHostButton") |
---|
| 43 | button = tolua.cast(window,"CEGUI::RadioButton") |
---|
| 44 | button:setSelected(true) |
---|
| 45 | end |
---|
| 46 | if multiplayerMode == "startDedicated" then |
---|
| 47 | window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton") |
---|
| 48 | button = tolua.cast(window,"CEGUI::RadioButton") |
---|
| 49 | button:setSelected(true) |
---|
| 50 | end |
---|
| 51 | end |
---|
| 52 | |
---|
| 53 | function P.MultiplayerJoinButton_clicked(e) |
---|
| 54 | multiplayerMode = "startClient" |
---|
| 55 | end |
---|
| 56 | |
---|
| 57 | function P.MultiplayerHostButton_clicked(e) |
---|
| 58 | multiplayerMode = "startServer" |
---|
| 59 | end |
---|
| 60 | |
---|
| 61 | function P.MultiplayerDedicatedButton_clicked(e) |
---|
| 62 | multiplayerMode = "startDedicated" |
---|
| 63 | end |
---|
| 64 | |
---|
| 65 | function P.MultiplayerStartButton_clicked(e) |
---|
| 66 | local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem() |
---|
| 67 | if choice then |
---|
| 68 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
[6403] | 69 | orxonox.execute(multiplayerMode) |
---|
[6363] | 70 | hideAllGUIs() |
---|
| 71 | end |
---|
| 72 | end |
---|
| 73 | |
---|
| 74 | function P.MultiplayerBackButton_clicked(e) |
---|
| 75 | hideGUI(P.filename) |
---|
| 76 | end |
---|
| 77 | |
---|
| 78 | return P |
---|
| 79 | |
---|