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