Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 6, 2010, 9:52:48 PM (14 years ago)
Author:
dafrick
Message:

Accidentally removed a file. Re-adding it.
Levels that are tagged with "test" are now not displayed by default, but can be displayed by choosing show all.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua

    r7625 r7626  
    33local P = createMenuSheet("SingleplayerMenu")
    44
     5P.levelList = {}
     6P.itemList = {}
     7P.showAll = false
     8
    59function P.onLoad()
    6     listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
    7     preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    8     size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    9     local levelList = {}
     10    local window = winMgr:getWindow("orxonox/SingleplayerShowRestrictedButton")
     11    local button = tolua.cast(window,"CEGUI::RadioButton")
     12    button:setSelected(true)
     13    P.createLevelList()
     14end
     15
     16function P.createLevelList()
     17    P.levelList = {}
     18    P.itemList = {}
     19    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
     20    listbox:resetList()
     21    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
     22    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    1023    local index = 0
    11     local level = ""
     24    local level = nil
    1225    while index < size do
    13       level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    14       table.insert(levelList, level)
    15       index = index + 1
     26        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
     27        if level ~= nil then
     28            if P.showAll or not level:hasTag("test") then
     29                table.insert(P.levelList, level)
     30            end
     31        end
     32        index = index + 1
    1633    end
    17     table.sort(levelList)
    18     for k,v in pairs(levelList) do
    19         item = CEGUI.createListboxTextItem(v)
     34    --TODO: Reintroduce sorting, if needed.
     35    --table.sort(levelList)
     36    for k,v in pairs(P.levelList) do
     37        local item = CEGUI.createListboxTextItem(v:getName())
    2038        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    21         CEGUI.toListbox(listbox):addItem(item)
    22         if v .. ".oxw" == preselect then
     39        listbox:addItem(item)
     40        if v:getXMLFilename() == preselect then
    2341            listbox:setItemSelectState(item, true)
    2442        end
     43        P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
     44        --TODO: The description as tooltip would be nice.
     45        --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k])
     46        --lItem:setTooltipText(v:getDescription())
    2547    end
    26 
    2748end
    2849
    2950function P.SingleplayerStartButton_clicked(e)
    30     local choice = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")):getFirstSelectedItem()
    31     if choice then
    32         orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
    33         orxonox.execute("startGame")
    34         hideAllMenuSheets()
     51    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox"))
     52    local choice = listbox:getFirstSelectedItem()
     53    if choice ~= nil then
     54        local index = listbox:getItemIndex(choice)
     55        local level = P.levelList[index+1]
     56        if level ~= nil then
     57            orxonox.LevelManager:getInstance():setDefaultLevel(level:getXMLFilename())
     58            orxonox.execute("startGame")
     59            hideAllMenuSheets()
     60        end
    3561    end
     62end
     63
     64function P.SingleplayerShowRestrictedButton_clicked(e)
     65    P.showAll = false
     66    P.createLevelList()
     67end
     68
     69function P.SingleplayerShowAllButton_clicked(e)
     70    P.showAll = true
     71    P.createLevelList()
    3672end
    3773
Note: See TracChangeset for help on using the changeset viewer.