Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/data/gui/scripts/MultiplayerMenu.lua @ 7957

Last change on this file since 7957 was 6773, checked in by rgrieder, 15 years ago

Eliminated all unnecessary global Lua variables and replaced them either with a local or a instance variable (P.myVar).

  • Property svn:eol-style set to native
File size: 2.3 KB
RevLine 
[6363]1-- MultiplayerMenu.lua
2
[6746]3local P = createMenuSheet("MultiplayerMenu")
[6363]4
[6746]5function P.onLoad()
[6773]6    local listbox = winMgr:getWindow("orxonox/MultiplayerLevelListbox")
7    local preselect = orxonox.LevelManager:getInstance():getDefaultLevel()
[6363]8    orxonox.LevelManager:getInstance():compileAvailableLevelList()
9    local levelList = {}
10    local index = 0
11    local level = ""
12    while true do
13        level = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
14        if level == "" then
15            break
16        end
17        table.insert(levelList, level)
18        index = index + 1
19    end
20    table.sort(levelList)
21    for k,v in pairs(levelList) do
[6773]22        local item = CEGUI.createListboxTextItem(v)
[6746]23        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
[6363]24        CEGUI.toListbox(listbox):addItem(item)
25        if v .. ".oxw" == preselect then
26            listbox:setItemSelectState(item, true)
27        end
28    end
[6773]29    P.multiplayerMode = "startClient"
30    if P.multiplayerMode == "startClient" then
31        local window = winMgr:getWindow("orxonox/MultiplayerJoinButton")
32        local button = tolua.cast(window,"CEGUI::RadioButton")
[6363]33        button:setSelected(true)
34    end
[6773]35    if P.multiplayerMode == "startServer" then
36        local window = winMgr:getWindow("orxonox/MultiplayerHostButton")
37        local button = tolua.cast(window,"CEGUI::RadioButton")
[6363]38        button:setSelected(true)
39    end
[6773]40    if P.multiplayerMode == "startDedicated" then
41        local window = winMgr:getWindow("orxonox/MultiplayerDedicatedButton")
42        local button = tolua.cast(window,"CEGUI::RadioButton")
[6363]43        button:setSelected(true)
44    end
45end
46
47function P.MultiplayerJoinButton_clicked(e)
[6773]48    P.multiplayerMode = "startClient"
[6363]49end
50
51function P.MultiplayerHostButton_clicked(e)
[6773]52    P.multiplayerMode = "startServer"
[6363]53end
54
55function P.MultiplayerDedicatedButton_clicked(e)
[6773]56    P.multiplayerMode = "startDedicated"
[6363]57end
58
59function P.MultiplayerStartButton_clicked(e)
60    local choice = winMgr:getWindow("orxonox/MultiplayerLevelListbox"):getFirstSelectedItem()
61    if choice then
62        orxonox.LevelManager:getInstance():setDefaultLevel(choice:getText() .. ".oxw")
[6773]63        orxonox.execute(P.multiplayerMode)
[6746]64        hideAllMenuSheets()
[6363]65    end
66end
67
68function P.MultiplayerBackButton_clicked(e)
[6746]69    hideMenuSheet(P.name)
[6363]70end
71
72return P
73
Note: See TracBrowser for help on using the repository browser.