feat(ManagedPackPage): implement Flame modpack updating button

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-11-12 13:03:50 -03:00
parent 34794cc4af
commit 57b905be24
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 28 additions and 0 deletions

View File

@ -271,6 +271,7 @@ FlameManagedPackPage::FlameManagedPackPage(BaseInstance* inst, InstanceWindow* i
{
Q_ASSERT(inst->isManagedPack());
connect(ui->versionsComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(suggestVersion()));
connect(ui->updateButton, &QPushButton::pressed, this, &FlameManagedPackPage::update);
}
void FlameManagedPackPage::parseManagedPack() {
@ -367,4 +368,29 @@ void FlameManagedPackPage::suggestVersion()
ManagedPackPage::suggestVersion();
}
void FlameManagedPackPage::update()
{
auto index = ui->versionsComboBox->currentIndex();
auto version = m_pack.versions.at(index);
QMap<QString, QString> extra_info;
extra_info.insert("pack_id", m_inst->getManagedPackID());
extra_info.insert("pack_version_id", QString::number(version.fileId));
auto extracted = new InstanceImportTask(version.downloadUrl, this, extra_info);
InstanceName inst_name(m_inst->getManagedPackName(), version.version);
inst_name.setName(m_inst->name().replace(m_inst->getManagedPackVersionName(), version.version));
extracted->setName(inst_name);
extracted->setGroup(APPLICATION->instances()->getInstanceGroup(m_inst->id()));
extracted->setIcon(m_inst->iconKey());
extracted->setConfirmUpdate(false);
auto did_succeed = runUpdateTask(extracted);
if (m_instance_window && did_succeed)
m_instance_window->close();
}
#include "ManagedPackPage.moc"

View File

@ -134,6 +134,8 @@ class FlameManagedPackPage final : public ManagedPackPage {
public slots:
void suggestVersion() override;
void update() override;
private:
Flame::IndexedPack m_pack;
FlameAPI m_api;