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
RevLine 
[10157]1--CampaignMenu.lua
2
3local P = createMenuSheet("CampaignMenu")
4
[10253]5function P:onShow()
6    P:updateButtons()
[10157]7end
8
[10253]9function P.updateButtons()
[11052]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"))
[10253]19
[11052]20
[11173]21--    if (P.getIndexOfLastFinishedMission() == orxonox.LevelManager:getInstance():getNumberOfCampaignMissions() - 1) then
22--        local label = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
23--        label:setProperty("Visible","True")
24--    end
[10157]25end
26
[10253]27function P.updateButton(index, button)
[11180]28    local test =orxonox.LevelManager:getInstance():missionactivate(index)
29    if (test==1) then
[10253]30        button:setProperty("Visible", "True")
[11173]31        button:setProperty("Disabled", "False")
[11180]32    elseif (test==2) then
33        button:setProperty("Visible", "True")
34        button:setProperty("Disabled", "True")
[11173]35    else
[11180]36        button:setProperty("Visible", "False")
[11173]37        button:setProperty("Disabled", "True")
[10157]38    end
39end
[10253]40
[11173]41--function P.shouldDisplayButton(index)
42--    local size = orxonox.LevelManager:getInstance():getNumberOfCampaignMissions()
43--    return index < size
44--end
[10253]45
[11173]46--function P.shouldActivateButton(index) --checks if button should be activated or not
47--    return index <= P.getIndexOfLastFinishedMission() + 1
48--end
[10253]49
[11173]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
[10157]65
[11052]66function P.Mission1Button_clicked(e)
[10253]67    P.loadLevel(P.FindLevel(0))
[10157]68end
69
[11052]70function P.Mission2Button_clicked(e)
[10253]71    P.loadLevel(P.FindLevel(1))
[10157]72end
73
[11052]74function P.Mission3Button_clicked(e)
[10253]75    P.loadLevel(P.FindLevel(2))
[10157]76end
77
[11052]78function P.Mission4Button_clicked(e)
[10253]79    P.loadLevel(P.FindLevel(3))
[10157]80end
81
[11052]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
[10253]102function P.loadLevel(level)
103    orxonox.execute("startGame " .. level:getXMLFilename())
104    hideAllMenuSheets()
105end
[10157]106
[10253]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
[10250]119    end
[10253]120    return level
[10157]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.