QTfrontend/hwform.cpp
changeset 14483 4c743ef80b1b
parent 13867 d8e606cf8ff5
child 14488 4edcb655dc5a
equal deleted inserted replaced
14482:9844450389a4 14483:4c743ef80b1b
    55 #endif
    55 #endif
    56 
    56 
    57 #include "hwform.h"
    57 #include "hwform.h"
    58 #include "game.h"
    58 #include "game.h"
    59 #include "team.h"
    59 #include "team.h"
       
    60 #include "mission.h"
    60 #include "campaign.h"
    61 #include "campaign.h"
    61 #include "teamselect.h"
    62 #include "teamselect.h"
    62 #include "selectWeapon.h"
    63 #include "selectWeapon.h"
    63 #include "gameuiconfig.h"
    64 #include "gameuiconfig.h"
    64 #include "pageinfo.h"
    65 #include "pageinfo.h"
   328     connect(ui.pageCampaign->btnPreview, SIGNAL(clicked()), this, SLOT(StartCampaign()));
   329     connect(ui.pageCampaign->btnPreview, SIGNAL(clicked()), this, SLOT(StartCampaign()));
   329     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   330     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   330     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPageTeam(int)));
   331     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPageTeam(int)));
   331     connect(ui.pageCampaign->CBCampaign, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   332     connect(ui.pageCampaign->CBCampaign, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   332     connect(ui.pageCampaign->CBMission, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPageMission(int)));
   333     connect(ui.pageCampaign->CBMission, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPageMission(int)));
       
   334     connect(ui.pageTraining->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateTrainingPageTeam(int)));
   333 
   335 
   334     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted(QString)),
   336     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted(QString)),
   335              this, SLOT(DeleteWeapons(QString)));
   337              this, SLOT(DeleteWeapons(QString)));
   336     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsAdded(QString, QString)),
   338     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsAdded(QString, QString)),
   337              this, SLOT(AddWeapons(QString, QString)));
   339              this, SLOT(AddWeapons(QString, QString)));
   570     }
   572     }
   571 
   573 
   572     ui.pageOptions->CBTeamName->clear();
   574     ui.pageOptions->CBTeamName->clear();
   573     ui.pageOptions->CBTeamName->addItems(teamslist);
   575     ui.pageOptions->CBTeamName->addItems(teamslist);
   574     ui.pageCampaign->CBTeam->clear();
   576     ui.pageCampaign->CBTeam->clear();
   575     /* Only show human teams in campaign page */
   577     ui.pageTraining->CBTeam->clear();
       
   578     /* Only show human teams in campaign/training page */
   576     for(int i=0; i<teamslist.length(); i++)
   579     for(int i=0; i<teamslist.length(); i++)
   577     {
   580     {
   578         HWTeam testTeam = HWTeam(teamslist[i]);
   581         HWTeam testTeam = HWTeam(teamslist[i]);
   579         testTeam.loadFromFile();
   582         testTeam.loadFromFile();
   580         if(testTeam.difficulty() == 0)
   583         if(testTeam.difficulty() == 0)
   581         {
   584         {
   582             ui.pageCampaign->CBTeam->addItem(teamslist[i]);
   585             ui.pageCampaign->CBTeam->addItem(teamslist[i]);
   583         }
   586             ui.pageTraining->CBTeam->addItem(teamslist[i]);
   584     }
   587         }
       
   588     }
       
   589     UpdateTrainingPageTeam(0);
   585 }
   590 }
   586 
   591 
   587 void HWForm::GoToNewWeapons()
   592 void HWForm::GoToNewWeapons()
   588 {
   593 {
   589     ui.pageSelectWeapon->pWeapons->newWeaponsName();
   594     ui.pageSelectWeapon->pWeapons->newWeaponsName();
  1840 
  1845 
  1841 void HWForm::startTraining(const QString & scriptName, const QString & subFolder)
  1846 void HWForm::startTraining(const QString & scriptName, const QString & subFolder)
  1842 {
  1847 {
  1843     CreateGame(0, 0, 0);
  1848     CreateGame(0, 0, 0);
  1844 
  1849 
  1845     game->StartTraining(scriptName, subFolder);
  1850     QString trainTeam = ui.pageTraining->CBTeam->currentText();
       
  1851     game->StartTraining(scriptName, subFolder, trainTeam);
  1846 }
  1852 }
  1847 
  1853 
  1848 void HWForm::StartCampaign()
  1854 void HWForm::StartCampaign()
  1849 {
  1855 {
  1850     CreateGame(0, 0, 0);
  1856     CreateGame(0, 0, 0);
  1995         wBackground->setFixedSize(w, h);
  2001         wBackground->setFixedSize(w, h);
  1996         wBackground->move(0, 0);
  2002         wBackground->move(0, 0);
  1997     }
  2003     }
  1998 }
  2004 }
  1999 
  2005 
       
  2006 void HWForm::UpdateTrainingPageTeam(int index)
       
  2007 {
       
  2008     Q_UNUSED(index);
       
  2009     HWTeam team(ui.pageTraining->CBTeam->currentText());
       
  2010     QString tName = team.name();
       
  2011 
       
  2012     QListWidget* listWidget;
       
  2013     for(int w = 0; w < 3; w++)
       
  2014     {
       
  2015         switch(w) {
       
  2016             case 0: listWidget = ui.pageTraining->lstTrainings; break;
       
  2017             case 1: listWidget = ui.pageTraining->lstChallenges; break;
       
  2018             case 2: listWidget = ui.pageTraining->lstScenarios; break;
       
  2019             default: listWidget = ui.pageTraining->lstTrainings; break;
       
  2020         }
       
  2021         unsigned int n = listWidget->count();
       
  2022 
       
  2023         for(unsigned int i = 0; i < n; i++)
       
  2024         {
       
  2025             QListWidgetItem* item = listWidget->takeItem(i);
       
  2026             QString missionName = QString(item->data(Qt::UserRole).toString()).replace(QString(" "),QString("_"));
       
  2027             if(isMissionWon(missionName, tName))
       
  2028                 item->setIcon(finishedIcon);
       
  2029             else
       
  2030                 item->setIcon(notFinishedIcon);
       
  2031             listWidget->insertItem(i, item);
       
  2032         }
       
  2033     }
       
  2034 }
       
  2035 
  2000 void HWForm::InitCampaignPage()
  2036 void HWForm::InitCampaignPage()
  2001 {
  2037 {
  2002     ui.pageCampaign->CBCampaign->clear();
  2038     ui.pageCampaign->CBCampaign->clear();
  2003     HWTeam team(ui.pageCampaign->CBTeam->currentText());
  2039     HWTeam team(ui.pageCampaign->CBTeam->currentText());
  2004 
  2040 
  2029     ui.pageCampaign->CBMission->clear();
  2065     ui.pageCampaign->CBMission->clear();
  2030 
  2066 
  2031     for(int i=0;i<campaignMissionInfo.size();i++)
  2067     for(int i=0;i<campaignMissionInfo.size();i++)
  2032     {
  2068     {
  2033         ui.pageCampaign->CBMission->addItem(QString(campaignMissionInfo[i].realName), QString(campaignMissionInfo[i].name));
  2069         ui.pageCampaign->CBMission->addItem(QString(campaignMissionInfo[i].realName), QString(campaignMissionInfo[i].name));
  2034         if(isMissionWon(campaignName, i, tName))
  2070         if(isCampMissionWon(campaignName, i, tName))
  2035             ui.pageCampaign->CBMission->setItemIcon(i, finishedIcon);
  2071             ui.pageCampaign->CBMission->setItemIcon(i, finishedIcon);
  2036         else
  2072         else
  2037             ui.pageCampaign->CBMission->setItemIcon(i, notFinishedIcon);
  2073             ui.pageCampaign->CBMission->setItemIcon(i, notFinishedIcon);
  2038     }
  2074     }
  2039 }
  2075 }
  2233 
  2269 
  2234     CreateGame(lastGameCfg, lastGameTeamSel, lastGameAmmo);
  2270     CreateGame(lastGameCfg, lastGameTeamSel, lastGameAmmo);
  2235 
  2271 
  2236     switch(lastGameType) {
  2272     switch(lastGameType) {
  2237     case gtTraining:
  2273     case gtTraining:
  2238         game->StartTraining(lastGameStartArgs.at(0).toString(), lastTrainingSubFolder);
  2274         game->StartTraining(lastGameStartArgs.at(0).toString(), lastGameStartArgs.at(1).toString(), lastGameStartArgs.at(2).toString());
  2239         break;
  2275         break;
  2240     case gtQLocal:
  2276     case gtQLocal:
  2241         game->StartQuick();
  2277         game->StartQuick();
  2242         break;
  2278         break;
  2243     case gtCampaign:
  2279     case gtCampaign: