Last change
on this file since 7047 was
6206,
checked in by cmueri, 15 years ago
|
The new menus (but not all functions of the menu) are now available.
|
File size:
1.6 KB
|
Line | |
---|
1 | -- SingleplayerMenu.lua |
---|
2 | |
---|
3 | BasicGUI = require("BasicGUI") |
---|
4 | local P = BasicGUI:new() --inherit everything from the gui package |
---|
5 | if _REQUIREDNAME == nil then |
---|
6 | SingleplayerMenu = P |
---|
7 | else |
---|
8 | _G[_REQUIREDNAME] = P |
---|
9 | end |
---|
10 | |
---|
11 | P.filename = "SingleplayerMenu" |
---|
12 | P.layoutString = "SingleplayerMenu.layout" |
---|
13 | |
---|
14 | function P:init() |
---|
15 | listbox = winMgr:getWindow("orxonox/SingleplayerLevelListbox") |
---|
16 | preselect = orxonox.LevelManager:getInstance():getDefaultLevel() |
---|
17 | orxonox.LevelManager:getInstance():compileAvailableLevelList() |
---|
18 | local levelList = {} |
---|
19 | local index = 0 |
---|
20 | local level = "" |
---|
21 | while true do |
---|
22 | level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index) |
---|
23 | if level == "" then |
---|
24 | break |
---|
25 | end |
---|
26 | table.insert(levelList, level) |
---|
27 | index = index + 1 |
---|
28 | end |
---|
29 | table.sort(levelList) |
---|
30 | for k,v in pairs(levelList) do |
---|
31 | item = CEGUI.createListboxTextItem(v) |
---|
32 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
33 | CEGUI.toListbox(listbox):addItem(item) |
---|
34 | if v .. ".oxw" == preselect then |
---|
35 | listbox:setItemSelectState(item, true) |
---|
36 | end |
---|
37 | end |
---|
38 | end |
---|
39 | |
---|
40 | function P.SingleplayerStartButton_clicked(e) |
---|
41 | choice = winMgr:getWindow("orxonox/SingleplayerLevelListbox"):getFirstSelectedItem() |
---|
42 | if choice then |
---|
43 | orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw") |
---|
44 | orxonox.CommandExecutor:execute("startGame") |
---|
45 | hideAllGUIs() |
---|
46 | end |
---|
47 | end |
---|
48 | |
---|
49 | function P.SingleplayerBackButton_clicked(e) |
---|
50 | hideGUI(P.filename) |
---|
51 | end |
---|
52 | |
---|
53 | return P |
---|
54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.