firstlaunch_moc.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * firstlaunch_moc.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "firstlaunch_moc.h"
  12. #include "ui_firstlaunch_moc.h"
  13. #include "mainwindow_moc.h"
  14. #include "modManager/cmodlistview_moc.h"
  15. #include "../../lib/CConfigHandler.h"
  16. #include "../../lib/texts/CGeneralTextHandler.h"
  17. #include "../../lib/texts/Languages.h"
  18. #include "../../lib/VCMIDirs.h"
  19. #include "../../lib/filesystem/Filesystem.h"
  20. #include "../helper.h"
  21. #include "../languages.h"
  22. #include "../innoextract.h"
  23. #ifdef VCMI_IOS
  24. #include "ios/selectdirectory.h"
  25. #include "iOS_utils.h"
  26. #elif defined(VCMI_ANDROID)
  27. #include <QAndroidJniObject>
  28. #include <QtAndroid>
  29. static FirstLaunchView * thiz;
  30. extern "C" JNIEXPORT void JNICALL Java_eu_vcmi_vcmi_NativeMethods_heroesDataUpdate(JNIEnv * env, jclass cls)
  31. {
  32. thiz->heroesDataUpdate();
  33. }
  34. #endif
  35. FirstLaunchView::FirstLaunchView(QWidget * parent)
  36. : QWidget(parent)
  37. , ui(new Ui::FirstLaunchView)
  38. {
  39. ui->setupUi(this);
  40. enterSetup();
  41. activateTabLanguage();
  42. ui->lineEditDataSystem->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().dataPaths().front())));
  43. ui->lineEditDataUser->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().userDataPath())));
  44. Helper::enableScrollBySwiping(ui->listWidgetLanguage);
  45. #ifdef VCMI_MOBILE
  46. // This directory is not accessible to players without rooting of their device
  47. ui->lineEditDataSystem->hide();
  48. #endif
  49. #ifndef ENABLE_INNOEXTRACT
  50. ui->pushButtonGogInstall->hide();
  51. ui->labelDataGogTitle->hide();
  52. ui->labelDataGogDescr->hide();
  53. #endif
  54. }
  55. void FirstLaunchView::on_buttonTabLanguage_clicked()
  56. {
  57. activateTabLanguage();
  58. }
  59. void FirstLaunchView::on_buttonTabHeroesData_clicked()
  60. {
  61. activateTabHeroesData();
  62. }
  63. void FirstLaunchView::on_buttonTabModPreset_clicked()
  64. {
  65. activateTabModPreset();
  66. }
  67. void FirstLaunchView::on_listWidgetLanguage_currentRowChanged(int currentRow)
  68. {
  69. languageSelected(ui->listWidgetLanguage->item(currentRow)->data(Qt::UserRole).toString());
  70. }
  71. void FirstLaunchView::changeEvent(QEvent * event)
  72. {
  73. if(event->type() == QEvent::LanguageChange)
  74. {
  75. ui->retranslateUi(this);
  76. Languages::fillLanguages(ui->listWidgetLanguage, false);
  77. }
  78. QWidget::changeEvent(event);
  79. }
  80. void FirstLaunchView::on_pushButtonLanguageNext_clicked()
  81. {
  82. activateTabHeroesData();
  83. }
  84. void FirstLaunchView::on_pushButtonDataNext_clicked()
  85. {
  86. activateTabModPreset();
  87. }
  88. void FirstLaunchView::on_pushButtonDataBack_clicked()
  89. {
  90. activateTabLanguage();
  91. }
  92. void FirstLaunchView::on_pushButtonDataSearch_clicked()
  93. {
  94. heroesDataUpdate();
  95. }
  96. void FirstLaunchView::on_pushButtonDataCopy_clicked()
  97. {
  98. #ifdef VCMI_ANDROID
  99. thiz = this;
  100. QtAndroid::androidActivity().callMethod<void>("copyHeroesData");
  101. #else
  102. // iOS can't display modal dialogs when called directly on button press
  103. // https://bugreports.qt.io/browse/QTBUG-98651
  104. QTimer::singleShot(0, this, [this]{ copyHeroesData(); });
  105. #endif
  106. }
  107. void FirstLaunchView::on_pushButtonGogInstall_clicked()
  108. {
  109. // iOS can't display modal dialogs when called directly on button press
  110. // https://bugreports.qt.io/browse/QTBUG-98651
  111. QTimer::singleShot(0, this, &FirstLaunchView::extractGogData);
  112. }
  113. void FirstLaunchView::enterSetup()
  114. {
  115. Languages::fillLanguages(ui->listWidgetLanguage, false);
  116. }
  117. void FirstLaunchView::setSetupProgress(int progress)
  118. {
  119. ui->buttonTabLanguage->setDisabled(progress < 1);
  120. ui->buttonTabHeroesData->setDisabled(progress < 2);
  121. ui->buttonTabModPreset->setDisabled(progress < 3);
  122. }
  123. void FirstLaunchView::activateTabLanguage()
  124. {
  125. setSetupProgress(1);
  126. ui->installerTabs->setCurrentIndex(0);
  127. ui->buttonTabLanguage->setChecked(true);
  128. ui->buttonTabHeroesData->setChecked(false);
  129. ui->buttonTabModPreset->setChecked(false);
  130. }
  131. void FirstLaunchView::activateTabHeroesData()
  132. {
  133. setSetupProgress(2);
  134. ui->installerTabs->setCurrentIndex(1);
  135. ui->buttonTabLanguage->setChecked(false);
  136. ui->buttonTabHeroesData->setChecked(true);
  137. ui->buttonTabModPreset->setChecked(false);
  138. if(heroesDataUpdate())
  139. {
  140. activateTabModPreset();
  141. return;
  142. }
  143. QString installPath = getHeroesInstallDir();
  144. if(!installPath.isEmpty())
  145. {
  146. auto reply = QMessageBox::question(this, tr("Heroes III installation found!"), tr("Copy data to VCMI folder?"), QMessageBox::Yes | QMessageBox::No);
  147. if(reply == QMessageBox::Yes)
  148. copyHeroesData(installPath);
  149. }
  150. }
  151. void FirstLaunchView::activateTabModPreset()
  152. {
  153. setSetupProgress(3);
  154. ui->installerTabs->setCurrentIndex(2);
  155. ui->buttonTabLanguage->setChecked(false);
  156. ui->buttonTabHeroesData->setChecked(false);
  157. ui->buttonTabModPreset->setChecked(true);
  158. modPresetUpdate();
  159. }
  160. void FirstLaunchView::exitSetup()
  161. {
  162. if(auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow()))
  163. mainWindow->exitSetup();
  164. }
  165. // Tab Language
  166. void FirstLaunchView::languageSelected(const QString & selectedLanguage)
  167. {
  168. Settings node = settings.write["general"]["language"];
  169. node->String() = selectedLanguage.toStdString();
  170. if(auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow()))
  171. mainWindow->updateTranslation();
  172. }
  173. bool FirstLaunchView::heroesDataUpdate()
  174. {
  175. bool detected = heroesDataDetect();
  176. if(detected)
  177. heroesDataDetected();
  178. else
  179. heroesDataMissing();
  180. return detected;
  181. }
  182. void FirstLaunchView::heroesDataMissing()
  183. {
  184. QPalette newPalette = palette();
  185. newPalette.setColor(QPalette::Base, QColor(200, 50, 50));
  186. ui->lineEditDataSystem->setPalette(newPalette);
  187. ui->lineEditDataUser->setPalette(newPalette);
  188. ui->labelDataManualTitle->setVisible(true);
  189. ui->labelDataManualDescr->setVisible(true);
  190. ui->pushButtonDataSearch->setVisible(true);
  191. #ifdef VCMI_ANDROID
  192. // selecting directory with ACTION_OPEN_DOCUMENT_TREE is available only since API level 21
  193. const bool canUseDataCopy = QtAndroid::androidSdkVersion() >= 21;
  194. #elif defined(VCMI_IOS)
  195. // selecting directory through UIDocumentPickerViewController is available only since iOS 13
  196. const bool canUseDataCopy = iOS_utils::isOsVersionAtLeast(13);
  197. #else
  198. const bool canUseDataCopy = true;
  199. #endif
  200. ui->labelDataCopyTitle->setVisible(canUseDataCopy);
  201. ui->labelDataCopyDescr->setVisible(canUseDataCopy);
  202. ui->pushButtonDataCopy->setVisible(canUseDataCopy);
  203. #ifdef ENABLE_INNOEXTRACT
  204. ui->pushButtonGogInstall->setVisible(true);
  205. ui->labelDataGogTitle->setVisible(true);
  206. ui->labelDataGogDescr->setVisible(true);
  207. #endif
  208. ui->labelDataFound->setVisible(false);
  209. ui->pushButtonDataNext->setEnabled(false);
  210. }
  211. void FirstLaunchView::heroesDataDetected()
  212. {
  213. QPalette newPalette = palette();
  214. newPalette.setColor(QPalette::Base, QColor(50, 200, 50));
  215. ui->lineEditDataSystem->setPalette(newPalette);
  216. ui->lineEditDataUser->setPalette(newPalette);
  217. ui->pushButtonDataSearch->setVisible(false);
  218. ui->pushButtonDataCopy->setVisible(false);
  219. ui->labelDataManualTitle->setVisible(false);
  220. ui->labelDataManualDescr->setVisible(false);
  221. ui->labelDataCopyTitle->setVisible(false);
  222. ui->labelDataCopyDescr->setVisible(false);
  223. #ifdef ENABLE_INNOEXTRACT
  224. ui->pushButtonGogInstall->setVisible(false);
  225. ui->labelDataGogTitle->setVisible(false);
  226. ui->labelDataGogDescr->setVisible(false);
  227. #endif
  228. ui->labelDataFound->setVisible(true);
  229. ui->pushButtonDataNext->setEnabled(true);
  230. CGeneralTextHandler::detectInstallParameters();
  231. }
  232. // Tab Heroes III Data
  233. bool FirstLaunchView::heroesDataDetect()
  234. {
  235. // user might have copied files to one of our data path.
  236. // perform full reinitialization of virtual filesystem
  237. CResourceHandler::destroy();
  238. CResourceHandler::initialize();
  239. CResourceHandler::load("config/filesystem.json");
  240. // use file from lod archive to check presence of H3 data. Very rough estimate, but will work in majority of cases
  241. bool heroesDataFoundROE = CResourceHandler::get()->existsResource(ResourcePath("DATA/GENRLTXT.TXT"));
  242. bool heroesDataFoundSOD = CResourceHandler::get()->existsResource(ResourcePath("DATA/TENTCOLR.TXT"));
  243. return heroesDataFoundROE && heroesDataFoundSOD;
  244. }
  245. QString FirstLaunchView::getHeroesInstallDir()
  246. {
  247. #ifdef VCMI_WINDOWS
  248. QString gogPath = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\GOG.com\\Games\\1207658787", QSettings::NativeFormat).value("path").toString();
  249. if(!gogPath.isEmpty())
  250. return gogPath;
  251. QString cdPath = QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\New World Computing\\Heroes of Might and Magic® III\\1.0", QSettings::NativeFormat).value("AppPath").toString();
  252. if(!cdPath.isEmpty())
  253. return cdPath;
  254. #endif
  255. return QString{};
  256. }
  257. void FirstLaunchView::extractGogData()
  258. {
  259. #ifdef ENABLE_INNOEXTRACT
  260. auto fileSelection = [this](QByteArray magic, QString filter, QString startPath = {}) {
  261. QString titleSel = tr("Select %1 file...", "param is file extension").arg(filter);
  262. QString titleErr = tr("You have to select %1 file!", "param is file extension").arg(filter);
  263. #if defined(VCMI_MOBILE)
  264. filter = tr("GOG file (*.*)");
  265. QMessageBox::information(this, tr("File selection"), titleSel);
  266. #endif
  267. QString file = QFileDialog::getOpenFileName(this, titleSel, startPath.isEmpty() ? QDir::homePath() : startPath, filter);
  268. if(file.isEmpty())
  269. return QString{};
  270. QFile tmpFile(file);
  271. if(!tmpFile.open(QIODevice::ReadOnly))
  272. {
  273. QMessageBox::critical(this, tr("File cannot opened"), tmpFile.errorString());
  274. return QString{};
  275. }
  276. QByteArray magicFile = tmpFile.read(magic.length());
  277. if(!magicFile.startsWith(magic))
  278. {
  279. QMessageBox::critical(this, tr("Invalid file selected"), titleErr);
  280. return QString{};
  281. }
  282. return file;
  283. };
  284. QString fileBin = fileSelection(QByteArray{"idska32"}, tr("GOG data") + " (*.bin)");
  285. if(fileBin.isEmpty())
  286. return;
  287. QString fileExe = fileSelection(QByteArray{"MZ"}, tr("GOG installer") + " (*.exe)", QFileInfo(fileBin).absolutePath());
  288. if(fileExe.isEmpty())
  289. return;
  290. ui->progressBarGog->setVisible(true);
  291. ui->pushButtonGogInstall->setVisible(false);
  292. setEnabled(false);
  293. QTimer::singleShot(100, this, [this, fileExe, fileBin](){ // background to make sure FileDialog is closed...
  294. QDir tempDir(pathToQString(VCMIDirs::get().userDataPath()));
  295. if(tempDir.cd("tmp"))
  296. {
  297. tempDir.removeRecursively(); // remove if already exists (e.g. previous crash)
  298. tempDir.cdUp();
  299. }
  300. tempDir.mkdir("tmp");
  301. if(!tempDir.cd("tmp"))
  302. return; // should not happen - but avoid deleting wrong folder in any case
  303. QString tmpFileExe = tempDir.filePath("h3_gog.exe");
  304. QFile(fileExe).copy(tmpFileExe);
  305. QFile(fileBin).copy(tempDir.filePath("h3_gog-1.bin"));
  306. QString errorText{};
  307. auto isGogGalaxyExe = [](QString fileToTest) {
  308. QFile file(fileToTest);
  309. quint64 fileSize = file.size();
  310. if(fileSize > 10 * 1024 * 1024)
  311. return false; // avoid to load big files; galaxy exe is smaller...
  312. if(!file.open(QIODevice::ReadOnly))
  313. return false;
  314. QByteArray data = file.readAll();
  315. const QByteArray magicId{reinterpret_cast<const char*>(u"GOG Galaxy"), 20};
  316. return data.contains(magicId);
  317. };
  318. if(isGogGalaxyExe(tmpFileExe))
  319. errorText = tr("You've provided GOG Galaxy installer! This file doesn't contain the game. Please download the offline backup game installer!");
  320. if(errorText.isEmpty())
  321. errorText = Innoextract::extract(tmpFileExe, tempDir.path(), [this](float progress) {
  322. ui->progressBarGog->setValue(progress * 100);
  323. qApp->processEvents();
  324. });
  325. ui->progressBarGog->setVisible(false);
  326. ui->pushButtonGogInstall->setVisible(true);
  327. setEnabled(true);
  328. QStringList dirData = tempDir.entryList({"data"}, QDir::Filter::Dirs);
  329. if(!errorText.isEmpty() || dirData.empty() || QDir(tempDir.filePath(dirData.front())).entryList({"*.lod"}, QDir::Filter::Files).empty())
  330. {
  331. if(!errorText.isEmpty())
  332. QMessageBox::critical(this, tr("Extracting error!"), errorText, QMessageBox::Ok, QMessageBox::Ok);
  333. else
  334. QMessageBox::critical(this, tr("No Heroes III data!"), tr("Selected files do not contain Heroes III data!"), QMessageBox::Ok, QMessageBox::Ok);
  335. tempDir.removeRecursively();
  336. return;
  337. }
  338. copyHeroesData(tempDir.path(), true);
  339. tempDir.removeRecursively();
  340. });
  341. #endif
  342. }
  343. void FirstLaunchView::copyHeroesData(const QString & path, bool move)
  344. {
  345. QDir sourceRoot{path};
  346. #ifdef VCMI_IOS
  347. // TODO: Qt 6.5 can select directories https://codereview.qt-project.org/c/qt/qtbase/+/446449
  348. SelectDirectory iosDirectorySelector;
  349. if(path.isEmpty())
  350. sourceRoot.setPath(iosDirectorySelector.getExistingDirectory());
  351. #else
  352. if(path.isEmpty())
  353. sourceRoot.setPath(QFileDialog::getExistingDirectory(this, {}, {}, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
  354. #endif
  355. if(!sourceRoot.exists())
  356. return;
  357. if (sourceRoot.dirName().compare("data", Qt::CaseInsensitive) == 0)
  358. {
  359. // We got Data folder. Possibly user selected "Data" folder of Heroes III install. Check whether valid data might exist 1 level above
  360. QStringList dirData = sourceRoot.entryList({"data"}, QDir::Filter::Dirs);
  361. if (dirData.empty())
  362. {
  363. // This is "Data" folder without any "Data" folders inside. Try to check for data 1 level above
  364. sourceRoot.cdUp();
  365. }
  366. }
  367. QStringList dirData = sourceRoot.entryList({"data"}, QDir::Filter::Dirs);
  368. QStringList dirMaps = sourceRoot.entryList({"maps"}, QDir::Filter::Dirs);
  369. QStringList dirMp3 = sourceRoot.entryList({"mp3"}, QDir::Filter::Dirs);
  370. const auto noDataMessage = tr("Failed to detect valid Heroes III data in chosen directory.\nPlease select directory with installed Heroes III data.");
  371. if(dirData.empty())
  372. {
  373. QMessageBox::critical(this, tr("Heroes III data not found!"), noDataMessage);
  374. return;
  375. }
  376. QDir sourceData = sourceRoot.filePath(dirData.front());
  377. QStringList roeFiles = sourceData.entryList({"*.lod"}, QDir::Filter::Files);
  378. QStringList sodFiles = sourceData.entryList({"H3ab*.lod"}, QDir::Filter::Files);
  379. QStringList hdFiles = sourceData.entryList({"*.pak"}, QDir::Filter::Files);
  380. if(sodFiles.empty())
  381. {
  382. if (roeFiles.empty())
  383. {
  384. // Directory structure is correct (Data/Maps/Mp3) but no .lod archives that should be present in any install
  385. QMessageBox::critical(this, tr("Heroes III data not found!"), noDataMessage);
  386. return;
  387. }
  388. if (!hdFiles.empty())
  389. {
  390. // HD Edition contains only RoE data so we can't use even unmodified files from it
  391. QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Heroes III: HD Edition files are not supported by VCMI.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death."));
  392. return;
  393. }
  394. // RoE or some other unsupported edition. Demo version?
  395. QMessageBox::critical(this, tr("Heroes III data not found!"), tr("Unknown or unsupported Heroes III version found.\nPlease select directory with Heroes III: Complete Edition or Heroes III: Shadow of Death."));
  396. return;
  397. }
  398. QStringList copyDirectories;
  399. copyDirectories += dirData.front();
  400. if (!dirMaps.empty())
  401. copyDirectories += dirMaps.front();
  402. if (!dirMp3.empty())
  403. copyDirectories += dirMp3.front();
  404. QDir targetRoot = pathToQString(VCMIDirs::get().userDataPath());
  405. for(const QString & dirName : copyDirectories)
  406. {
  407. QDir sourceDir = sourceRoot.filePath(dirName);
  408. QDir targetDir = targetRoot.filePath(dirName);
  409. if(!targetRoot.exists(dirName))
  410. targetRoot.mkdir(dirName);
  411. for(const QString & filename : sourceDir.entryList(QDir::Filter::Files))
  412. {
  413. QFile sourceFile(sourceDir.filePath(filename));
  414. if(move)
  415. sourceFile.rename(targetDir.filePath(filename));
  416. else
  417. sourceFile.copy(targetDir.filePath(filename));
  418. }
  419. }
  420. heroesDataUpdate();
  421. }
  422. // Tab Mod Preset
  423. void FirstLaunchView::modPresetUpdate()
  424. {
  425. bool translationExists = !findTranslationModName().isEmpty();
  426. ui->labelPresetLanguageDescr->setVisible(translationExists);
  427. ui->buttonPresetLanguage->setVisible(translationExists);
  428. ui->buttonPresetLanguage->setVisible(checkCanInstallTranslation());
  429. ui->buttonPresetExtras->setVisible(checkCanInstallExtras());
  430. ui->buttonPresetHota->setVisible(checkCanInstallHota());
  431. ui->buttonPresetWog->setVisible(checkCanInstallWog());
  432. ui->labelPresetLanguageDescr->setVisible(checkCanInstallTranslation());
  433. ui->labelPresetExtrasDescr->setVisible(checkCanInstallExtras());
  434. ui->labelPresetHotaDescr->setVisible(checkCanInstallHota());
  435. ui->labelPresetWogDescr->setVisible(checkCanInstallWog());
  436. // we can't install anything - either repository checkout is off or all recommended mods are already installed
  437. if (!checkCanInstallTranslation() && !checkCanInstallExtras() && !checkCanInstallHota() && !checkCanInstallWog())
  438. exitSetup();
  439. }
  440. QString FirstLaunchView::findTranslationModName()
  441. {
  442. if (!getModView())
  443. return QString();
  444. QString preferredlanguage = QString::fromStdString(settings["general"]["language"].String());
  445. QString installedlanguage = QString::fromStdString(settings["session"]["language"].String());
  446. if (preferredlanguage == installedlanguage)
  447. return QString();
  448. return getModView()->getTranslationModName(preferredlanguage);
  449. }
  450. bool FirstLaunchView::checkCanInstallTranslation()
  451. {
  452. QString modName = findTranslationModName();
  453. if(modName.isEmpty())
  454. return false;
  455. return checkCanInstallMod(modName);
  456. }
  457. bool FirstLaunchView::checkCanInstallWog()
  458. {
  459. return checkCanInstallMod("wake-of-gods");
  460. }
  461. bool FirstLaunchView::checkCanInstallHota()
  462. {
  463. return checkCanInstallMod("hota");
  464. }
  465. bool FirstLaunchView::checkCanInstallExtras()
  466. {
  467. return checkCanInstallMod("vcmi-extras");
  468. }
  469. CModListView * FirstLaunchView::getModView()
  470. {
  471. auto * mainWindow = dynamic_cast<MainWindow *>(QApplication::activeWindow());
  472. assert(mainWindow);
  473. if (!mainWindow)
  474. return nullptr;
  475. return mainWindow->getModView();
  476. }
  477. bool FirstLaunchView::checkCanInstallMod(const QString & modID)
  478. {
  479. return getModView() && getModView()->isModAvailable(modID);
  480. }
  481. void FirstLaunchView::on_pushButtonPresetBack_clicked()
  482. {
  483. activateTabHeroesData();
  484. }
  485. void FirstLaunchView::on_pushButtonPresetNext_clicked()
  486. {
  487. QStringList modsToInstall;
  488. if (ui->buttonPresetLanguage->isChecked() && checkCanInstallTranslation())
  489. modsToInstall.push_back(findTranslationModName());
  490. if (ui->buttonPresetExtras->isChecked() && checkCanInstallExtras())
  491. modsToInstall.push_back("vcmi-extras");
  492. if (ui->buttonPresetWog->isChecked() && checkCanInstallWog())
  493. modsToInstall.push_back("wake-of-gods");
  494. if (ui->buttonPresetHota->isChecked() && checkCanInstallHota())
  495. modsToInstall.push_back("hota");
  496. exitSetup();
  497. for (auto const & modName : modsToInstall)
  498. getModView()->doInstallMod(modName);
  499. }
  500. void FirstLaunchView::on_pushButtonDiscord_clicked()
  501. {
  502. QDesktopServices::openUrl(QUrl("https://discord.gg/chBT42V"));
  503. }
  504. void FirstLaunchView::on_pushButtonGithub_clicked()
  505. {
  506. QDesktopServices::openUrl(QUrl("https://github.com/vcmi/vcmi"));
  507. }