QTfrontend/hwform.cpp
changeset 7201 dc17ffdf0702
parent 7122 fa2d09868ac6
child 7207 b216efbc00ff
equal deleted inserted replaced
7199:f329fbf1ffb4 7201:dc17ffdf0702
    49 #endif
    49 #endif
    50 
    50 
    51 #include "hwform.h"
    51 #include "hwform.h"
    52 #include "game.h"
    52 #include "game.h"
    53 #include "team.h"
    53 #include "team.h"
       
    54 #include "campaign.h"
    54 #include "teamselect.h"
    55 #include "teamselect.h"
    55 #include "selectWeapon.h"
    56 #include "selectWeapon.h"
    56 #include "gameuiconfig.h"
    57 #include "gameuiconfig.h"
    57 #include "pageinfo.h"
    58 #include "pageinfo.h"
    58 #include "pagetraining.h"
    59 #include "pagetraining.h"
   160     QShortcut * updateData = new QShortcut(QKeySequence("F5"), this);
   161     QShortcut * updateData = new QShortcut(QKeySequence("F5"), this);
   161     connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
   162     connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
   162 #endif
   163 #endif
   163 
   164 
   164     UpdateTeamsLists();
   165     UpdateTeamsLists();
       
   166     InitCampaignPage();
   165     UpdateCampaignPage(0);
   167     UpdateCampaignPage(0);
   166     UpdateWeapons();
   168     UpdateWeapons();
   167 
   169 
   168     // connect all goBack signals
   170     // connect all goBack signals
   169     int nPages = ui.Pages->count();
   171     int nPages = ui.Pages->count();
   271 
   273 
   272     connect(ui.pageTraining, SIGNAL(startMission(const QString&)), this, SLOT(startTraining(const QString&)));
   274     connect(ui.pageTraining, SIGNAL(startMission(const QString&)), this, SLOT(startTraining(const QString&)));
   273 
   275 
   274     connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign()));
   276     connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign()));
   275     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   277     connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
       
   278     connect(ui.pageCampaign->CBCampaign, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int)));
   276 
   279 
   277 
   280 
   278     connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()),
   281     connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()),
   279             ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first
   282             ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first
   280     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
   283     connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()),
  1416 
  1419 
  1417 void HWForm::StartCampaign()
  1420 void HWForm::StartCampaign()
  1418 {
  1421 {
  1419     CreateGame(0, 0, 0);
  1422     CreateGame(0, 0, 0);
  1420 
  1423 
  1421     game->StartCampaign(ui.pageCampaign->CBSelect->itemData(ui.pageCampaign->CBSelect->currentIndex()).toString());
  1424     QComboBox *combo = ui.pageCampaign->CBMission;
       
  1425     QString camp = ui.pageCampaign->CBCampaign->currentText();
       
  1426     unsigned int mNum = combo->count() - combo->currentIndex();
       
  1427     QString miss = getCampaignScript(camp, mNum);
       
  1428     QString campTeam = ui.pageCampaign->CBTeam->currentText();
       
  1429 
       
  1430     game->StartCampaign(camp, miss, campTeam);
  1422 }
  1431 }
  1423 
  1432 
  1424 void HWForm::CreateNetGame()
  1433 void HWForm::CreateNetGame()
  1425 {
  1434 {
  1426     QString ammo;
  1435     QString ammo;
  1542         wBackground->setFixedSize(w, h);
  1551         wBackground->setFixedSize(w, h);
  1543         wBackground->move(0, 0);
  1552         wBackground->move(0, 0);
  1544     }
  1553     }
  1545 }
  1554 }
  1546 
  1555 
       
  1556 void HWForm::InitCampaignPage()
       
  1557 {
       
  1558     ui.pageCampaign->CBCampaign->clear();
       
  1559     HWTeam team(ui.pageCampaign->CBTeam->currentText());
       
  1560 
       
  1561     QStringList entries = DataManager::instance().entryList(
       
  1562                                   "Missions/Campaign",
       
  1563                                   QDir::Dirs,
       
  1564                                   QStringList("[^\\.]*")
       
  1565                               );
       
  1566 
       
  1567     unsigned int n = entries.count();
       
  1568     for(unsigned int i = 0; i < n; i++)
       
  1569     {
       
  1570         ui.pageCampaign->CBCampaign->addItem(QString(entries[i]), QString(entries[i]));
       
  1571     }
       
  1572 }
       
  1573 
       
  1574 
  1547 void HWForm::UpdateCampaignPage(int index)
  1575 void HWForm::UpdateCampaignPage(int index)
  1548 {
  1576 {
  1549     Q_UNUSED(index);
  1577     Q_UNUSED(index);
  1550 
  1578 
  1551     HWTeam team(ui.pageCampaign->CBTeam->currentText());
  1579     HWTeam team(ui.pageCampaign->CBTeam->currentText());
  1552     ui.pageCampaign->CBSelect->clear();
  1580     ui.pageCampaign->CBMission->clear();
  1553 
  1581 
  1554     QStringList entries = DataManager::instance().entryList(
  1582     QString campaignName = ui.pageCampaign->CBCampaign->currentText();
  1555                               "Missions/Campaign",
  1583     QStringList missionEntries = getCampMissionList(campaignName);
  1556                               QDir::Files,
  1584     QString tName = team.name();
  1557                               QStringList("*#*.lua")
  1585     unsigned int n = missionEntries.count();
  1558                           );
  1586     unsigned int m = getCampProgress(tName, campaignName);
  1559 
  1587 
  1560     unsigned int n = entries.count();
  1588     for (unsigned int i = min(m + 1, n); i > 0; i--)
  1561     for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++)
  1589     {
  1562     {
  1590         ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1]));
  1563         ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1"));
       
  1564     }
  1591     }
  1565 }
  1592 }
  1566 
  1593 
  1567 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
  1594 // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
  1568 QString HWForm::getDemoArguments()
  1595 QString HWForm::getDemoArguments()