Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/media/gui/scripts/mainmenu_2.lua @ 5551

Last change on this file since 5551 was 5532, checked in by bknecht, 16 years ago

lua code to upgrade the mainmenu

File size: 1.7 KB
Line 
1-- mainmenu_2.lua
2gui = require("gui")
3local P = gui:new() --inherit everything from the gui package
4
5mainmenu_2 = P
6
7P.filename = "mainmenu_2"
8P.layoutString = "MainMenu_2.layout"
9
10function 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
22end
23
24
25-- events for mainmenu
26function P.button_quit_clicked(e)
27    hideGUI()
28    orxonox.CommandExecutor:execute("exit")
29end
30
31function 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
38end
39
40function P.button_server_clicked(e)
41  orxonox.CommandExecutor:execute("echo Not yet supported!")
42  hideGUI()
43end
44
45function P.button_dedicated_clicked(e)
46  orxonox.CommandExecutor:execute("echo Not yet supported!")
47  hideGUI()
48end
49
50function P.button_client_clicked(e)
51  orxonox.CommandExecutor:execute("echo Not yet supported!")
52  hideGUI()
53end
54
55function 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
61end
62
63return mainmenu_2
64
Note: See TracBrowser for help on using the repository browser.