Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/data/gui/scripts/mainmenu_4.lua @ 5646

Last change on this file since 5646 was 5587, checked in by rgrieder, 15 years ago

svn eol-style, so I don't see the mysterious line ending characters in vim ;)

  • Property svn:eol-style set to native
File size: 2.6 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.LevelManager:getInstance():getDefaultLevel()
13    orxonox.LevelManager:getInstance():compileAvailableLevelList()
14    local levelList = {}
15    local index = 0
16    local level = ""
17    while true do
18      level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
19      if level == "" then
20        break
21      end
22      table.insert(levelList, level)
23      index = index + 1
24    end
25    table.sort(levelList)
26    for k,v in pairs(levelList) do
27        item = CEGUI.createListboxTextItem(v)       
28        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
29        CEGUI.toListbox(listbox):addItem(item)
30        if v .. ".oxw" == preselect then
31            listbox:setItemSelectState(item, true)
32        end
33    end
34end
35
36
37-- events for mainmenu
38function P.button_quit_clicked(e)
39    hideGUI()
40    orxonox.CommandExecutor:execute("exit")
41end
42
43function P.button_standalone_clicked(e)
44    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
45    if choice then
46        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
47        orxonox.CommandExecutor:execute("startGame")
48        toggleGUI()
49    end
50end
51
52function P.button_server_clicked(e)
53    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
54    if choice then
55        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
56        orxonox.CommandExecutor:execute("startServer")
57        toggleGUI()
58    end
59end
60
61function P.button_dedicated_clicked(e)
62    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
63    if choice then
64        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
65        orxonox.CommandExecutor:execute("startDedicated")
66        toggleGUI()
67    end
68end
69
70function P.button_client_clicked(e)
71    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
72    if choice then
73        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
74        orxonox.CommandExecutor:execute("startClient")
75        toggleGUI()
76    end
77end
78
79function P.listbox_level_selectionchanged(e)
80    if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then
81        winMgr:getWindow("orxonox/StandaloneButton"):enable()
82    else
83        winMgr:getWindow("orxonox/StandaloneButton"):disable()
84    end
85end
86
87return mainmenu_2
88
Note: See TracBrowser for help on using the repository browser.