mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
add setting to controll game assets download (#5355)
This commit is contained in:
commit
5d8cdb429b
5 changed files with 66 additions and 37 deletions
|
|
@ -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", "");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -251,12 +251,12 @@
|
|||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelJavaDir">
|
||||
<property name="text">
|
||||
<string>&Auto Java Download:</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Folder where Prism Launcher stores automatically downloaded Java versions. Do NOT set this to your system Java installation.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Auto Java Download:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>javaDirTextBox</cstring>
|
||||
</property>
|
||||
|
|
@ -444,6 +444,25 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="instanceBox">
|
||||
<property name="title">
|
||||
<string>Instance Creation</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="downloadGameFilesBtn">
|
||||
<property name="toolTip">
|
||||
<string>Downloads required game files while creating the instance. Disable this to skip the initial download and fetch files when the instance is launched instead.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Download game files during instance creation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue