132 } |
132 } |
133 } |
133 } |
134 return descriptionList; |
134 return descriptionList; |
135 } |
135 } |
136 |
136 |
|
137 QStringList getImages(QString & campaignName, QString & teamName) |
|
138 { |
|
139 QStringList imageList; |
|
140 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
|
141 teamfile.setIniCodec("UTF-8"); |
|
142 unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt(); |
|
143 qDebug("HERE is progress : %d",progress); |
|
144 unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt(); |
|
145 qDebug("HERE is unlocked missions : %d",unlockedMissions); |
|
146 |
|
147 QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0); |
|
148 campfile.setIniCodec("UTF-8"); |
|
149 unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt(); |
|
150 qDebug("HERE is number of missions : %d",missionsNumber); |
|
151 |
|
152 |
|
153 DataManager & dataMgr = DataManager::instance(); |
|
154 // get locale |
|
155 QSettings settings(dataMgr.settingsFileName(), |
|
156 QSettings::IniFormat); |
|
157 QString loc = settings.value("misc/locale", "").toString(); |
|
158 if (loc.isEmpty()) |
|
159 loc = QLocale::system().name(); |
|
160 QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt"); |
|
161 // if file is non-existant try with language only |
|
162 if (!QFile::exists(campaignDescFile)) |
|
163 campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt"); |
|
164 |
|
165 // fallback if file for current locale is non-existant |
|
166 if (!QFile::exists(campaignDescFile)) |
|
167 campaignDescFile = QString("physfs://Locale/campaigns_en.txt"); |
|
168 |
|
169 QSettings m_info(campaignDescFile, QSettings::IniFormat, 0); |
|
170 m_info.setIniCodec("UTF-8"); |
|
171 |
|
172 if(progress>=0 and unlockedMissions==0) |
|
173 { |
|
174 for(unsigned int i=progress+1;i>0;i--) |
|
175 { |
|
176 //update descruiptions here |
|
177 imageList += campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png")); |
|
178 } |
|
179 } |
|
180 else if(unlockedMissions>0) |
|
181 { |
|
182 qDebug("IN HERE !!!"); |
|
183 for(unsigned int i=1;i<=unlockedMissions;i++) |
|
184 { |
|
185 QString missionNum = QString("%1").arg(i); |
|
186 imageList += campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png")); |
|
187 } |
|
188 } |
|
189 return imageList; |
|
190 } |
|
191 |
137 unsigned int getCampProgress(QString & teamName, QString & campName) |
192 unsigned int getCampProgress(QString & teamName, QString & campName) |
138 { |
193 { |
139 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
194 QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); |
140 teamfile.setIniCodec("UTF-8"); |
195 teamfile.setIniCodec("UTF-8"); |
141 return teamfile.value("Campaign " + campName + "/Progress", 0).toInt(); |
196 return teamfile.value("Campaign " + campName + "/Progress", 0).toInt(); |