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