QTfrontend/campaign.cpp
branchspacecampaign
changeset 9294 f9b31c3efd35
parent 9292 187ce630dddc
child 9308 4bddcc1a1450
equal deleted inserted replaced
9292:187ce630dddc 9294:f9b31c3efd35
    22 #include <QSettings>
    22 #include <QSettings>
    23 #include <QObject>
    23 #include <QObject>
    24 #include <QLocale>
    24 #include <QLocale>
    25 
    25 
    26 QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
    26 QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
    27 {    
    27 {
    28 	// TODO: add default image if there isn't an available one
       
    29     QList<MissionInfo> missionInfoList;
    28     QList<MissionInfo> missionInfoList;
    30 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
    29 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
    31     teamfile.setIniCodec("UTF-8");
    30     teamfile.setIniCodec("UTF-8");
    32     unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
    31     unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
    33     unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
    32     unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
    61 			MissionInfo missionInfo;
    60 			MissionInfo missionInfo;
    62 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(i)).toString();
    61 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(i)).toString();
    63             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(i)).toString();
    62             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(i)).toString();
    64 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    63 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    65                                             QObject::tr("No description available")).toString();
    64                                             QObject::tr("No description available")).toString();
    66             missionInfo.image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
    65             QString image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
       
    66             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
       
    67             if (!QFile::exists(missionInfo.image))
       
    68 				missionInfo.image = ":/res/CampaignDefault.png";
    67 			missionInfoList.append(missionInfo);
    69 			missionInfoList.append(missionInfo);
    68 		}
    70 		}
    69 	} 
    71 	} 
    70 	else if(unlockedMissions>0)
    72 	else if(unlockedMissions>0)
    71 	{
    73 	{
    76 			MissionInfo missionInfo;
    78 			MissionInfo missionInfo;
    77 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString();
    79 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString();
    78             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
    80             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
    79 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    81 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    80                                             QObject::tr("No description available")).toString();
    82                                             QObject::tr("No description available")).toString();
    81             missionInfo.image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
    83             QString image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
       
    84             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
       
    85             if (!QFile::exists(missionInfo.image))
       
    86 				missionInfo.image = ":/res/CampaignDefault.png";
    82 			missionInfoList.append(missionInfo);
    87 			missionInfoList.append(missionInfo);
    83 		}
    88 		}
    84 	}
    89 	}
    85 	return missionInfoList;
    90 	return missionInfoList;
    86 }
    91 }