From 03a27d5b5a43116bafbd08aa8a2f5b7a592710b8 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 19 Oct 2023 19:47:48 +0300 Subject: [PATCH] Updated Managed Packs Signed-off-by: Trial97 --- .../flame/FlameInstanceCreationTask.cpp | 3 +++ .../modrinth/ModrinthInstanceCreationTask.cpp | 5 +++- .../ui/pages/instance/ManagedPackPage.cpp | 23 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index 2a26ce944..c8df8b627 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -427,6 +427,9 @@ bool FlameCreationTask::createInstance() // Don't add managed info to packs without an ID (most likely imported from ZIP) if (!m_managed_id.isEmpty()) instance.setManagedPack("flame", m_managed_id, m_pack.name, m_managed_version_id, m_pack.version); + else + instance.setManagedPack("flame", "", name(), "", ""); + instance.setName(name()); m_mod_id_resolver.reset(new Flame::FileResolvingTask(APPLICATION->network(), m_pack)); diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index e732ad39c..96d9c84d2 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -226,6 +226,9 @@ bool ModrinthCreationTask::createInstance() // Don't add managed info to packs without an ID (most likely imported from ZIP) if (!m_managed_id.isEmpty()) instance.setManagedPack("modrinth", m_managed_id, m_managed_name, m_managed_version_id, version()); + else + instance.setManagedPack("modrinth", "", name(), "", ""); + instance.setName(name()); instance.saveNow(); @@ -289,7 +292,7 @@ bool ModrinthCreationTask::createInstance() // Only change the name if it didn't use a custom name, so that the previous custom name // is preserved, but if we're using the original one, we update the version string. // NOTE: This needs to come before the copyManagedPack call! - if (inst->name().contains(inst->getManagedPackVersionName())) { + if (inst->name().contains(inst->getManagedPackVersionName()) && inst->name() != instance.name()) { if (askForChangingInstanceName(m_parent, inst->name(), instance.name()) == InstanceNameChange::ShouldChange) inst->setName(instance.name()); } diff --git a/launcher/ui/pages/instance/ManagedPackPage.cpp b/launcher/ui/pages/instance/ManagedPackPage.cpp index 26a8302db..c419066a0 100644 --- a/launcher/ui/pages/instance/ManagedPackPage.cpp +++ b/launcher/ui/pages/instance/ManagedPackPage.cpp @@ -131,6 +131,22 @@ ManagedPackPage::~ManagedPackPage() void ManagedPackPage::openedImpl() { + if (m_inst->getManagedPackID().isEmpty()) { + ui->packVersion->hide(); + ui->packVersionLabel->hide(); + ui->packOrigin->hide(); + ui->packOriginLabel->hide(); + ui->versionsComboBox->hide(); + ui->updateButton->hide(); + ui->updateToVersionLabel->hide(); + ui->updateFromFileButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + + ui->packName->setText(m_inst->name()); + ui->changelogTextBrowser->setText(tr("This is a local modpack.\n" + "This can be updated only using a file in %1 format\n") + .arg(displayName())); + return; + } ui->packName->setText(m_inst->getManagedPackName()); ui->packVersion->setText(m_inst->getManagedPackVersionName()); ui->packOrigin->setText(tr("Website: %2 | Pack ID: %3 | Version ID: %4") @@ -355,6 +371,8 @@ void ModrinthManagedPackPage::update() void ModrinthManagedPackPage::updateFromFile() { auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), "Modrinth pack (*.mrpack *.zip)"); + if (output.isEmpty()) + return; QMap extra_info; extra_info.insert("pack_id", m_inst->getManagedPackID()); extra_info.insert("pack_version_id", QString()); @@ -471,8 +489,7 @@ void FlameManagedPackPage::parseManagedPack() QString FlameManagedPackPage::url() const { - // FIXME: We should display the websiteUrl field, but this requires doing the API request first :( - return {}; + return "https://www.curseforge.com/projects/" + m_inst->getManagedPackID(); } void FlameManagedPackPage::suggestVersion() @@ -519,6 +536,8 @@ void FlameManagedPackPage::update() void FlameManagedPackPage::updateFromFile() { auto output = QFileDialog::getOpenFileUrl(this, tr("Choose update file"), QDir::homePath(), "CurseForge pack (*.zip)"); + if (output.isEmpty()) + return; QMap extra_info; extra_info.insert("pack_id", m_inst->getManagedPackID());