Use non-mod metadata in ModrinthPackExportTask

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2024-10-25 19:13:41 +01:00
parent 5eff9b0934
commit 13e13ea8fc
8 changed files with 143 additions and 109 deletions

View File

@@ -1403,27 +1403,26 @@ void MainWindow::on_actionExportInstanceZip_triggered()
void MainWindow::on_actionExportInstanceMrPack_triggered()
{
if (m_selectedInstance) {
ExportPackDialog dlg(m_selectedInstance, this);
auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_selectedInstance);
if (instance) {
ExportPackDialog dlg(std::move(instance), this);
dlg.exec();
}
}
void MainWindow::on_actionExportInstanceFlamePack_triggered()
{
if (m_selectedInstance) {
auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
if (instance) {
if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
QMessageBox msgBox(this);
msgBox.setText("Snapshots are currently not supported by CurseForge modpacks.");
msgBox.exec();
return;
}
ExportPackDialog dlg(m_selectedInstance, this, ModPlatform::ResourceProvider::FLAME);
dlg.exec();
auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_selectedInstance);
if (instance) {
if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
QMessageBox msgBox(this);
msgBox.setText("Snapshots are currently not supported by CurseForge modpacks.");
msgBox.exec();
return;
}
ExportPackDialog dlg(std::move(instance), this, ModPlatform::ResourceProvider::FLAME);
dlg.exec();
}
}

View File

@@ -34,7 +34,7 @@
#include "MMCZip.h"
#include "modplatform/modrinth/ModrinthPackExportTask.h"
ExportPackDialog::ExportPackDialog(InstancePtr instance, QWidget* parent, ModPlatform::ResourceProvider provider)
ExportPackDialog::ExportPackDialog(const MinecraftInstancePtr& instance, QWidget* parent, ModPlatform::ResourceProvider provider)
: QDialog(parent), instance(instance), ui(new Ui::ExportPackDialog), m_provider(provider)
{
Q_ASSERT(m_provider == ModPlatform::ResourceProvider::MODRINTH || m_provider == ModPlatform::ResourceProvider::FLAME);
@@ -86,12 +86,9 @@ ExportPackDialog::ExportPackDialog(InstancePtr instance, QWidget* parent, ModPla
proxy->blockedPaths().insert(file);
}
MinecraftInstance* mcInstance = dynamic_cast<MinecraftInstance*>(instance.get());
if (mcInstance) {
const QDir index = mcInstance->loaderModList()->indexDir();
if (index.exists())
proxy->ignoreFilesWithPath().insert(root.relativeFilePath(index.absolutePath()));
}
for (auto& resourceModel : instance->resourceLists())
if (resourceModel->indexDir().exists())
proxy->ignoreFilesWithPath().insert(root.relativeFilePath(resourceModel->indexDir().absolutePath()));
ui->files->setModel(proxy);
ui->files->setRootIndex(proxy->mapFromSource(model->index(instance->gameRoot())));

View File

@@ -18,6 +18,7 @@
#pragma once
#include <minecraft/MinecraftInstance.h>
#include <QDialog>
#include "BaseInstance.h"
#include "FastFileIconProvider.h"
@@ -32,7 +33,7 @@ class ExportPackDialog : public QDialog {
Q_OBJECT
public:
explicit ExportPackDialog(InstancePtr instance,
explicit ExportPackDialog(const MinecraftInstancePtr& instance,
QWidget* parent = nullptr,
ModPlatform::ResourceProvider provider = ModPlatform::ResourceProvider::MODRINTH);
~ExportPackDialog();
@@ -41,7 +42,7 @@ class ExportPackDialog : public QDialog {
void validate();
private:
const InstancePtr instance;
const MinecraftInstancePtr instance;
Ui::ExportPackDialog* ui;
FileIgnoreProxy* proxy;
FastFileIconProvider icons;