Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ggz2/data/gui/scripts/MainMenu.lua @ 5902

Last change on this file since 5902 was 5695, checked in by rgrieder, 15 years ago

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1-- MainMenu.lua
2
3BasicGUI = require("BasicGUI")
4local P = BasicGUI:new() --inherit everything from the gui package
5if _REQUIREDNAME == nil then
6    MainMenu = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11P.filename = "MainMenu"
12P.layoutString = "MainMenu.layout"
13
14function P:init()
15    listbox = winMgr:getWindow("orxonox/LevelListbox")
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
38end
39
40
41-- events for mainmenu
42function P.button_quit_clicked(e)
43    hideGUI()
44    orxonox.CommandExecutor:execute("exit")
45end
46
47function P.button_standalone_clicked(e)
48    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
49    if choice then
50        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
51        orxonox.CommandExecutor:execute("startGame")
52        toggleGUI()
53    end
54end
55
56function P.button_server_clicked(e)
57    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
58    if choice then
59        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
60        orxonox.CommandExecutor:execute("startServer")
61        toggleGUI()
62    end
63end
64
65function P.button_dedicated_clicked(e)
66    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
67    if choice then
68        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
69        orxonox.CommandExecutor:execute("startDedicated")
70        toggleGUI()
71    end
72end
73
74function P.button_client_clicked(e)
75    choice = winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem()
76    if choice then
77        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
78        orxonox.CommandExecutor:execute("startClient")
79        toggleGUI()
80    end
81end
82
83function P.listbox_level_selectionchanged(e)
84    if winMgr:getWindow("orxonox/LevelListbox"):getFirstSelectedItem() then
85        winMgr:getWindow("orxonox/StandaloneButton"):enable()
86    else
87        winMgr:getWindow("orxonox/StandaloneButton"):disable()
88    end
89end
90
91return P
92
Note: See TracBrowser for help on using the repository browser.