From 14b09549e1fc429b87a5c8345ceda069244b6484 Mon Sep 17 00:00:00 2001 From: Rachel Powers <508861+Ryex@users.noreply.github.com> Date: Tue, 25 Jun 2024 01:50:37 -0700 Subject: [PATCH 1/5] feat(instanceList) persist "ungrouped" hidden state Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com> --- launcher/InstanceList.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 0d53c7f25..3f835cfaf 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -710,6 +710,12 @@ void InstanceList::saveGroupList() groupsArr.insert(name, groupObj); } toplevel.insert("groups", groupsArr); + // empty string represents ungrouped "group" + if (m_collapsedGroups.contains("")) { + QJsonObject ungrouped; + ungrouped.insert("hidden", QJsonValue(true)); + toplevel.insert("ungrouped", ungrouped); + } QJsonDocument doc(toplevel); try { FS::write(groupFileName, doc.toJson()); @@ -805,6 +811,16 @@ void InstanceList::loadGroupList() increaseGroupCount(groupName); } } + + bool ungroupedHidden = false; + if (rootObj.value("ungrouped").isObject()) { + QJsonObject ungrouped = rootObj.value("ungrouped").toObject(); + ungroupedHidden = ungrouped.value("hidden").toBool(false); + } + if (ungroupedHidden) { + // empty string represents ungrouped "group" + m_collapsedGroups.insert(""); + } m_groupsLoaded = true; qDebug() << "Group list loaded."; } From 9b172278f8ca81f7dbf3b698dbfbbc37c40f8a81 Mon Sep 17 00:00:00 2001 From: Kationor Date: Wed, 3 Jul 2024 12:39:28 +0200 Subject: [PATCH 2/5] Add ModpackUpdatePromptDisabled setting When creating an instance of a modpack that's already associated with another instance, the user gets asked if they want to update that instance instead. This commit introduces a setting to suppress the prompt and directly create the new instance. Signed-off-by: Kationor --- launcher/Application.cpp | 1 + launcher/InstanceTask.cpp | 5 +++++ launcher/ui/pages/global/LauncherPage.cpp | 2 ++ launcher/ui/pages/global/LauncherPage.ui | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 7ae66e13a..b88b72006 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -662,6 +662,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Minecraft mods m_settings->registerSetting("ModMetadataDisabled", false); m_settings->registerSetting("ModDependenciesDisabled", false); + m_settings->registerSetting("ModpackUpdatePromptDisabled", false); // Minecraft offline player name m_settings->registerSetting("LastOfflinePlayerName", ""); diff --git a/launcher/InstanceTask.cpp b/launcher/InstanceTask.cpp index 53476897c..ffa875119 100644 --- a/launcher/InstanceTask.cpp +++ b/launcher/InstanceTask.cpp @@ -1,5 +1,7 @@ #include "InstanceTask.h" +#include "Application.h" +#include "settings/SettingsObject.h" #include "ui/dialogs/CustomMessageBox.h" #include @@ -22,6 +24,9 @@ InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& ol ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name) { + if (APPLICATION->settings()->get("ModpackUpdatePromptDisabled").toBool()) + return ShouldUpdate::SkipUpdating; + auto info = CustomMessageBox::selectable( parent, QObject::tr("Similar modpack was found!"), QObject::tr( diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 6b32e9849..93ff572c2 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -241,6 +241,7 @@ void LauncherPage::applySettings() // Mods s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked()); s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked()); + s->set("ModpackUpdatePromptDisabled", ui->modpackUpdatePromptDisableBtn->isChecked()); } void LauncherPage::loadSettings() { @@ -303,6 +304,7 @@ void LauncherPage::loadSettings() ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool()); + ui->modpackUpdatePromptDisableBtn->setChecked(s->get("ModpackUpdatePromptDisabled").toBool()); } void LauncherPage::refreshFontPreview() diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 1f49a831f..162b5da45 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -243,6 +243,16 @@ + + + + When creating a new modpack instance, do not suggest updating existing instances. + + + Always create new modpack instance + + + From 83a5fe198413e70d20fa3d08df808b5b3f932bb2 Mon Sep 17 00:00:00 2001 From: Kationor Date: Wed, 3 Jul 2024 23:09:59 +0200 Subject: [PATCH 3/5] Rename setting to SkipModpackUpdatePrompt Was ModpackUpdatePromptDisabled Signed-off-by: Kationor --- launcher/Application.cpp | 2 +- launcher/InstanceTask.cpp | 2 +- launcher/ui/pages/global/LauncherPage.cpp | 4 ++-- launcher/ui/pages/global/LauncherPage.ui | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index b88b72006..06fc68575 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -662,7 +662,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) // Minecraft mods m_settings->registerSetting("ModMetadataDisabled", false); m_settings->registerSetting("ModDependenciesDisabled", false); - m_settings->registerSetting("ModpackUpdatePromptDisabled", false); + m_settings->registerSetting("SkipModpackUpdatePrompt", false); // Minecraft offline player name m_settings->registerSetting("LastOfflinePlayerName", ""); diff --git a/launcher/InstanceTask.cpp b/launcher/InstanceTask.cpp index ffa875119..be10bbe07 100644 --- a/launcher/InstanceTask.cpp +++ b/launcher/InstanceTask.cpp @@ -24,7 +24,7 @@ InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& ol ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name) { - if (APPLICATION->settings()->get("ModpackUpdatePromptDisabled").toBool()) + if (APPLICATION->settings()->get("SkipModpackUpdatePrompt").toBool()) return ShouldUpdate::SkipUpdating; auto info = CustomMessageBox::selectable( diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 93ff572c2..179f06bbf 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -241,7 +241,7 @@ void LauncherPage::applySettings() // Mods s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked()); s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked()); - s->set("ModpackUpdatePromptDisabled", ui->modpackUpdatePromptDisableBtn->isChecked()); + s->set("SkipModpackUpdatePrompt", ui->skipModpackUpdatePromptBtn->isChecked()); } void LauncherPage::loadSettings() { @@ -304,7 +304,7 @@ void LauncherPage::loadSettings() ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool()); - ui->modpackUpdatePromptDisableBtn->setChecked(s->get("ModpackUpdatePromptDisabled").toBool()); + ui->skipModpackUpdatePromptBtn->setChecked(s->get("SkipModpackUpdatePrompt").toBool()); } void LauncherPage::refreshFontPreview() diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index 162b5da45..b3d677ce2 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -244,12 +244,12 @@ - + - When creating a new modpack instance, do not suggest updating existing instances. + When creating a new modpack instance, do not suggest updating existing instances instead. - Always create new modpack instance + Skip modpack update prompt From 1dd21a5e4a5360ceac5f549fb613722487bfb4f1 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 4 Jul 2024 16:38:40 +0300 Subject: [PATCH 4/5] fix crash with hash task Signed-off-by: Trial97 --- launcher/modplatform/helpers/HashUtils.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/launcher/modplatform/helpers/HashUtils.cpp b/launcher/modplatform/helpers/HashUtils.cpp index f20af1f09..51789910c 100644 --- a/launcher/modplatform/helpers/HashUtils.cpp +++ b/launcher/modplatform/helpers/HashUtils.cpp @@ -18,8 +18,7 @@ Hasher::Ptr createHasher(QString file_path, ModPlatform::ResourceProvider provid case ModPlatform::ResourceProvider::FLAME: return makeShared(file_path, Algorithm::Murmur2); default: - qCritical() << "[Hashing]" - << "Unrecognized mod platform!"; + qCritical() << "[Hashing]" << "Unrecognized mod platform!"; return nullptr; } } @@ -129,6 +128,10 @@ QString hash(QString fileName, Algorithm type) QFile file(fileName); return hash(&file, type); } +QString hashFile(QString fileName, Algorithm type) +{ + return hash(fileName, type); +} QString hash(QByteArray data, Algorithm type) { @@ -138,7 +141,7 @@ QString hash(QByteArray data, Algorithm type) void Hasher::executeTask() { - m_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return hash(m_path, m_alg); }); + m_future = QtConcurrent::run(QThreadPool::globalInstance(), hashFile, m_path, m_alg); connect(&m_watcher, &QFutureWatcher::finished, this, [this] { if (m_future.isCanceled()) { emitAborted(); From 5d8d1c4b90960e3469bb04e566c79afb513da529 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 4 Jul 2024 16:47:27 +0300 Subject: [PATCH 5/5] transform hashFile to lambda Signed-off-by: Trial97 --- launcher/modplatform/helpers/HashUtils.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/launcher/modplatform/helpers/HashUtils.cpp b/launcher/modplatform/helpers/HashUtils.cpp index 51789910c..a3b8d904c 100644 --- a/launcher/modplatform/helpers/HashUtils.cpp +++ b/launcher/modplatform/helpers/HashUtils.cpp @@ -128,10 +128,6 @@ QString hash(QString fileName, Algorithm type) QFile file(fileName); return hash(&file, type); } -QString hashFile(QString fileName, Algorithm type) -{ - return hash(fileName, type); -} QString hash(QByteArray data, Algorithm type) { @@ -141,7 +137,8 @@ QString hash(QByteArray data, Algorithm type) void Hasher::executeTask() { - m_future = QtConcurrent::run(QThreadPool::globalInstance(), hashFile, m_path, m_alg); + m_future = QtConcurrent::run( + QThreadPool::globalInstance(), [](QString fileName, Algorithm type) { return hash(fileName, type); }, m_path, m_alg); connect(&m_watcher, &QFutureWatcher::finished, this, [this] { if (m_future.isCanceled()) { emitAborted();