1 | -- mainmenu_2.lua |
---|
2 | gui = require("gui") |
---|
3 | local P = gui:new() --inherit everything from the gui package |
---|
4 | |
---|
5 | mainmenu_2 = P |
---|
6 | |
---|
7 | P.filename = "mainmenu_2" |
---|
8 | P.layoutString = "MainMenu_2.layout" |
---|
9 | |
---|
10 | function P:init() |
---|
11 | listbox = winMgr:getWindow("orxonox/LevelListbox") |
---|
12 | preselect = orxonox.Game:getInstance():getLevel() |
---|
13 | orxonox.GUIManager:getInstance():getLevelList() --levellist variable ist set now |
---|
14 | for k,v in pairs(levellist) do |
---|
15 | item = CEGUI.createListboxTextItem(v) |
---|
16 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
17 | CEGUI.toListbox(listbox):addItem(item) |
---|
18 | if v .. ".oxw" == preselect then |
---|
19 | listbox:setItemSelectState(item, true) |
---|
20 | end |
---|
21 | end |
---|
22 | end |
---|
23 | |
---|
24 | |
---|
25 | -- events for mainmenu |
---|
26 | function P.button_quit_clicked(e) |
---|
27 | hideGUI() |
---|
28 | orxonox.CommandExecutor:execute("exit") |
---|
29 | end |
---|
30 | |
---|
31 | function P.button_standalone_clicked(e) |
---|
32 | choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() |
---|
33 | if choice then |
---|
34 | orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw") |
---|
35 | orxonox.CommandExecutor:execute("startGame") |
---|
36 | toggleGUI() |
---|
37 | end |
---|
38 | end |
---|
39 | |
---|
40 | function P.button_server_clicked(e) |
---|
41 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
42 | hideGUI() |
---|
43 | end |
---|
44 | |
---|
45 | function P.button_dedicated_clicked(e) |
---|
46 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
47 | hideGUI() |
---|
48 | end |
---|
49 | |
---|
50 | function P.button_client_clicked(e) |
---|
51 | orxonox.CommandExecutor:execute("echo Not yet supported!") |
---|
52 | hideGUI() |
---|
53 | end |
---|
54 | |
---|
55 | function P.listbox_level_selectionchanged(e) |
---|
56 | if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then |
---|
57 | winMgr:getWindow("orxonox/StandaloneButton"):enable() |
---|
58 | else |
---|
59 | winMgr:getWindow("orxonox/StandaloneButton"):disable() |
---|
60 | end |
---|
61 | end |
---|
62 | |
---|
63 | return mainmenu_2 |
---|
64 | |
---|