Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8894


Ignore:
Timestamp:
Oct 12, 2011, 9:48:04 PM (13 years ago)
Author:
baermatt
Message:

Added tabs in Singleplayer level selection menu.

Location:
code/branches/menue/data/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menue/data/gui/layouts/SingleplayerMenu.layout

    r8890 r8894  
    2121                <Property Name="TabPanePosition" Value="Top" />
    2222                <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>
    3323            </Window>
    3424        </Window>
  • code/branches/menue/data/gui/scripts/SingleplayerMenu.lua

    r8890 r8894  
    44
    55P.levelList = {}
    6 P.itemList = {}
    76
    87function 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")
    1017
    1118    --buttons are arranged in a 1x2 matrix
     
    2128end
    2229
    23 function P.createLevelList(tag)
     30function P.createLevelList()
    2431    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()
    3032    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    3133    local index = 0
     
    3436        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    3537        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)
    4139        end
    4240        index = index + 1
    4341    end
     42end
    4443
     44function 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()
    4562    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())
    5172        end
    52         P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
    53         orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
    5473    end
    5574end
    5675
    5776function 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()))
    5980    local choice = listbox:getFirstSelectedItem()
    6081    if choice ~= nil then
Note: See TracChangeset for help on using the changeset viewer.