Changeset 8894
- Timestamp:
- Oct 12, 2011, 9:48:04 PM (13 years ago)
- Location:
- code/branches/menue/data/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menue/data/gui/layouts/SingleplayerMenu.layout
r8890 r8894 21 21 <Property Name="TabPanePosition" Value="Top" /> 22 22 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.925,0}}" /> 23 <Window Type="MenuWidgets/Listbox" Name="orxonox/SingleplayerLevelListbox" >24 <Property Name="Text" Value="Show All" />25 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />26 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}" />27 </Window>28 <Window Type="MenuWidgets/Listbox" Name="orxonox/SingleplayerLevelListboxx" >29 <Property Name="Text" Value="Tests" />30 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />31 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}" />32 </Window>33 23 </Window> 34 24 </Window> -
code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
r8890 r8894 4 4 5 5 P.levelList = {} 6 P.itemList = {}7 6 8 7 function P.onLoad() 9 P.createLevelList(nil) 8 P.createLevelList() 9 10 -- create tabs with desired tab as argument (nil for all) 11 P.createFilterTab("Show All", nil) 12 P.createFilterTab("Tests", "test") 13 P.createFilterTab("Tutorials", "tutorial") 14 P.createFilterTab("Showcases", "showcase") 15 P.createFilterTab("SP?", "singleplayer") 16 P.createFilterTab("Presentations", "presentation") 10 17 11 18 --buttons are arranged in a 1x2 matrix … … 21 28 end 22 29 23 function P.createLevelList( tag)30 function P.createLevelList() 24 31 P.levelList = {} 25 P.itemList = {}26 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))27 listbox:resetList()28 orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)29 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()30 32 local size = orxonox.LevelManager:getInstance():getNumberOfLevels() 31 33 local index = 0 … … 34 36 level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) 35 37 if level ~= nil then 36 if tag == nil then 37 table.insert(P.levelList, level) 38 elseif level:hasTag(tag) then 39 table.insert(P.levelList, level) 40 end 38 table.insert(P.levelList, level) 41 39 end 42 40 index = index + 1 43 41 end 42 end 44 43 44 function P.createFilterTab(name, tag) 45 -- create unique tab window name 46 local tabName = "orxonox/SingleplayerLevelListbox" 47 if tag ~= nil then 48 tabName = tabName..tag 49 end 50 -- add new tab window with desired name 51 local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl") 52 local newWindow = winMgr:createWindow("MenuWidgets/Listbox", tabName) 53 newWindow:setText(name) 54 newWindow:setProperty("UnifiedMaxSize", "{{1,0},{1,0}}") 55 newWindow:setProperty("UnifiedAreaRect", "{{0.05,0},{0.15,0},{0.95,0},{0.85,0}}") 56 tabControl:addChildWindow(tabName) 57 -- fill listbox with items 58 local listbox = CEGUI.toListbox(newWindow) 59 listbox:resetList() 60 orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true) 61 local preselect = orxonox.LevelManager:getInstance():getDefaultLevel() 45 62 for k,v in pairs(P.levelList) do 46 local item = CEGUI.createListboxTextItem(v:getName()) 47 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 48 listbox:addItem(item) 49 if v:getXMLFilename() == preselect then 50 listbox:setItemSelectState(item, true) 63 -- only add level if it has desired tag 64 if tag == nil or v:hasTag(tag) then 65 local item = CEGUI.createListboxTextItem(v:getName()) 66 item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") 67 listbox:addItem(item) 68 if v:getXMLFilename() == preselect then 69 listbox:setItemSelectState(item, true) 70 end 71 orxonox.GUIManager:setTooltipTextHelper(item, v:getDescription()) 51 72 end 52 P.itemList[k] = listbox:getListboxItemFromIndex(k-1)53 orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())54 73 end 55 74 end 56 75 57 76 function P.SingleplayerStartButton_clicked(e) 58 local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")) 77 -- choose the active listbox 78 local tabControl = CEGUI.toTabControl(winMgr:getWindow("orxonox/SingleplayerTabControl")) 79 local listbox = CEGUI.toListbox(tabControl:getTabContentsAtIndex(tabControl:getSelectedTabIndex())) 59 80 local choice = listbox:getFirstSelectedItem() 60 81 if choice ~= nil then
Note: See TracChangeset
for help on using the changeset viewer.