From b8d996530c6420c8eb92ecdbc2e55af33b975bf5 Mon Sep 17 00:00:00 2001 From: dyredhead Date: Fri, 29 May 2026 00:59:08 -0400 Subject: [PATCH] added settings entires for auto updating mods Signed-off-by: dyredhead --- launcher/minecraft/MinecraftInstance.cpp | 8 ++++- .../ui/widgets/MinecraftSettingsWidget.cpp | 32 +++++++++++++++++++ .../ui/widgets/MinecraftSettingsWidget.ui | 31 +++++++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 8e98a2efe..bcc770992 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -263,10 +263,16 @@ void MinecraftInstance::loadSpecificSettings() connect(dataPacksEnabled.get(), &Setting::SettingChanged, this, [this] { m_data_pack_list.reset(); }); connect(dataPacksPath.get(), &Setting::SettingChanged, this, [this] { m_data_pack_list.reset(); }); - // Join server on launch, this does not have a global override + // Set mod downloaders, this does not have a global override m_settings->registerSetting("OverrideModDownloadLoaders", false); m_settings->registerSetting("ModDownloadLoaders", "[]"); + // Enable automatic mod updates, this does not have a global override + m_settings->registerSetting("AutomaticallyUpdateMods", false); + m_settings->registerSetting("AutomaticallyUpdateModsAll", false); + m_settings->registerSetting("AutomaticallyUpdateModsEnabled", true); + // m_settings->registerSetting("AutomaticallyUpdateModsSpecified", "[]"); + qDebug() << "Instance-type specific settings were loaded!"; setSpecificSettingsLoaded(true); diff --git a/launcher/ui/widgets/MinecraftSettingsWidget.cpp b/launcher/ui/widgets/MinecraftSettingsWidget.cpp index 460068bd3..29a4045d3 100644 --- a/launcher/ui/widgets/MinecraftSettingsWidget.cpp +++ b/launcher/ui/widgets/MinecraftSettingsWidget.cpp @@ -61,6 +61,7 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstance* instance, QW m_ui->serverJoinGroupBox->hide(); m_ui->globalDataPacksGroupBox->hide(); m_ui->loaderGroup->hide(); + m_ui->autoModUpdateGroup->hide(); } else { m_javaSettings = new JavaSettingsWidget(m_instance, this); m_ui->javaScrollArea->setWidget(m_javaSettings); @@ -120,6 +121,18 @@ MinecraftSettingsWidget::MinecraftSettingsWidget(MinecraftInstance* instance, QW m_ui->legacyFabric, m_ui->ornithe, m_ui->rift }) { connect(c, &QCheckBox::stateChanged, this, &MinecraftSettingsWidget::saveSelectedLoaders); } + + connect(m_ui->autoModUpdateGroup, &QGroupBox::toggled, this, [this](bool value) { + m_instance->settings()->set("AutomaticallyUpdateMods", value); + // if (!value) { + // m_instance->settings()->reset("AutomaticallyUpdateModsAll"); + // m_instance->settings()->reset("AutomaticallyUpdateModsEnabled"); + // } + }); + connect(m_ui->allMods, &QAbstractButton::toggled, this, + [this](bool value) { m_instance->settings()->set("AutomaticallyUpdateModsAll", value); }); + connect(m_ui->enabledMods, &QAbstractButton::toggled, this, + [this](bool value) { m_instance->settings()->set("AutomaticallyUpdateModsEnabled", value); }); } m_ui->maximizedWarning->hide(); @@ -248,6 +261,10 @@ void MinecraftSettingsWidget::loadSettings() m_ui->serverJoinGroupBox->setChecked(settings->get("JoinServerOnLaunch").toBool()); + m_ui->autoModUpdateGroup->setChecked(settings->get("AutomaticallyUpdateMods").toBool()); + m_ui->allMods->setChecked(settings->get("AutomaticallyUpdateModsAll").toBool()); + m_ui->enabledMods->setChecked(settings->get("AutomaticallyUpdateModsEnabled").toBool()); + m_ui->instanceAccountGroupBox->setChecked(settings->get("UseAccountForInstance").toBool()); updateAccountsMenu(*settings); @@ -455,6 +472,21 @@ void MinecraftSettingsWidget::saveSettings() settings->reset("JoinWorldOnLaunch"); } + bool automaticallyUpdateMods = m_ui->autoModUpdateGroup->isChecked(); + settings->set("AutomaticallyUpdateMods", automaticallyUpdateMods); + // if (automaticallyUpdateMods) { + if (m_ui->allMods->isChecked()) { + settings->set("AutomaticallyUpdateModsAll", true); + settings->set("AutomaticallyUpdateModsEnabled", false); + } else { + settings->set("AutomaticallyUpdateModsAll", false); + settings->set("AutomaticallyUpdateModsEnabled", true); + } + // } else { + // settings->reset("AutomaticallyUpdateModsAll"); + // settings->reset("AutomaticallyUpdateModsEnabled"); + // } + // Use an account for this instance bool useAccountForInstance = m_ui->instanceAccountGroupBox->isChecked(); settings->set("UseAccountForInstance", useAccountForInstance); diff --git a/launcher/ui/widgets/MinecraftSettingsWidget.ui b/launcher/ui/widgets/MinecraftSettingsWidget.ui index 80fb8530d..8bd723ffc 100644 --- a/launcher/ui/widgets/MinecraftSettingsWidget.ui +++ b/launcher/ui/widgets/MinecraftSettingsWidget.ui @@ -268,7 +268,7 @@ Allows installing data packs across all worlds if an applicable mod is installed. -It is most likely you will need to change the path - please refer to the mod's website. + It is most likely you will need to change the path - please refer to the mod's website. @@ -554,6 +554,35 @@ It is most likely you will need to change the path - please refer to the mod's w + + + + Automatically Update Mods + + + true + + + false + + + + + + All mods + + + + + + + Enabled mods only + + + + + +