Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/media/gui/scripts/mainmenu_2.lua @ 3864

Last change on this file since 3864 was 3374, checked in by rgrieder, 15 years ago

Added most of the text based files of the media directory (the file I deleted in the previous commit of the media repo) with svn:eol-style=native

  • Property svn:eol-style set to native
File size: 2.3 KB
RevLine 
[3374]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    table.sort(levellist)
15    for k,v in pairs(levellist) do
16        item = CEGUI.createListboxTextItem(v)       
17        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
18        CEGUI.toListbox(listbox):addItem(item)
19        if v .. ".oxw" == preselect then
20            listbox:setItemSelectState(item, true)
21        end
22    end
23end
24
25
26-- events for mainmenu
27function P.button_quit_clicked(e)
28    hideGUI()
29    orxonox.CommandExecutor:execute("exit")
30end
31
32function P.button_standalone_clicked(e)
33    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
34    if choice then
35        orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw")
36        orxonox.CommandExecutor:execute("startGame")
37        toggleGUI()
38    end
39end
40
41function P.button_server_clicked(e)
42    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
43    if choice then
44        orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw")
45        orxonox.CommandExecutor:execute("startServer")
46        toggleGUI()
47    end
48end
49
50function P.button_dedicated_clicked(e)
51    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
52    if choice then
53        orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw")
54        orxonox.CommandExecutor:execute("startDedicated")
55        toggleGUI()
56    end
57end
58
59function P.button_client_clicked(e)
60    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
61    if choice then
62        orxonox.Game:getInstance():setLevel(choice:getText() .. ".oxw")
63        orxonox.CommandExecutor:execute("startClient")
64        toggleGUI()
65    end
66end
67
68function P.listbox_level_selectionchanged(e)
69    if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then
70        winMgr:getWindow("orxonox/StandaloneButton"):enable()
71    else
72        winMgr:getWindow("orxonox/StandaloneButton"):disable()
73    end
74end
75
76return mainmenu_2
77
Note: See TracBrowser for help on using the repository browser.