QTfrontend/campaign.cpp
branchspacecampaign
changeset 9308 4bddcc1a1450
parent 9294 f9b31c3efd35
child 9821 7501208fd025
equal deleted inserted replaced
9296:5cc010e79431 9308:4bddcc1a1450
    26 QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
    26 QList<MissionInfo> getCampMissionList(QString & campaignName, QString & teamName)
    27 {
    27 {
    28     QList<MissionInfo> missionInfoList;
    28     QList<MissionInfo> missionInfoList;
    29 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
    29 	QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0);
    30     teamfile.setIniCodec("UTF-8");
    30     teamfile.setIniCodec("UTF-8");
    31     unsigned int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
    31     int progress = teamfile.value("Campaign " + campaignName + "/Progress", 0).toInt();
    32     unsigned int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
    32     int unlockedMissions = teamfile.value("Campaign " + campaignName + "/UnlockedMissions", 0).toInt();
    33     
    33     
    34     QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
    34     QSettings campfile("physfs://Missions/Campaign/" + campaignName + "/campaign.ini", QSettings::IniFormat, 0);
    35     campfile.setIniCodec("UTF-8");
    35     campfile.setIniCodec("UTF-8");
    36     
    36     
    37     DataManager & dataMgr = DataManager::instance();
    37     DataManager & dataMgr = DataManager::instance();
    57     {
    57     {
    58 		for(unsigned int i=progress+1;i>0;i--)
    58 		for(unsigned int i=progress+1;i>0;i--)
    59 		{
    59 		{
    60 			MissionInfo missionInfo;
    60 			MissionInfo missionInfo;
    61 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(i)).toString();
    61 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(i)).toString();
    62             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(i)).toString();
    62 			QString script = campfile.value(QString("Mission %1/Script").arg(i)).toString();
    63 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    63             missionInfo.script = script;
       
    64 			missionInfo.description = m_info.value(campaignName+"-"+ script.replace(QString(".lua"),QString("")) + ".desc",
    64                                             QObject::tr("No description available")).toString();
    65                                             QObject::tr("No description available")).toString();
    65             QString image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
    66             QString image = campfile.value(QString("Mission %1/Script").arg(i)).toString().replace(QString(".lua"),QString(".png"));
    66             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
    67             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
    67             if (!QFile::exists(missionInfo.image))
    68             if (!QFile::exists(missionInfo.image))
    68 				missionInfo.image = ":/res/CampaignDefault.png";
    69 				missionInfo.image = ":/res/CampaignDefault.png";
    69 			missionInfoList.append(missionInfo);
    70 			missionInfoList.append(missionInfo);
    70 		}
    71 		}
    71 	} 
    72 	} 
    72 	else if(unlockedMissions>0)
    73 	else if(unlockedMissions>0)
    73 	{
    74 	{
    74 		for(unsigned int i=1;i<=unlockedMissions;i++)
    75 		for(int i=1;i<=unlockedMissions;i++)
    75 		{
    76 		{
    76 			QString missionNum = QString("%1").arg(i);
    77 			QString missionNum = QString("%1").arg(i);
    77 			int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt();
    78 			int missionNumber = teamfile.value("Campaign " + campaignName + "/Mission"+missionNum, -1).toInt();
    78 			MissionInfo missionInfo;
    79 			MissionInfo missionInfo;
    79 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString();
    80 			missionInfo.name = campfile.value(QString("Mission %1/Name").arg(missionNumber)).toString();
    80             missionInfo.script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
    81 			QString script = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString();
    81 			missionInfo.description = m_info.value(campaignName+"-"+ missionInfo.script.replace(QString(".lua"),QString("")) + ".desc",
    82             missionInfo.script = script;
       
    83 			missionInfo.description = m_info.value(campaignName+"-"+ script.replace(QString(".lua"),QString("")) + ".desc",
    82                                             QObject::tr("No description available")).toString();
    84                                             QObject::tr("No description available")).toString();
    83             QString image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
    85             QString image = campfile.value(QString("Mission %1/Script").arg(missionNumber)).toString().replace(QString(".lua"),QString(".png"));
    84             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
    86             missionInfo.image = ":/res/campaign/"+campaignName+"/"+image;
    85             if (!QFile::exists(missionInfo.image))
    87             if (!QFile::exists(missionInfo.image))
    86 				missionInfo.image = ":/res/CampaignDefault.png";
    88 				missionInfo.image = ":/res/CampaignDefault.png";