Changeset 7739 for code/branches/presentation/data
- Timestamp:
- Dec 8, 2010, 4:25:52 PM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/data/gui/scripts/MultiplayerMenu.lua
r7732 r7739 42 42 function P.LanButton_clicked(e) 43 43 P.joinMode = 1 44 P.showServerList() 44 45 end 45 46 46 47 function P.InternetButton_clicked(e) 47 48 P.joinMode = 2 49 P.showServerList() 48 50 end 49 51 … … 55 57 function P.MultiplayerJoinButton_clicked(e) 56 58 local choice = winMgr:getWindow("orxonox/MultiplayerListbox"):getFirstSelectedItem() 57 58 if P.joinMode == 2 then 59 if choice then 60 local client = orxonox.Client:getInstance() 61 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 62 client:setDestination( P.serverList[index][2], 55556 ) 63 else 64 return 65 end 66 orxonox.execute("startClient") 67 hideAllMenuSheets() 59 if choice then 60 local client = orxonox.Client:getInstance() 61 local index = tolua.cast(choice, "CEGUI::ListboxItem"):getID() 62 client:setDestination( P.serverList[index][2], 55556 ) 68 63 else 69 --wait for Sandro's function64 return 70 65 end 71 66 orxonox.execute("startClient") 67 hideAllMenuSheets() 72 68 end 73 69 … … 77 73 78 74 function P.showServerList() 79 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 80 CEGUI.toListbox(listbox):resetList() 81 local discovery = orxonox.LANDiscovery:getInstance() 82 discovery:discover() 83 P.serverList = {} 84 local index = 0 85 local servername = "" 86 local serverip = "" 87 while true do 88 servername = discovery:getServerListItemName(index) 89 if servername == "" then 90 break 91 end 92 serverip = discovery:getServerListItemIP(index) 93 if serverip == "" then 94 break 95 end 96 table.insert(P.serverList, {servername, serverip}) 97 index = index + 1 98 end 99 index = 1 100 for k,v in pairs(P.serverList) do 101 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 102 item:setID(index) 103 index = index + 1 104 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 105 CEGUI.toListbox(listbox):addItem(item) 106 end 75 -- LAN Discovery 76 if P.joinMode == 1 then 77 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 78 CEGUI.toListbox(listbox):resetList() 79 local discovery = orxonox.LANDiscovery:getInstance() 80 discovery:discover() 81 P.serverList = {} 82 local index = 0 83 local servername = "" 84 local serverip = "" 85 while true do 86 servername = discovery:getServerListItemName(index) 87 if servername == "" then 88 break 89 end 90 serverip = discovery:getServerListItemIP(index) 91 if serverip == "" then 92 break 93 end 94 table.insert(P.serverList, {servername, serverip}) 95 index = index + 1 96 end 97 index = 1 98 for k,v in pairs(P.serverList) do 99 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 100 item:setID(index) 101 index = index + 1 102 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 103 CEGUI.toListbox(listbox):addItem(item) 104 end 105 -- WAN Discovery 106 elseif P.joinMode == 2 then 107 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox") 108 CEGUI.toListbox(listbox):resetList() 109 local discovery = orxonox.WANDiscovery:getInstance() 110 cout(0, "discovering.\n" ) 111 discovery:discover() 112 cout(0, "discovered.\n" ) 113 P.serverList = {} 114 local index = 0 115 local servername = "" 116 local serverip = "" 117 while true do 118 servername = discovery:getServerListItemName(index) 119 if servername == "" then 120 break 121 end 122 serverip = discovery:getServerListItemIP(index) 123 if serverip == "" then 124 break 125 end 126 table.insert(P.serverList, {servername, serverip}) 127 index = index + 1 128 end 129 index = 1 130 for k,v in pairs(P.serverList) do 131 local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] ) 132 item:setID(index) 133 index = index + 1 134 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 135 CEGUI.toListbox(listbox):addItem(item) 136 end 137 end 138 107 139 end 108 140
Note: See TracChangeset
for help on using the changeset viewer.