--- a/QTfrontend/campaign.cpp Sat Nov 19 23:04:44 2016 +0100
+++ b/QTfrontend/campaign.cpp Tue May 03 22:26:39 2016 +0200
@@ -23,30 +23,43 @@
#include <QObject>
#include <QLocale>
-QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
+QSettings* getCampTeamFile(QString & campaignName, QString & teamName)
{
- QList<MissionInfo> missionInfoList;
- QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
- teamfile.setIniCodec("UTF-8");
-
+ QSettings* teamfile = new QSettings(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
+ teamfile->setIniCodec("UTF-8");
// if entry not found check if there is written without _
// if then is found rename it to use _
QString spaceCampName = campaignName;
spaceCampName = spaceCampName.replace(QString("_"),QString(" "));
- if (!teamfile.childGroups().contains("Campaign " + campaignName) and
- teamfile.childGroups().contains("Campaign " + spaceCampName)){
- teamfile.beginGroup("Campaign " + spaceCampName);
- QStringList keys = teamfile.childKeys();
- teamfile.endGroup();
+ if (!teamfile->childGroups().contains("Campaign " + campaignName) and
+ teamfile->childGroups().contains("Campaign " + spaceCampName)){
+ teamfile->beginGroup("Campaign " + spaceCampName);
+ QStringList keys = teamfile->childKeys();
+ teamfile->endGroup();
for (int i=0;i<keys.size();i++) {
- QVariant value = teamfile.value("Campaign " + spaceCampName + "/" + keys[i]);
- teamfile.setValue("Campaign " + campaignName + "/" + keys[i], value);
+ QVariant value = teamfile->value("Campaign " + spaceCampName + "/" + keys[i]);
+ teamfile->setValue("Campaign " + campaignName + "/" + keys[i], value);
}
- teamfile.remove("Campaign " + spaceCampName);
+ teamfile->remove("Campaign " + spaceCampName);
}
- int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
- int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
+ return teamfile;
+}
+
+bool isCampWon(QString & campaignName, QString & teamName)
+{
+ QSettings* teamfile = getCampTeamFile(campaignName, teamName);
+ bool won = teamfile->value("Campaign " + campaignName + "/Won", false).toBool();
+ return won;
+}
+
+QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
+{
+ QList<MissionInfo> missionInfoList;
+ QSettings* teamfile = getCampTeamFile(campaignName, teamName);
+
+ int progress = teamfile->value("Campaign " + campaignName + "/Progress", 0).toInt();
+ int unlockedMissions = teamfile->value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
campfile.setIniCodec("UTF-8");
@@ -92,7 +105,7 @@
for(int i=1;i<=unlockedMissions;i++)
{
QString missionNum = QString("%1").arg(i);
- int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt();
+ int missionNumber = teamfile->value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt();
MissionInfo missionInfo;
missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString();
QString script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
--- a/QTfrontend/campaign.h Sat Nov 19 23:04:44 2016 +0100
+++ b/QTfrontend/campaign.h Tue May 03 22:26:39 2016 +0200
@@ -20,6 +20,7 @@
#define CAMPAIGN_H
#include <QString>
+#include <QSettings>
class MissionInfo
{
@@ -30,6 +31,9 @@
QString image;
};
+
+QSettings* getCampTeamFile(QString & campaignName, QString & teamName);
+bool isCampWon(QString & campaignName, QString & teamName);
QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName);
#endif
--- a/QTfrontend/hedgewars.qrc Sat Nov 19 23:04:44 2016 +0100
+++ b/QTfrontend/hedgewars.qrc Tue May 03 22:26:39 2016 +0200
@@ -85,6 +85,8 @@
<file>res/delete.png</file>
<file>res/checked.png</file>
<file>res/unchecked.png</file>
+ <file>res/missionFinished.png</file>
+ <file>res/missionFinishedSelected.png</file>
<file>res/graphicsicon.png</file>
<file>res/miscicon.png</file>
<file>res/Load.png</file>
--- a/QTfrontend/hwform.cpp Sat Nov 19 23:04:44 2016 +0100
+++ b/QTfrontend/hwform.cpp Tue May 03 22:26:39 2016 +0200
@@ -1855,9 +1855,18 @@
);
unsigned int n = entries.count();
+
+ QIcon finishedIcon;
+ finishedIcon.addFile(":/res/missionFinished.png", QSize(), QIcon::Normal, QIcon::On);
+ finishedIcon.addFile(":/res/missionFinishedSelected.png", QSize(), QIcon::Selected, QIcon::On);
for(unsigned int i = 0; i < n; i++)
{
- ui.pageCampaign->CBCampaign->addItem(QString(entries[i]).replace(QString("_"),QString(" ")), QString(entries[i]).replace(QString("_"),QString(" ")));
+ QString campaignNameUnderscores= QString(entries[i]).replace(QString(" "),QString("_"));
+ QString campaignNameSpaces = QString(entries[i]).replace(QString("_"),QString(" "));
+ QString tName = team.name();
+ ui.pageCampaign->CBCampaign->addItem(campaignNameSpaces, campaignNameSpaces);
+ if(isCampWon(campaignNameUnderscores, tName))
+ ui.pageCampaign->CBCampaign->setItemIcon(i, finishedIcon);
}
}
Binary file QTfrontend/res/missionFinished.png has changed
Binary file QTfrontend/res/missionFinishedSelected.png has changed