diff --git a/launcher/Application.cpp b/launcher/Application.cpp index df849f7ca..ff4013b1c 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -779,6 +779,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting("ModDependenciesDisabled", false); m_settings->registerSetting("SkipModpackUpdatePrompt", false); m_settings->registerSetting("ShowModIncompat", false); + m_settings->registerSetting("DownloadGameFilesDuringInstanceCreation", true); // Minecraft offline player name m_settings->registerSetting("LastOfflinePlayerName", ""); diff --git a/launcher/InstanceCreationTask.cpp b/launcher/InstanceCreationTask.cpp index 7e74a9336..e58926660 100644 --- a/launcher/InstanceCreationTask.cpp +++ b/launcher/InstanceCreationTask.cpp @@ -3,6 +3,7 @@ #include #include +#include "Application.h" #include "InstanceTask.h" #include "minecraft/MinecraftLoadAndCheck.h" #include "tasks/SequentialTask.h" @@ -38,8 +39,9 @@ void InstanceCreationTask::executeTask() m_instance = createInstance(); if (!m_instance) { - if (m_abort) + if (m_abort) { return; + } qWarning() << "Instance creation failed!"; if (!m_error_message.isEmpty()) { @@ -63,8 +65,9 @@ void InstanceCreationTask::executeTask() qDebug() << "Removing old files"; for (const QString& path : m_filesToRemove) { - if (!QFile::exists(path)) + if (!QFile::exists(path)) { continue; + } qDebug() << "Removing" << path; @@ -81,6 +84,10 @@ void InstanceCreationTask::executeTask() } if (!m_abort) { + if (!APPLICATION->settings()->get("DownloadGameFilesDuringInstanceCreation").toBool()) { + emitSucceeded(); + return; + } setAbortable(true); setAbortButtonText(tr("Skip")); qDebug() << "Downloading game files"; @@ -110,7 +117,7 @@ void InstanceCreationTask::executeTask() } } -void InstanceCreationTask::scheduleToDelete(QWidget* parent, QDir dir, QString path, bool checkDisabled) +void InstanceCreationTask::scheduleToDelete(QWidget* parent, const QDir& dir, const QString& path, bool checkDisabled) { if (path.isEmpty()) { return; diff --git a/launcher/InstanceCreationTask.h b/launcher/InstanceCreationTask.h index 416cf81db..39acaf8b2 100644 --- a/launcher/InstanceCreationTask.h +++ b/launcher/InstanceCreationTask.h @@ -38,7 +38,7 @@ class InstanceCreationTask : public InstanceTask { protected: void setError(const QString& message) { m_error_message = message; }; - void scheduleToDelete(QWidget* parent, QDir dir, QString path, bool checkDisabled = false); + void scheduleToDelete(QWidget* parent, const QDir& dir, const QString& path, bool checkDisabled = false); protected: bool m_abort = false; diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index d6d15a2c4..6276d3be6 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -90,12 +90,12 @@ bool LauncherPage::apply() void LauncherPage::on_instDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"), ui->instDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - if (FS::checkProblemticPathJava(QDir(cooked_dir))) { + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + if (FS::checkProblemticPathJava(QDir(cookedDir))) { QMessageBox warning; warning.setText( tr("You're trying to specify an instance folder which\'s path " @@ -108,9 +108,9 @@ void LauncherPage::on_instDirBrowseBtn_clicked() warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int result = warning.exec(); if (result == QMessageBox::Ok) { - ui->instDirTextBox->setText(cooked_dir); + ui->instDirTextBox->setText(cookedDir); } - } else if (DesktopServices::isFlatpak() && raw_dir.startsWith("/run/user")) { + } else if (DesktopServices::isFlatpak() && rawDir.startsWith("/run/user")) { QMessageBox warning; warning.setText(tr("You're trying to specify an instance folder " "which was granted temporarily via Flatpak.\n" @@ -123,64 +123,64 @@ void LauncherPage::on_instDirBrowseBtn_clicked() warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int result = warning.exec(); if (result == QMessageBox::Ok) { - ui->instDirTextBox->setText(cooked_dir); + ui->instDirTextBox->setText(cookedDir); } } else { - ui->instDirTextBox->setText(cooked_dir); + ui->instDirTextBox->setText(cookedDir); } } } void LauncherPage::on_iconsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"), ui->iconsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - ui->iconsDirTextBox->setText(cooked_dir); + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + ui->iconsDirTextBox->setText(cookedDir); } } void LauncherPage::on_modsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - ui->modsDirTextBox->setText(cooked_dir); + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + ui->modsDirTextBox->setText(cookedDir); } } void LauncherPage::on_downloadsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Downloads Folder"), ui->downloadsDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Downloads Folder"), ui->downloadsDirTextBox->text()); - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - ui->downloadsDirTextBox->setText(cooked_dir); + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + ui->downloadsDirTextBox->setText(cookedDir); } } void LauncherPage::on_javaDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Java Folder"), ui->javaDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Java Folder"), ui->javaDirTextBox->text()); - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - ui->javaDirTextBox->setText(cooked_dir); + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + ui->javaDirTextBox->setText(cookedDir); } } void LauncherPage::on_skinsDirBrowseBtn_clicked() { - QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Skins Folder"), ui->skinsDirTextBox->text()); + QString rawDir = QFileDialog::getExistingDirectory(this, tr("Skins Folder"), ui->skinsDirTextBox->text()); // do not allow current dir - it's dirty. Do not allow dirs that don't exist - if (!raw_dir.isEmpty() && QDir(raw_dir).exists()) { - QString cooked_dir = FS::NormalizePath(raw_dir); - ui->skinsDirTextBox->setText(cooked_dir); + if (!rawDir.isEmpty() && QDir(rawDir).exists()) { + QString cookedDir = FS::NormalizePath(rawDir); + ui->skinsDirTextBox->setText(cookedDir); } } @@ -191,7 +191,7 @@ void LauncherPage::on_metadataEnableBtn_clicked() void LauncherPage::applySettings() { - auto s = APPLICATION->settings(); + auto* s = APPLICATION->settings(); // Updates if (APPLICATION->updater()) { @@ -246,10 +246,11 @@ void LauncherPage::applySettings() s->set("ModDependenciesDisabled", !ui->dependenciesEnableBtn->isChecked()); s->set("ShowModIncompat", ui->showModIncompatCheckBox->isChecked()); s->set("SkipModpackUpdatePrompt", !ui->modpackUpdatePromptBtn->isChecked()); + s->set("DownloadGameFilesDuringInstanceCreation", ui->downloadGameFilesBtn->isChecked()); } void LauncherPage::loadSettings() { - auto s = APPLICATION->settings(); + auto* s = APPLICATION->settings(); // Updates if (APPLICATION->updater()) { ui->autoUpdateCheckBox->setChecked(APPLICATION->updater()->getAutomaticallyChecksForUpdates()); @@ -296,6 +297,7 @@ void LauncherPage::loadSettings() ui->dependenciesEnableBtn->setChecked(!s->get("ModDependenciesDisabled").toBool()); ui->showModIncompatCheckBox->setChecked(s->get("ShowModIncompat").toBool()); ui->modpackUpdatePromptBtn->setChecked(!s->get("SkipModpackUpdatePrompt").toBool()); + ui->downloadGameFilesBtn->setChecked(s->get("DownloadGameFilesDuringInstanceCreation").toBool()); } void LauncherPage::retranslate() diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index f5cfacf96..252f54b17 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -251,12 +251,12 @@ - - &Auto Java Download: - Folder where Prism Launcher stores automatically downloaded Java versions. Do NOT set this to your system Java installation. + + &Auto Java Download: + javaDirTextBox @@ -444,6 +444,25 @@ + + + + Instance Creation + + + + + + Downloads required game files while creating the instance. Disable this to skip the initial download and fetch files when the instance is launched instead. + + + Download game files during instance creation + + + + + +