Updated Managed Packs

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-10-19 19:47:48 +03:00
parent c638a63a03
commit 03a27d5b5a
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
3 changed files with 28 additions and 3 deletions

View File

@ -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));

View File

@ -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());
}

View File

@ -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: <a href=%1>%2</a> | 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<QString, QString> 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<QString, QString> extra_info;
extra_info.insert("pack_id", m_inst->getManagedPackID());