Changeset 7161 for code/branches/presentation3/data
- Timestamp:
- Jul 28, 2010, 8:29:32 PM (14 years ago)
- Location:
- code/branches/presentation3/data/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/data/gui/layouts/MultiplayerMenu.layout
r6746 r7161 16 16 <Property Name="VertFormatting" Value="TopAligned" /> 17 17 <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2875,0},{0.75,0},{0.6375,0}}" /> 18 <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerL evelListbox" >18 <Window Type="MenuWidgets/Listbox" Name="orxonox/MultiplayerListbox" > 19 19 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 20 20 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.8,0}}" /> -
code/branches/presentation3/data/gui/scripts/MultiplayerMenu.lua
r6746 r7161 4 4 5 5 function P.onLoad() 6 listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox") 7 preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 6 P.multiplayerMode = "startClient" 7 end 8 9 function P.onShow() 10 if P.multiplayerMode == "startClient" then 11 local window = winMgr:getWindow("orxonox/MultiplayerJoinButton") 12 local button = tolua.cast(window,"CEGUI::RadioButton") 13 button:setSelected(true) 14 P.showServerList() 15 end 16 if P.multiplayerMode == "startServer" then 17 local window = winMgr:getWindow("orxonox/MultiplayerHostButton") 18 local button = tolua.cast(window,"CEGUI::RadioButton") 19 button:setSelected(true) 20 P.showLevelList() 21 end 22 if P.multiplayerMode == "startDedicated" then 23 local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton") 24 local button = tolua.cast(window,"CEGUI::RadioButton") 25 button:setSelected(true) 26 P.showLevelList() 27 end 28 end 29 30 function P.MultiplayerJoinButton_clicked(e) 31 P.multiplayerMode = "startClient" 32 P.showServerList() 33 end 34 35 function P.MultiplayerHostButton_clicked(e) 36 P.multiplayerMode = "startServer" 37 P.showLevelList() 38 end 39 40 function P.MultiplayerDedicatedButton_clicked(e) 41 P.multiplayerMode = "startDedicated" 42 P.showLevelList() 43 end 44 45 function P.MultiplayerStartButton_clicked(e) 46 local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem() 47 if P.multiplayerMode == "startClient" then 48 if choice then 49 local client = orxonox.Client:getInstance() 50 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 51 client:setDestination( P.serverList[index][2], 55556 ) 52 else 53 return 54 end 55 else 56 if choice then 57 orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") 58 else 59 return 60 end 61 end 62 orxonox.execute(P.multiplayerMode) 63 hideAllMenuSheets() 64 end 65 66 function P.MultiplayerBackButton_clicked(e) 67 hideMenuSheet(P.name) 68 end 69 70 function P.showLevelList() 71 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 72 CEGUI.toListbox(listbox):resetList() 73 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 8 74 orxonox.LevelManager:getInstance():compileAvailableLevelList() 9 75 local levelList = {} … … 19 85 end 20 86 table.sort(levelList) 87 index = 1 21 88 for k,v in pairs(levelList) do 22 item = CEGUI.createListboxTextItem(v)89 local item = CEGUI.createListboxTextItem(v) 23 90 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 91 item:setID(index) 92 index = index + 1 24 93 CEGUI.toListbox(listbox):addItem(item) 25 94 if v .. ".oxw" == preselect then … … 27 96 end 28 97 end 29 local multiplayerMode = "startClient"30 if multiplayerMode == "startClient" then31 window = winMgr:getWindow("orxonox/MultiplayerJoinButton")32 button = tolua.cast(window,"CEGUI::RadioButton")33 button:setSelected(true)34 98 end 35 if multiplayerMode == "startServer" then 36 window = winMgr:getWindow("orxonox/MultiplayerHostButton") 37 button = tolua.cast(window,"CEGUI::RadioButton") 38 button:setSelected(true) 99 100 function P.showServerList() 101 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 102 CEGUI.toListbox(listbox):resetList() 103 local discovery = orxonox.LANDiscovery:getInstance() 104 discovery:discover() 105 P.serverList = {} 106 local index = 0 107 local servername = "" 108 local serverip = "" 109 while true do 110 servername = discovery:getServerListItemName(index) 111 if servername == "" then 112 break 113 end 114 serverip = discovery:getServerListItemIP(index) 115 if serverip == "" then 116 break 117 end 118 table.insert(P.serverList, {servername, serverip}) 119 index = index + 1 39 120 end 40 if multiplayerMode == "startDedicated" then 41 window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton") 42 button = tolua.cast(window,"CEGUI::RadioButton") 43 button:setSelected(true) 121 index = 1 122 for k,v in pairs(P.serverList) do 123 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 124 item:setID(index) 125 index = index + 1 126 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 127 CEGUI.toListbox(listbox):addItem(item) 44 128 end 45 end46 47 function P.MultiplayerJoinButton_clicked(e)48 multiplayerMode = "startClient"49 end50 51 function P.MultiplayerHostButton_clicked(e)52 multiplayerMode = "startServer"53 end54 55 function P.MultiplayerDedicatedButton_clicked(e)56 multiplayerMode = "startDedicated"57 end58 59 function P.MultiplayerStartButton_clicked(e)60 local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem()61 if choice then62 orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")63 orxonox.execute(multiplayerMode)64 hideAllMenuSheets()65 end66 end67 68 function P.MultiplayerBackButton_clicked(e)69 hideMenuSheet(P.name)70 129 end 71 130
Note: See TracChangeset
for help on using the changeset viewer.