Changeset 7689 for code/trunk/data/gui/scripts/HostMenu.lua
- Timestamp:
- Dec 1, 2010, 3:00:19 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/menu merged: 7587-7588,7594,7607-7608,7649,7663,7670-7671,7687
- Property svn:mergeinfo changed
-
code/trunk/data/gui/scripts/HostMenu.lua
r7687 r7689 6 6 7 7 P.buttonList = {} 8 P.levelList = {} 9 P.itemList = {} 10 P.showAll = false 8 11 9 12 function P.onLoad() 10 P.multiplayerMode = "startClient" 13 P.multiplayerMode = "startServer" 14 local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox") 15 local button = tolua.cast(window,"CEGUI::Checkbox") 16 button:setSelected(false) 17 P.createLevelList() 11 18 12 19 local item = { … … 28 35 local button = tolua.cast(window,"CEGUI::RadioButton") 29 36 button:setSelected(true) 30 P. showLevelList()37 P.createLevelList() 31 38 end 32 39 … … 35 42 local button = tolua.cast(window,"CEGUI::RadioButton") 36 43 button:setSelected(true) 37 P. showLevelList()44 P.createLevelList() 38 45 end 39 46 … … 43 50 end 44 51 52 function P.createLevelList() 53 P.levelList = {} 54 P.itemList = {} 55 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox")) 56 listbox:resetList() 57 orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true) 58 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 59 local size = orxonox.LevelManager:getInstance():getNumberOfLevels() 60 local index = 0 61 local level = nil 62 while index < size do 63 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 64 if level ~= nil then 65 if P.showAll or not level:hasTag("test") then 66 table.insert(P.levelList, level) 67 end 68 end 69 index = index + 1 70 end 71 --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename. 72 --table.sort(levelList) 73 for k,v in pairs(P.levelList) do 74 local item = CEGUI.createListboxTextItem(v:getName()) 75 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 76 listbox:addItem(item) 77 if v:getXMLFilename() == preselect then 78 listbox:setItemSelectState(item, true) 79 end 80 P.itemList[k] = listbox:getListboxItemFromIndex(k-1) 81 orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription()) 82 end 83 end 84 45 85 function P.HostMenuBuildServerButton_clicked(e) 46 86 P.multiplayerMode = "startServer" 47 P. showLevelList()87 P.createLevelList() 48 88 end 49 89 50 90 function P.HostMenuDedicatedButton_clicked(e) 51 91 P.multiplayerMode = "startDedicated" 52 P. showLevelList()92 P.createLevelList() 53 93 end 54 94 … … 57 97 end 58 98 59 function P.HostMenuStartButton_clicked(e) 60 local choice = winMgr:getWindow("orxonox/HostMenuListbox"):getFirstSelectedItem() 61 if choice then 62 orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") 63 else 64 return 65 end 66 orxonox.execute(P.multiplayerMode) 67 hideAllMenuSheets() 68 end 69 70 71 72 function P.showLevelList() 73 local listbox = winMgr:getWindow("orxonox/HostMenuListbox") 74 CEGUI.toListbox(listbox):resetList() 75 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 76 orxonox.LevelManager:getInstance():compileAvailableLevelList() 77 local levelList = {} 78 local index = 0 79 local level = "" 80 while true do 81 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 82 if level == "" then 83 break 84 end 85 table.insert(levelList, level) 86 index = index + 1 87 end 88 table.sort(levelList) 89 index = 1 90 for k,v in pairs(levelList) do 91 local item = CEGUI.createListboxTextItem(v) 92 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 93 item:setID(index) 94 index = index + 1 95 CEGUI.toListbox(listbox):addItem(item) 96 if v .. ".oxw" == preselect then 97 listbox:setItemSelectState(item, true) 99 function P.HostMenuStartButton_clicked(e) 100 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox")) 101 local choice = listbox:getFirstSelectedItem() 102 if choice ~= nil then 103 local index = listbox:getItemIndex(choice) 104 local level = P.levelList[index+1] 105 if level ~= nil then 106 orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename()) 107 orxonox.execute(P.multiplayerMode) 108 hideAllMenuSheets() 98 109 end 99 110 end 100 111 end 101 112 113 function P.MultiplayerShowAll_clicked(e) 114 local checkbox = tolua.cast(winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox"), "CEGUI::Checkbox") 115 local show = checkbox:isSelected() 116 if show ~= P.showAll then 117 P.showAll = show 118 P.createLevelList() 119 end 120 end 102 121 103 122 function P.onKeyPressed() … … 105 124 end 106 125 107 108 109 126 return P
Note: See TracChangeset
for help on using the changeset viewer.