382 teamslist = config->GetTeamsList(); |
382 teamslist = config->GetTeamsList(); |
383 } |
383 } |
384 |
384 |
385 if(teamslist.empty()) { |
385 if(teamslist.empty()) { |
386 HWTeam defaultTeam(tr("DefaultTeam")); |
386 HWTeam defaultTeam(tr("DefaultTeam")); |
387 defaultTeam.SaveToFile(); |
387 defaultTeam.saveToFile(); |
388 teamslist.push_back(tr("DefaultTeam")); |
388 teamslist.push_back(tr("DefaultTeam")); |
389 } |
389 } |
390 |
390 |
391 ui.pageOptions->CBTeamName->clear(); |
391 ui.pageOptions->CBTeamName->clear(); |
392 ui.pageOptions->CBTeamName->addItems(teamslist); |
392 ui.pageOptions->CBTeamName->addItems(teamslist); |
630 } |
630 } |
631 |
631 |
632 void HWForm::EditTeam() |
632 void HWForm::EditTeam() |
633 { |
633 { |
634 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
634 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
635 editedTeam->LoadFromFile(); |
635 editedTeam->loadFromFile(); |
636 editedTeam->SetToPage(this); |
636 editedTeam->SetToPage(this); |
637 GoToPage(ID_PAGE_SETUP_TEAM); |
637 GoToPage(ID_PAGE_SETUP_TEAM); |
638 } |
638 } |
639 |
639 |
640 void HWForm::DeleteTeam() |
640 void HWForm::DeleteTeam() |
641 { |
641 { |
642 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); |
642 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); |
643 |
643 |
644 if (reallyDelete.exec() == QMessageBox::Ok) { |
644 if (reallyDelete.exec() == QMessageBox::Ok) { |
645 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
645 editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
646 editedTeam->DeleteFile(); |
646 editedTeam->deleteFile(); |
647 |
647 |
648 // Remove from lists |
648 // Remove from lists |
649 ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex()); |
649 ui.pageOptions->CBTeamName->removeItem(ui.pageOptions->CBTeamName->currentIndex()); |
650 } |
650 } |
651 } |
651 } |
652 |
652 |
653 void HWForm::RandomNames() |
653 void HWForm::RandomNames() |
654 { |
654 { |
655 editedTeam->GetFromPage(this); |
655 editedTeam->GetFromPage(this); |
656 namegen->TeamRandomNames(editedTeam, true); |
656 namegen->teamRandomNames(*editedTeam, true); |
657 editedTeam->SetToPage(this); |
657 editedTeam->SetToPage(this); |
658 } |
658 } |
659 |
659 |
660 void HWForm::RandomName(const int &i) |
660 void HWForm::RandomName(const int &i) |
661 { |
661 { |
662 editedTeam->GetFromPage(this); |
662 editedTeam->GetFromPage(this); |
663 namegen->TeamRandomName(editedTeam,i); |
663 namegen->teamRandomName(*editedTeam,i); |
664 editedTeam->SetToPage(this); |
664 editedTeam->SetToPage(this); |
665 } |
665 } |
666 |
666 |
667 void HWForm::TeamSave() |
667 void HWForm::TeamSave() |
668 { |
668 { |
669 editedTeam->GetFromPage(this); |
669 editedTeam->GetFromPage(this); |
670 editedTeam->SaveToFile(); |
670 editedTeam->saveToFile(); |
671 delete editedTeam; |
671 delete editedTeam; |
672 editedTeam=0; |
672 editedTeam=0; |
673 UpdateTeamsLists(); |
673 UpdateTeamsLists(); |
674 GoBack(); |
674 GoBack(); |
675 } |
675 } |
1313 tmpdir.cd(cfgdir->absolutePath()); |
1313 tmpdir.cd(cfgdir->absolutePath()); |
1314 tmpdir.cd("Data/Missions/Campaign"); |
1314 tmpdir.cd("Data/Missions/Campaign"); |
1315 tmpdir.setFilter(QDir::Files); |
1315 tmpdir.setFilter(QDir::Files); |
1316 QStringList userentries = tmpdir.entryList(QStringList("*#*.lua")); |
1316 QStringList userentries = tmpdir.entryList(QStringList("*#*.lua")); |
1317 //entries.sort(); |
1317 //entries.sort(); |
1318 for(int i = 0; (i < userentries.count()) && (i <= team.CampaignProgress); i++) |
1318 unsigned int n = userentries.count(); |
|
1319 for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) |
1319 ui.pageCampaign->CBSelect->addItem(QString(userentries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(userentries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1320 ui.pageCampaign->CBSelect->addItem(QString(userentries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(userentries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1320 |
1321 |
1321 tmpdir.cd(datadir->absolutePath()); |
1322 tmpdir.cd(datadir->absolutePath()); |
1322 tmpdir.cd("Missions/Campaign"); |
1323 tmpdir.cd("Missions/Campaign"); |
1323 tmpdir.setFilter(QDir::Files); |
1324 tmpdir.setFilter(QDir::Files); |
1324 QStringList entries = tmpdir.entryList(QStringList("*#*.lua")); |
1325 QStringList entries = tmpdir.entryList(QStringList("*#*.lua")); |
1325 //entries.sort(); |
1326 //entries.sort(); |
1326 for(int i = 0; (i < entries.count()) && (i <= team.CampaignProgress); i++) { |
1327 n = entries.count(); |
|
1328 for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) { |
1327 if (userentries.contains(entries[i])) continue; |
1329 if (userentries.contains(entries[i])) continue; |
1328 ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1330 ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); |
1329 } |
1331 } |
1330 } |
1332 } |
1331 |
1333 |