Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/data/gui/scripts/SingleplayerMenu.lua @ 6571

Last change on this file since 6571 was 6571, checked in by rgrieder, 14 years ago

Removed last remains of hard coded Taharez references:
Refer to the ImageSets with menuImageSet or hudImageSet from now on (in lua scripts).
(and hope that the image you're looking for is named like that in every look…)

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