finished up the curesforge export
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
377f27b16f
commit
049b02cee4
@ -28,20 +28,21 @@
|
||||
#include "MMCZip.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
#include "modplatform/helpers/ExportModsToStringTask.h"
|
||||
|
||||
const QStringList FlamePackExportTask::PREFIXES({ "mods/", "coremods/", "resourcepacks/", "texturepacks/", "shaderpacks/" });
|
||||
const QStringList FlamePackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
||||
const QString FlamePackExportTask::TEMPLATE = "<li><a href={url}>{name}({authors})</a></li>";
|
||||
|
||||
FlamePackExportTask::FlamePackExportTask(const QString& name,
|
||||
const QString& version,
|
||||
const QString& author,
|
||||
const QVariant& projectID,
|
||||
InstancePtr instance,
|
||||
const QString& output,
|
||||
MMCZip::FilterFunction filter)
|
||||
: name(name)
|
||||
, version(version)
|
||||
, author(author)
|
||||
, projectID(projectID)
|
||||
, instance(instance)
|
||||
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
||||
@ -193,28 +194,27 @@ QByteArray FlamePackExportTask::generateIndex()
|
||||
|
||||
QJsonObject loader;
|
||||
if (quilt != nullptr)
|
||||
loader["id"] = quilt->getName();
|
||||
loader["id"] = "quilt-" + quilt->getVersion();
|
||||
else if (fabric != nullptr)
|
||||
loader["id"] = fabric->getName();
|
||||
loader["id"] = "fabric-" + fabric->getVersion();
|
||||
else if (forge != nullptr)
|
||||
loader["id"] = forge->getName();
|
||||
loader["id"] = "forge-" + forge->getVersion();
|
||||
loader["primary"] = true;
|
||||
|
||||
version["modLoaders"] = QJsonArray({ loader });
|
||||
obj["minecraft"] = version;
|
||||
}
|
||||
|
||||
QJsonArray files;
|
||||
QMapIterator<QString, ResolvedFile> iterator(resolvedFiles);
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
|
||||
const ResolvedFile& value = iterator.value();
|
||||
for (auto mod : mods) {
|
||||
auto meta = mod->metadata();
|
||||
if (meta == nullptr || meta->provider != ModPlatform::ResourceProvider::FLAME)
|
||||
continue;
|
||||
resolvedFiles[gameRoot.relativeFilePath(mod->fileinfo().absoluteFilePath())] = {};
|
||||
|
||||
QJsonObject file;
|
||||
file["projectID"] = value.projectID.toInt();
|
||||
file["fileID"] = value.fileID.toInt();
|
||||
file["required"] = value.required;
|
||||
file["projectID"] = meta->project_id.toInt();
|
||||
file["fileID"] = meta->file_id.toInt();
|
||||
file["required"] = true;
|
||||
files << file;
|
||||
}
|
||||
obj["files"] = files;
|
||||
|
@ -29,6 +29,7 @@ class FlamePackExportTask : public Task {
|
||||
public:
|
||||
FlamePackExportTask(const QString& name,
|
||||
const QString& version,
|
||||
const QString& author,
|
||||
const QVariant& projectID,
|
||||
InstancePtr instance,
|
||||
const QString& output,
|
||||
@ -39,13 +40,6 @@ class FlamePackExportTask : public Task {
|
||||
bool abort() override;
|
||||
|
||||
private:
|
||||
struct ResolvedFile {
|
||||
QVariant projectID, fileID;
|
||||
bool required;
|
||||
};
|
||||
|
||||
static const QStringList PREFIXES;
|
||||
static const QStringList FILE_EXTENSIONS;
|
||||
static const QString TEMPLATE;
|
||||
|
||||
// inputs
|
||||
@ -60,7 +54,7 @@ class FlamePackExportTask : public Task {
|
||||
typedef std::optional<QString> BuildZipResult;
|
||||
|
||||
QFileInfoList files;
|
||||
QMap<QString, ResolvedFile> resolvedFiles;
|
||||
QMap<QString, QString> resolvedFiles;
|
||||
Task::Ptr task;
|
||||
QFuture<BuildZipResult> buildZipFuture;
|
||||
QFutureWatcher<BuildZipResult> buildZipWatcher;
|
||||
|
@ -39,10 +39,13 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent, Mo
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->name->setText(instance->name());
|
||||
if (m_provider == ModPlatform::ResourceProvider::MODRINTH)
|
||||
if (m_provider == ModPlatform::ResourceProvider::MODRINTH) {
|
||||
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
||||
else
|
||||
ui->author->hide();
|
||||
ui->authorLabel->hide();
|
||||
} else {
|
||||
ui->summaryLabel->setText("ProjectID");
|
||||
}
|
||||
|
||||
// ensure a valid pack is generated
|
||||
// the name and version fields mustn't be empty
|
||||
@ -96,9 +99,14 @@ void ExportMrPackDialog::done(int result)
|
||||
{
|
||||
if (result == Accepted) {
|
||||
const QString filename = FS::RemoveInvalidFilenameChars(ui->name->text());
|
||||
const QString output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()),
|
||||
FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
||||
"Modrinth pack (*.mrpack *.zip)", nullptr);
|
||||
QString output;
|
||||
if (m_provider == ModPlatform::ResourceProvider::MODRINTH)
|
||||
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()),
|
||||
FS::PathCombine(QDir::homePath(), filename + ".mrpack"), "Modrinth pack (*.mrpack *.zip)",
|
||||
nullptr);
|
||||
else
|
||||
output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()),
|
||||
FS::PathCombine(QDir::homePath(), filename + ".zip"), "Curseforge pack (*.zip)", nullptr);
|
||||
|
||||
if (output.isEmpty())
|
||||
return;
|
||||
@ -107,7 +115,7 @@ void ExportMrPackDialog::done(int result)
|
||||
task = new ModrinthPackExportTask(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
|
||||
[this](const QString& path) { return proxy->blockedPaths().covers(path); });
|
||||
else
|
||||
task = new FlamePackExportTask(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
|
||||
task = new FlamePackExportTask(ui->name->text(), ui->version->text(), ui->author->text(), ui->summary->text(), instance, output,
|
||||
[this](const QString& path) { return proxy->blockedPaths().covers(path); });
|
||||
|
||||
connect(task, &Task::failed,
|
||||
|
@ -24,7 +24,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<widget class="QLabel" name="summaryLabel">
|
||||
<property name="text">
|
||||
<string>Summary</string>
|
||||
</property>
|
||||
@ -41,7 +41,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="summaryLabel">
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<property name="text">
|
||||
<string>Version</string>
|
||||
</property>
|
||||
@ -57,6 +57,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="authorLabel">
|
||||
<property name="text">
|
||||
<string>Author</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="author"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user