Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/releasetodo/data/gui/scripts/SingleplayerMenu.lua @ 7625

Last change on this file since 7625 was 7625, checked in by dafrick, 14 years ago

Introducing LevelInfo class, which can be used to specify things about a Level and which is used to provide more flexibility in displaying a list of levels.
Basic functionality works, now all that needs to be dones is to exploit the new functionality.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1-- SingleplayerMenu.lua
2
3local P = createMenuSheet("SingleplayerMenu")
4
5function 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 index = 0
11    local level = ""
12    while index < size do
13      level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
14      table.insert(levelList, level)
15      index = index + 1
16    end
17    table.sort(levelList)
18    for k,v in pairs(levelList) do
19        item = CEGUI.createListboxTextItem(v)
20        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
21        CEGUI.toListbox(listbox):addItem(item)
22        if v .. ".oxw" == preselect then
23            listbox:setItemSelectState(item, true)
24        end
25    end
26
27end
28
29function 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()
35    end
36end
37
38function P.SingleplayerBackButton_clicked(e)
39    hideMenuSheet(P.name)
40end
41
42return P
43
Note: See TracBrowser for help on using the repository browser.