added deafult image if not one available in campaign spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Mon, 01 Jul 2013 18:03:06 +0300
branchspacecampaign
changeset 9294 f9b31c3efd35
parent 9292 187ce630dddc
child 9296 5cc010e79431
added deafult image if not one available in campaign
QTfrontend/campaign.cpp
QTfrontend/hedgewars.qrc
QTfrontend/hwform.cpp
--- a/QTfrontend/campaign.cpp	Fri Jun 28 22:38:08 2013 +0300
+++ b/QTfrontend/campaign.cpp	Mon Jul 01 18:03:06 2013 +0300
@@ -24,8 +24,7 @@
 #include <QLocale>
 
 QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
-{    
-	// TODO: add default image if there isn't an available one
+{
     QList<MissionInfo> missionInfoList;
 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
     teamfile.setIniCodec("UTF-8");
@@ -63,7 +62,10 @@
             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(i)).toString();
 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
                                             QObject::tr("No description available")).toString();
-            missionInfo.image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
+            QString image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
+            missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
+            if (!QFile::exists(missionInfo.image))
+				missionInfo.image = ":/res/CampaignDefault.png";
 			missionInfoList.append(missionInfo);
 		}
 	} 
@@ -78,7 +80,10 @@
             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
                                             QObject::tr("No description available")).toString();
-            missionInfo.image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
+            QString image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
+            missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
+            if (!QFile::exists(missionInfo.image))
+				missionInfo.image = ":/res/CampaignDefault.png";
 			missionInfoList.append(missionInfo);
 		}
 	}
--- a/QTfrontend/hedgewars.qrc	Fri Jun 28 22:38:08 2013 +0300
+++ b/QTfrontend/hedgewars.qrc	Mon Jul 01 18:03:06 2013 +0300
@@ -45,6 +45,7 @@
         <file>res/About.png</file>
         <file>res/SimpleGame.png</file>
         <file>res/Campaign.png</file>
+        <file>res/CampaignDefault.png</file>
         <file>res/Multiplayer.png</file>
         <file>res/Trainings.png</file>
         <file>res/Background.png</file>
--- a/QTfrontend/hwform.cpp	Fri Jun 28 22:38:08 2013 +0300
+++ b/QTfrontend/hwform.cpp	Mon Jul 01 18:03:06 2013 +0300
@@ -1917,7 +1917,7 @@
     if(index > -1 && index < campaignMissionInfo.count()) {
         ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
         ui.pageCampaign->lbldescription->setText(campaignMissionInfo[index].description);
-		ui.pageCampaign->btnPreview->setIcon(QIcon((":/res/campaign/"+campaignName+"/"+campaignMissionInfo[index].image)));
+		ui.pageCampaign->btnPreview->setIcon(QIcon(campaignMissionInfo[index].image));
     }
 }