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.

Location:
code/branches/releasetodo/data/gui/scripts
Files:
2 edited

Legend:

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

    r7163 r7626  
    22
    33local P = createMenuSheet("MultiplayerMenu")
     4
     5P.levelList = {}
     6P.itemList = {}
     7P.showAll = false
    48
    59function P.onLoad()
     
    6973
    7074function P.showLevelList()
    71     local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
    72     CEGUI.toListbox(listbox):resetList()
     75    P.createLevelList()
     76end
     77
     78function P.createLevelList()
     79    P.levelList = {}
     80    P.itemList = {}
     81    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox"))
     82    listbox:resetList()
    7383    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    74     orxonox.LevelManager:getInstance():compileAvailableLevelList()
    75     local levelList = {}
     84    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    7685    local index = 0
    77     local level = ""
    78     while true do
     86    local level = nil
     87    while index < size do
    7988        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    80         if level == "" then
    81             break
     89        if level ~= nil then
     90            if P.showAll or not level:hasTag("test") then
     91                table.insert(P.levelList, level)
     92            end
    8293        end
    83         table.insert(levelList, level)
    8494        index = index + 1
    8595    end
    86     table.sort(levelList)
    87     index = 1
    88     for k,v in pairs(levelList) do
    89         local item = CEGUI.createListboxTextItem(v)
     96    --TODO: Reintroduce sorting, if needed.
     97    --table.sort(levelList)
     98    for k,v in pairs(P.levelList) do
     99        local item = CEGUI.createListboxTextItem(v:getName())
    90100        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    91         item:setID(index)
    92         index = index + 1
    93         CEGUI.toListbox(listbox):addItem(item)
    94         if v .. ".oxw" == preselect then
     101        listbox:addItem(item)
     102        if v:getXMLFilename() == preselect then
    95103            listbox:setItemSelectState(item, true)
    96104        end
     105        P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
     106        --TODO: The description as tooltip would be nice.
     107        --local lItem = tolua.cast("CEGUI::ListboxItem", P.itemList[k])
     108        --lItem:setTooltipText(v:getDescription())
    97109    end
    98     end
    99    
     110end
     111
    100112function P.showServerList()
    101113    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
  • 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.