From f9e007ca2b6d8c361024b9cbc4e45de7c71e936c Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 7 May 2026 19:57:40 +0300 Subject: [PATCH] add update reason Signed-off-by: Trial97 --- .../modplatform/flame/FlameCheckUpdate.cpp | 2 +- .../modrinth/ModrinthCheckUpdate.cpp | 2 +- .../modrinth/ModrinthInstanceCreationTask.cpp | 21 ++++++------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/launcher/modplatform/flame/FlameCheckUpdate.cpp b/launcher/modplatform/flame/FlameCheckUpdate.cpp index 37f0bcb32..c38c2047e 100644 --- a/launcher/modplatform/flame/FlameCheckUpdate.cpp +++ b/launcher/modplatform/flame/FlameCheckUpdate.cpp @@ -120,7 +120,7 @@ void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* old_version = tr("Unknown"); } - auto download_task = makeShared(pack, latest_ver.value(), m_resourceModel); + auto download_task = makeShared(pack, latest_ver.value(), m_resourceModel, true, "update"); m_updates.emplace_back(pack->name, resource->metadata()->hash, old_version, latest_ver->version, latest_ver->version_type, api.getModFileChangelog(latest_ver->addonId.toInt(), latest_ver->fileId.toInt()), ModPlatform::ResourceProvider::FLAME, download_task, resource->enabled()); diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp index bd5a50d1b..26059b88b 100644 --- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp +++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp @@ -178,7 +178,7 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio pack->addonId = resource->metadata()->project_id; pack->provider = ModPlatform::ResourceProvider::MODRINTH; if ((project_ver.hash != hash && project_ver.is_preferred) || (resource->status() == ResourceStatus::NOT_INSTALLED)) { - auto download_task = makeShared(pack, project_ver, m_resourceModel); + auto download_task = makeShared(pack, project_ver, m_resourceModel, true, "update"); QString old_version = resource->metadata()->version_number; if (old_version.isEmpty()) { diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index f1717fefe..0cb2c547d 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -213,17 +213,22 @@ std::unique_ptr ModrinthCreationTask::createInstance() components->buildingFromScratch(); components->setComponentVersion("net.minecraft", m_minecraft_version, true); + QString loader; if (!m_fabric_version.isEmpty()) { components->setComponentVersion("net.fabricmc.fabric-loader", m_fabric_version); + loader = ModPlatform::getModLoaderAsString(ModPlatform::ModLoaderType::Fabric); } if (!m_quilt_version.isEmpty()) { components->setComponentVersion("org.quiltmc.quilt-loader", m_quilt_version); + loader = ModPlatform::getModLoaderAsString(ModPlatform::ModLoaderType::Quilt); } if (!m_forge_version.isEmpty()) { components->setComponentVersion("net.minecraftforge", m_forge_version); + loader = ModPlatform::getModLoaderAsString(ModPlatform::ModLoaderType::Forge); } if (!m_neoForge_version.isEmpty()) { components->setComponentVersion("net.neoforged", m_neoForge_version); + loader = ModPlatform::getModLoaderAsString(ModPlatform::ModLoaderType::NeoForge); } if (m_instIcon != "default") { @@ -271,22 +276,8 @@ std::unique_ptr ModrinthCreationTask::createInstance() } qDebug() << "Will try to download" << file.downloads.front() << "to" << filePath; - QString loader; - if (m_instance.has_value()) { - auto* mcInstance = dynamic_cast(m_instance.value()); - if (mcInstance) { - auto* profile = mcInstance->getPackProfile(); - if (profile) { - auto loaders = profile->getModLoadersList(); - if (!loaders.isEmpty()) { - loader = ModPlatform::getModLoaderAsString(loaders.first()); - } - } - } - } - Net::ModrinthDownloadMeta meta{ - .reason = "modpack", + .reason = m_instance.has_value() ? "update" : "modpack", .gameVersion = m_minecraft_version, .loader = loader, };