Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2010, 11:55:23 PM (13 years ago)
Author:
dafrick
Message:

Merged releasetodo, containing a new way to describe and tag levels, back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/gui/scripts/MultiplayerMenu.lua

    r7163 r7648  
    22
    33local P = createMenuSheet("MultiplayerMenu")
     4
     5P.levelList = {}
     6P.itemList = {}
     7P.showAll = false
    48
    59function P.onLoad()
     
    1216        local button = tolua.cast(window,"CEGUI::RadioButton")
    1317        button:setSelected(true)
     18        local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     19        checkbox:setProperty("Disabled", "True")
    1420        P.showServerList()
    1521    end
     
    1824        local button = tolua.cast(window,"CEGUI::RadioButton")
    1925        button:setSelected(true)
     26        local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     27        checkbox:setProperty("Disabled", "False")
    2028        P.showLevelList()
    2129    end
     
    2432        local button = tolua.cast(window,"CEGUI::RadioButton")
    2533        button:setSelected(true)
     34        local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     35        checkbox:setProperty("Disabled", "True")
    2636        P.showLevelList()
    2737    end
     
    3040function P.MultiplayerJoinButton_clicked(e)
    3141    P.multiplayerMode = "startClient"
     42    local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     43    checkbox:setProperty("Disabled", "True")
    3244    P.showServerList()
    3345end
     
    3547function P.MultiplayerHostButton_clicked(e)
    3648    P.multiplayerMode = "startServer"
     49    local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     50    checkbox:setProperty("Disabled", "False")
    3751    P.showLevelList()
    3852end
     
    4054function P.MultiplayerDedicatedButton_clicked(e)
    4155    P.multiplayerMode = "startDedicated"
     56    local checkbox = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     57    checkbox:setProperty("Disabled", "True")
    4258    P.showLevelList()
     59end
     60
     61function P.MultiplayerShowAll_clicked(e)
     62    local checkbox = tolua.cast(winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox"), "CEGUI::Checkbox")
     63    local show = checkbox:isSelected()
     64    if show ~= P.showAll then
     65        P.showAll = show
     66        P.createLevelList()
     67    end
    4368end
    4469
     
    6994
    7095function P.showLevelList()
    71     local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
    72     CEGUI.toListbox(listbox):resetList()
     96    P.createLevelList()
     97end
     98
     99function P.createLevelList()
     100    P.levelList = {}
     101    P.itemList = {}
     102    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/MultiplayerListbox"))
     103    listbox:resetList()
     104    orxonox.GUIManager:setItemTooltipsEnabledHelper(listbox, true)
    73105    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
    74     orxonox.LevelManager:getInstance():compileAvailableLevelList()
    75     local levelList = {}
     106    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
    76107    local index = 0
    77     local level = ""
    78     while true do
     108    local level = nil
     109    while index < size do
    79110        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    80         if level == "" then
    81             break
     111        if level ~= nil then
     112            if P.showAll or not level:hasTag("test") then
     113                table.insert(P.levelList, level)
     114            end
    82115        end
    83         table.insert(levelList, level)
    84116        index = index + 1
    85117    end
    86     table.sort(levelList)
    87     index = 1
    88     for k,v in pairs(levelList) do
    89         local item = CEGUI.createListboxTextItem(v)
     118    --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
     119    --table.sort(levelList)
     120    for k,v in pairs(P.levelList) do
     121        local item = CEGUI.createListboxTextItem(v:getName())
    90122        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    91         item:setID(index)
    92         index = index + 1
    93         CEGUI.toListbox(listbox):addItem(item)
    94         if v .. ".oxw" == preselect then
     123        listbox:addItem(item)
     124        if v:getXMLFilename() == preselect then
    95125            listbox:setItemSelectState(item, true)
    96126        end
     127        P.itemList[k] = listbox:getListboxItemFromIndex(k-1)
     128        orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
    97129    end
    98     end
    99    
     130end
     131
    100132function P.showServerList()
    101133    local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
Note: See TracChangeset for help on using the changeset viewer.