--- a/QTfrontend/campaign.cpp Fri Jun 28 19:05:41 2013 +0300
+++ b/QTfrontend/campaign.cpp Fri Jun 28 19:32:11 2013 +0300
@@ -134,6 +134,61 @@
return descriptionList;
}
+QStringList getImages(QString & campaignName, QString & teamName)
+{
+ QStringList imageList;
+ QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
+ teamfile.setIniCodec("UTF-8");
+ unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
+ qDebug("HERE is progress : %d",progress);
+ unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
+ qDebug("HERE is unlocked missions : %d",unlockedMissions);
+
+ QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
+ campfile.setIniCodec("UTF-8");
+ unsigned int missionsNumber = campfile.value("MissionNum", 0).toInt();
+ qDebug("HERE is number of missions : %d",missionsNumber);
+
+
+ DataManager & dataMgr = DataManager::instance();
+ // get locale
+ QSettings settings(dataMgr.settingsFileName(),
+ QSettings::IniFormat);
+ QString loc = settings.value("misc/locale", "").toString();
+ if (loc.isEmpty())
+ loc = QLocale::system().name();
+ QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt");
+ // if file is non-existant try with language only
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt");
+
+ // fallback if file for current locale is non-existant
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_en.txt");
+
+ QSettings m_info(campaignDescFile, QSettings::IniFormat, 0);
+ m_info.setIniCodec("UTF-8");
+
+ if(progress>=0 and unlockedMissions==0)
+ {
+ for(unsigned int i=progress+1;i>0;i--)
+ {
+ //update descruiptions here
+ imageList += campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
+ }
+ }
+ else if(unlockedMissions>0)
+ {
+ qDebug("IN HERE !!!");
+ for(unsigned int i=1;i<=unlockedMissions;i++)
+ {
+ QString missionNum = QString("%1").arg(i);
+ imageList += campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
+ }
+ }
+ return imageList;
+}
+
unsigned int getCampProgress(QString & teamName, QString & campName)
{
QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
--- a/QTfrontend/campaign.h Fri Jun 28 19:05:41 2013 +0300
+++ b/QTfrontend/campaign.h Fri Jun 28 19:32:11 2013 +0300
@@ -30,5 +30,6 @@
QMap<QString,QString> getUnlockedMissions2(QString & campaignName, QString & teamName);
QStringList getCampMissionList2(QString & campaignName, QString & teamName);
QStringList getDescriptions(QString & campaignName, QString & teamName);
+QStringList getImages(QString & campaignName, QString & teamName);
#endif
--- a/QTfrontend/hwform.cpp Fri Jun 28 19:05:41 2013 +0300
+++ b/QTfrontend/hwform.cpp Fri Jun 28 19:32:11 2013 +0300
@@ -1892,7 +1892,6 @@
}
}
-
void HWForm::UpdateCampaignPage(int index)
{
qDebug("UpdateCampaignPage");
@@ -1909,8 +1908,10 @@
// this will be used later in UpdateCampaignPageMission() to update
// the mission description in the campaign page
campaignMissionDescriptions.clear();
+ campaignMissionImages.clear();
ui.pageCampaign->CBMission->clear();
campaignMissionDescriptions = getDescriptions(campaignName,tName);
+ campaignMissionImages = getImages(campaignName,tName);
for(int i=0;i<missionEntries.size();i++)
{
ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(missionEntries.size()-i) + QString(missionEntries[i]), QString(missionEntries[i]));
@@ -1922,9 +1923,6 @@
qDebug("UpdateCampaignPageMission");
// update thumbnail
QString campaignName = ui.pageCampaign->CBCampaign->currentText();
- unsigned int mNum = ui.pageCampaign->CBMission->count() - ui.pageCampaign->CBMission->currentIndex();
- QString image = getCampaignImage(campaignName,mNum);
- ui.pageCampaign->btnPreview->setIcon(QIcon((":/res/campaign/"+campaignName+"/"+image)));
// update description
// when campaign changes the UpdateCampaignPageMission is triggered with wrong values
// this will cause segfault. This check prevents illegal memory reads
@@ -1933,6 +1931,7 @@
qDebug("INSIDE IF *******");
ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
ui.pageCampaign->lbldescription->setText(campaignMissionDescriptions[index]);
+ ui.pageCampaign->btnPreview->setIcon(QIcon((":/res/campaign/"+campaignName+"/"+campaignMissionImages[index])));
}
}
--- a/QTfrontend/hwform.h Fri Jun 28 19:05:41 2013 +0300
+++ b/QTfrontend/hwform.h Fri Jun 28 19:32:11 2013 +0300
@@ -197,11 +197,11 @@
QString previousCampaignName;
QString previousTeamName;
QStringList campaignMissionDescriptions;
+ QStringList campaignMissionImages;
QTime eggTimer;
BGWidget * wBackground;
QSignalMapper * pageSwitchMapper;
QByteArray m_lastDemo;
- QMap<QString,QString> unlockedMissionsHash;
QPropertyAnimation *animationNewSlide;
QPropertyAnimation *animationOldSlide;