Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/SingleplayerMenu.lua @ 7535

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

Merged presentation3 branch into trunk.

  • Property svn:eol-style set to native
File size: 1.3 KB
RevLine 
[6363]1-- SingleplayerMenu.lua
2
[6746]3local P = createMenuSheet("SingleplayerMenu")
[6363]4
[6746]5function P.onLoad()
[6363]6    listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox")
7    preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
8    orxonox.LevelManager:getInstance():compileAvailableLevelList()
9    local levelList = {}
10    local index = 0
11    local level = ""
12    while true do
13      level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
14      if level == "" then
15        break
16      end
17      table.insert(levelList, level)
18      index = index + 1
19    end
20    table.sort(levelList)
21    for k,v in pairs(levelList) do
[6388]22        item = CEGUI.createListboxTextItem(v)
[6746]23        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
[6363]24        CEGUI.toListbox(listbox):addItem(item)
25        if v .. ".oxw" == preselect then
26            listbox:setItemSelectState(item, true)
27        end
28    end
[7163]29
[6363]30end
31
32function P.SingleplayerStartButton_clicked(e)
[6754]33    local choice = CEGUI.toListbox(winMgr:getWindow("orxonox/SingleplayerLevelListbox")):getFirstSelectedItem()
[6363]34    if choice then
35        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
[6403]36        orxonox.execute("startGame")
[6746]37        hideAllMenuSheets()
[6363]38    end
39end
40
41function P.SingleplayerBackButton_clicked(e)
[6746]42    hideMenuSheet(P.name)
[6363]43end
44
45return P
46
Note: See TracBrowser for help on using the repository browser.