Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua @ 10251

Last change on this file since 10251 was 10251, checked in by landauf, 9 years ago

use relative path

File size: 4.0 KB
RevLine 
[10157]1--CampaignMenu.lua
2
3local P = createMenuSheet("CampaignMenu")
4
5function P.onLoad()
[10250]6   
7    local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
8    if (P.CheckLevel("missionOne.oxw")) then
9    MissionTwoButton:setProperty("Disabled", "False")
10    end
11   
12    local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
13    if (P.CheckLevel("fightInOurBack.oxw")) then
14    MissionThreeButton:setProperty("Disabled", "False")
15    end
[10157]16
[10250]17    local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
18    if (P.CheckLevel("pirateAttack.oxw")) then
19    MissionFourButton:setProperty("Disabled", "False")
20    end
21   
22    local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
23    if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
24    Completed:setProperty("Visible","True")
25    end
[10157]26end
27
28function P.GenerateHelperString(number)
[10250]29    local string = ""
30    while number > 1 do
31        string = string.." "
32        number = number-1
33    end
34    string = string.."."
35    return string
[10157]36end
37
38function P.FindLevel(filename)
[10250]39    local level = nil
40    local templevel = nil
41    local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
[10157]42    local index = 0
43    while index < size do
[10250]44        templevel = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
45        if(templevel:getXMLFilename()==filename) then 
46            level = templevel
47        end
[10157]48    index=index+1
49    end
50    return level
51end
52   
53function P.CheckLevel(filename)
[10251]54    local file = io.open("campaign.txt", "r+")
[10250]55    local index = 0
56    local returnvalue = false
57    local numberoflines = 58-string.len(filename)
58    local helpstringfalse = filename.." 0"..P.GenerateHelperString(numberoflines) 
59    local helpstringtrue = filename.." 1"..P.GenerateHelperString(numberoflines)
60    while index < 100 do
61        local line = file:read()
62        if(line == helpstringfalse) then
63            returnvalue = false 
64            break
65        end
66        if(line == helpstringtrue) then
67            returnvalue = true
68            break
69        end
70        index=index+1
71    end
72    io.close(file)
73    return returnvalue
[10157]74end
75
76function P.MissionOneButton_clicked(e)
[10250]77    local level = P.FindLevel("missionOne.oxw")
78        orxonox.execute("startGame " .. level:getXMLFilename())
79        hideAllMenuSheets()
[10157]80end
81
82function P.MissionTwoButton_clicked(e)
[10250]83    local level = P.FindLevel("fightInOurBack.oxw")
84    if (P.CheckLevel("missionOne.oxw")) then
85        orxonox.execute("startGame " .. level:getXMLFilename())
86        hideAllMenuSheets()
87    end
[10157]88end
89
90function P.MissionThreeButton_clicked(e)
[10250]91    local level = P.FindLevel("pirateAttack.oxw")
92    if (P.CheckLevel("fightInOurBack.oxw")) then
93        orxonox.execute("startGame " .. level:getXMLFilename())
94        hideAllMenuSheets()
95    else
96         hideMenuSheet(P.name)
97    end
[10157]98end
99
100function P.MissionFourButton_clicked(e)
[10250]101    local level = P.FindLevel("iJohnVane_TriptoArea51.oxw")
102    if (P.CheckLevel("pirateAttack.oxw")) then
103        orxonox.execute("startGame " .. level:getXMLFilename())
104        hideAllMenuSheets()
105    else
106         hideMenuSheet(P.name)
107    end
[10157]108end
109
110function P.CampaignMenuRefreshButton_clicked(e)
[10250]111    local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
112    if (P.CheckLevel("missionOne.oxw")) then
113    MissionTwoButton:setProperty("Disabled", "False")
114    end
115   
116    local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
117    if (P.CheckLevel("fightInOurBack.oxw")) then
118    MissionThreeButton:setProperty("Disabled", "False")
119    end
[10157]120
[10250]121    local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
122    if (P.CheckLevel("pirateAttack.oxw")) then
123    MissionFourButton:setProperty("Disabled", "False")
124    end
125   
126    local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
127    if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
128    Completed:setProperty("Visible","True")
129    end
[10157]130end
131
132function P.CampaignMenuBackButton_clicked(e)
133    hideMenuSheet(P.name)
134end
135
[10174]136
137
[10157]138return P
Note: See TracBrowser for help on using the repository browser.