Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

First steps with lua, CEGUI and the Singleplayer menu.

File:
1 edited

Legend:

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

    r8706 r8890  
    55P.levelList = {}
    66P.itemList = {}
    7 P.showAll = false
    87
    98function P.onLoad()
    10     local window = winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox")
    11     local button = tolua.cast(window,"CEGUI::Checkbox")
    12     button:setSelected(false)
    13     P.createLevelList()
     9    P.createLevelList(nil)
    1410
    1511    --buttons are arranged in a 1x2 matrix
     
    2521end
    2622
    27 function P.onShow()
    28     if P.showAll ~= orxonox.GUIManager:inDevMode() then
    29         local window = winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox")
    30         local button = tolua.cast(window,"CEGUI::Checkbox")
    31         P.showAll = not P.showAll
    32         button:setSelected(P.showAll)
    33         P.createLevelList()
    34     end
    35 end
    36 
    37 function P.createLevelList()
     23function P.createLevelList(tag)
    3824    P.levelList = {}
    3925    P.itemList = {}
     
    4834        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
    4935        if level ~= nil then
    50             if P.showAll or not level:hasTag("test") then
     36            if tag == nil then
     37                table.insert(P.levelList, level)
     38            elseif level:hasTag(tag) then
    5139                table.insert(P.levelList, level)
    5240            end
     
    8068end
    8169
    82 function P.SingleplayerShowAll_clicked(e)
    83     local checkbox = tolua.cast(winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox"), "CEGUI::Checkbox")
    84     local show = checkbox:isSelected()
    85     if show ~= P.showAll then
    86         P.showAll = show
    87         P.createLevelList()
    88    end
    89 end
    90 
    9170function P.SingleplayerBackButton_clicked(e)
    9271    hideMenuSheet(P.name)
Note: See TracChangeset for help on using the changeset viewer.