Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/bindermFS16/data/gui/scripts/CampaignMenu.lua @ 11180

Last change on this file since 11180 was 11180, checked in by binderm, 8 years ago

logic to show only certain levels and not all together, also not all shown levels have to be activated

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1--CampaignMenu.lua
2
3local P = createMenuSheet("CampaignMenu")
4
5function P:onShow()
6    P:updateButtons()
7end
8
9function P.updateButtons()
10    P.updateButton(0, winMgr:getWindow("orxonox/Mission1Button"))
11    P.updateButton(1, winMgr:getWindow("orxonox/Mission2Button"))
12    P.updateButton(2, winMgr:getWindow("orxonox/Mission3Button"))
13    P.updateButton(3, winMgr:getWindow("orxonox/Mission4Button"))
14    P.updateButton(4, winMgr:getWindow("orxonox/Mission5Button"))
15    P.updateButton(5, winMgr:getWindow("orxonox/Mission6Button"))
16    P.updateButton(6, winMgr:getWindow("orxonox/Mission7Button"))
17    P.updateButton(7, winMgr:getWindow("orxonox/Mission8Button"))
18    P.updateButton(8, winMgr:getWindow("orxonox/Mission9Button"))
19
20
21--    if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then
22--        local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
23--        label:setProperty("Visible","True")
24--    end
25end
26
27function P.updateButton(index, button)
28    local test =orxonox.LevelManager:getInstance():missionactivate(index)
29    if (test==1) then
30        button:setProperty("Visible", "True")
31        button:setProperty("Disabled", "False")
32    elseif (test==2) then
33        button:setProperty("Visible", "True")
34        button:setProperty("Disabled", "True")
35    else
36        button:setProperty("Visible", "False")
37        button:setProperty("Disabled", "True")
38    end
39end
40
41--function P.shouldDisplayButton(index)
42--    local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
43--    return index < size
44--end
45
46--function P.shouldActivateButton(index) --checks if button should be activated or not
47--    return index <= P.getIndexOfLastFinishedMission() + 1
48--end
49
50--function P.getIndexOfLastFinishedMission()
51--    local lastMission = orxonox.LevelManager:getInstance():getLastFinishedCampaignMission()
52--    if (lastMission and lastMission ~= "") then
53--        local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
54--        local index = 0
55--        while index < size do
56--            local mission = orxonox.LevelManager:getInstance():getCampaignMission(index)
57--            if (mission == lastMission) then
58--                return index
59--            end
60--            index = index + 1
61--        end
62--    end
63--    return -1
64--end
65
66function P.Mission1Button_clicked(e)
67    P.loadLevel(P.FindLevel(0))
68end
69
70function P.Mission2Button_clicked(e)
71    P.loadLevel(P.FindLevel(1))
72end
73
74function P.Mission3Button_clicked(e)
75    P.loadLevel(P.FindLevel(2))
76end
77
78function P.Mission4Button_clicked(e)
79    P.loadLevel(P.FindLevel(3))
80end
81
82function P.Mission5Button_clicked(e)
83    P.loadLevel(P.FindLevel(4))
84end
85
86function P.Mission6Button_clicked(e)
87    P.loadLevel(P.FindLevel(5))
88end
89
90function P.Mission7Button_clicked(e)
91    P.loadLevel(P.FindLevel(6))
92end
93
94function P.Mission8Button_clicked(e)
95    P.loadLevel(P.FindLevel(7))
96end
97
98function P.Mission9Button_clicked(e)
99    P.loadLevel(P.FindLevel(8))
100end
101
102function P.loadLevel(level)
103    orxonox.execute("startGame " .. level:getXMLFilename())
104    hideAllMenuSheets()
105end
106
107function P.FindLevel(index)
108    local filename = orxonox.LevelManager:getInstance():getCampaignMission(index)
109    local level = nil
110    local templevel = nil
111    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
112    local index = 0
113    while index < size do
114        templevel = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
115        if(templevel:getXMLFilename()==filename) then 
116            level = templevel
117        end
118    index=index+1
119    end
120    return level
121end
122
123function P.CampaignMenuBackButton_clicked(e)
124    hideMenuSheet(P.name)
125end
126
127return P
Note: See TracBrowser for help on using the repository browser.