commit
91c9082d19
@ -514,6 +514,8 @@ set(FLAME_SOURCES
|
|||||||
modplatform/flame/FlameCheckUpdate.h
|
modplatform/flame/FlameCheckUpdate.h
|
||||||
modplatform/flame/FlameInstanceCreationTask.h
|
modplatform/flame/FlameInstanceCreationTask.h
|
||||||
modplatform/flame/FlameInstanceCreationTask.cpp
|
modplatform/flame/FlameInstanceCreationTask.cpp
|
||||||
|
modplatform/flame/FlamePackExportTask.h
|
||||||
|
modplatform/flame/FlamePackExportTask.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MODRINTH_SOURCES
|
set(MODRINTH_SOURCES
|
||||||
@ -907,8 +909,8 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/dialogs/EditAccountDialog.h
|
ui/dialogs/EditAccountDialog.h
|
||||||
ui/dialogs/ExportInstanceDialog.cpp
|
ui/dialogs/ExportInstanceDialog.cpp
|
||||||
ui/dialogs/ExportInstanceDialog.h
|
ui/dialogs/ExportInstanceDialog.h
|
||||||
ui/dialogs/ExportMrPackDialog.cpp
|
ui/dialogs/ExportPackDialog.cpp
|
||||||
ui/dialogs/ExportMrPackDialog.h
|
ui/dialogs/ExportPackDialog.h
|
||||||
ui/dialogs/IconPickerDialog.cpp
|
ui/dialogs/IconPickerDialog.cpp
|
||||||
ui/dialogs/IconPickerDialog.h
|
ui/dialogs/IconPickerDialog.h
|
||||||
ui/dialogs/ImportResourceDialog.cpp
|
ui/dialogs/ImportResourceDialog.cpp
|
||||||
@ -1055,7 +1057,7 @@ qt_wrap_ui(LAUNCHER_UI
|
|||||||
ui/dialogs/ProfileSelectDialog.ui
|
ui/dialogs/ProfileSelectDialog.ui
|
||||||
ui/dialogs/SkinUploadDialog.ui
|
ui/dialogs/SkinUploadDialog.ui
|
||||||
ui/dialogs/ExportInstanceDialog.ui
|
ui/dialogs/ExportInstanceDialog.ui
|
||||||
ui/dialogs/ExportMrPackDialog.ui
|
ui/dialogs/ExportPackDialog.ui
|
||||||
ui/dialogs/IconPickerDialog.ui
|
ui/dialogs/IconPickerDialog.ui
|
||||||
ui/dialogs/ImportResourceDialog.ui
|
ui/dialogs/ImportResourceDialog.ui
|
||||||
ui/dialogs/MSALoginDialog.ui
|
ui/dialogs/MSALoginDialog.ui
|
||||||
|
@ -128,6 +128,7 @@ struct IndexedPack {
|
|||||||
return std::any_of(versions.constBegin(), versions.constEnd(), [](auto const& v) { return v.is_currently_selected; });
|
return std::any_of(versions.constBegin(), versions.constEnd(), [](auto const& v) { return v.is_currently_selected; });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
||||||
|
|
||||||
struct OverrideDep {
|
struct OverrideDep {
|
||||||
QString quilt;
|
QString quilt;
|
||||||
|
473
launcher/modplatform/flame/FlamePackExportTask.cpp
Normal file
473
launcher/modplatform/flame/FlamePackExportTask.cpp
Normal file
@ -0,0 +1,473 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||||
|
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FlamePackExportTask.h"
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QtConcurrentRun>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
#include "Json.h"
|
||||||
|
#include "MMCZip.h"
|
||||||
|
#include "minecraft/PackProfile.h"
|
||||||
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
#include "modplatform/flame/FlameModIndex.h"
|
||||||
|
#include "modplatform/helpers/HashUtils.h"
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
|
const QString FlamePackExportTask::TEMPLATE = "<li><a href=\"{url}\">{name}{authors}</a></li>\n";
|
||||||
|
const QStringList FlamePackExportTask::FILE_EXTENSIONS({ "jar", "zip" });
|
||||||
|
|
||||||
|
FlamePackExportTask::FlamePackExportTask(const QString& name,
|
||||||
|
const QString& version,
|
||||||
|
const QString& author,
|
||||||
|
InstancePtr instance,
|
||||||
|
const QString& output,
|
||||||
|
MMCZip::FilterFunction filter)
|
||||||
|
: name(name)
|
||||||
|
, version(version)
|
||||||
|
, author(author)
|
||||||
|
, instance(instance)
|
||||||
|
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
||||||
|
, gameRoot(instance->gameRoot())
|
||||||
|
, output(output)
|
||||||
|
, filter(filter)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void FlamePackExportTask::executeTask()
|
||||||
|
{
|
||||||
|
setStatus(tr("Searching for files..."));
|
||||||
|
setProgress(0, 5);
|
||||||
|
collectFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlamePackExportTask::abort()
|
||||||
|
{
|
||||||
|
if (task != nullptr) {
|
||||||
|
task->abort();
|
||||||
|
task = nullptr;
|
||||||
|
emitAborted();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildZipFuture.isRunning()) {
|
||||||
|
buildZipFuture.cancel();
|
||||||
|
// NOTE: Here we don't do `emitAborted()` because it will be done when `buildZipFuture` actually cancels, which may not occur
|
||||||
|
// immediately.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::collectFiles()
|
||||||
|
{
|
||||||
|
setAbortable(false);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
|
files.clear();
|
||||||
|
if (!MMCZip::collectFileListRecursively(instance->gameRoot(), nullptr, &files, filter)) {
|
||||||
|
emitFailed(tr("Could not search for files"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pendingHashes.clear();
|
||||||
|
resolvedFiles.clear();
|
||||||
|
|
||||||
|
if (mcInstance != nullptr) {
|
||||||
|
mcInstance->loaderModList()->update();
|
||||||
|
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &FlamePackExportTask::collectHashes);
|
||||||
|
} else
|
||||||
|
collectHashes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::collectHashes()
|
||||||
|
{
|
||||||
|
setAbortable(true);
|
||||||
|
setStatus(tr("Finding file hashes..."));
|
||||||
|
setProgress(1, 5);
|
||||||
|
auto allMods = mcInstance->loaderModList()->allMods();
|
||||||
|
ConcurrentTask::Ptr hashingTask(new ConcurrentTask(this, "MakeHashesTask", 10));
|
||||||
|
task.reset(hashingTask);
|
||||||
|
for (const QFileInfo& file : files) {
|
||||||
|
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||||
|
// require sensible file types
|
||||||
|
if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) {
|
||||||
|
return relative.endsWith('.' + extension) || relative.endsWith('.' + extension + ".disabled");
|
||||||
|
}))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (relative.startsWith("resourcepacks/") &&
|
||||||
|
(relative.endsWith(".zip") || relative.endsWith(".zip.disabled"))) { // is resourcepack
|
||||||
|
auto hashTask = Hashing::createFlameHasher(file.absoluteFilePath());
|
||||||
|
connect(hashTask.get(), &Hashing::Hasher::resultsReady, [this, relative, file](QString hash) {
|
||||||
|
if (m_state == Task::State::Running) {
|
||||||
|
pendingHashes.insert(hash, { relative, file.absoluteFilePath(), relative.endsWith(".zip") });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(hashTask.get(), &Task::failed, this, &FlamePackExportTask::emitFailed);
|
||||||
|
hashingTask->addTask(hashTask);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto modIter = std::find_if(allMods.begin(), allMods.end(), [&file](Mod* mod) { return mod->fileinfo() == file; });
|
||||||
|
modIter != allMods.end()) {
|
||||||
|
const Mod* mod = *modIter;
|
||||||
|
if (!mod || mod->type() == ResourceType::FOLDER) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (mod->metadata() && mod->metadata()->provider == ModPlatform::ResourceProvider::FLAME) {
|
||||||
|
resolvedFiles.insert(mod->fileinfo().absoluteFilePath(),
|
||||||
|
{ mod->metadata()->project_id.toInt(), mod->metadata()->file_id.toInt(), mod->enabled(), true,
|
||||||
|
mod->metadata()->name, mod->metadata()->slug, mod->authors().join(", ") });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto hashTask = Hashing::createFlameHasher(mod->fileinfo().absoluteFilePath());
|
||||||
|
connect(hashTask.get(), &Hashing::Hasher::resultsReady, [this, mod](QString hash) {
|
||||||
|
if (m_state == Task::State::Running) {
|
||||||
|
pendingHashes.insert(hash, { mod->name(), mod->fileinfo().absoluteFilePath(), mod->enabled(), true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(hashTask.get(), &Task::failed, this, &FlamePackExportTask::emitFailed);
|
||||||
|
hashingTask->addTask(hashTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto progressStep = std::make_shared<TaskStepProgress>();
|
||||||
|
connect(hashingTask.get(), &Task::finished, this, [this, progressStep] {
|
||||||
|
progressStep->state = TaskStepState::Succeeded;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(hashingTask.get(), &Task::succeeded, this, &FlamePackExportTask::makeApiRequest);
|
||||||
|
connect(hashingTask.get(), &Task::failed, this, [this, progressStep](QString reason) {
|
||||||
|
progressStep->state = TaskStepState::Failed;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
emitFailed(reason);
|
||||||
|
});
|
||||||
|
connect(hashingTask.get(), &Task::stepProgress, this, &FlamePackExportTask::propogateStepProgress);
|
||||||
|
|
||||||
|
connect(hashingTask.get(), &Task::progress, this, [this, progressStep](qint64 current, qint64 total) {
|
||||||
|
progressStep->update(current, total);
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
});
|
||||||
|
connect(hashingTask.get(), &Task::status, this, [this, progressStep](QString status) {
|
||||||
|
progressStep->status = status;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
});
|
||||||
|
hashingTask->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::makeApiRequest()
|
||||||
|
{
|
||||||
|
if (pendingHashes.isEmpty()) {
|
||||||
|
buildZip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus(tr("Finding versions for hashes..."));
|
||||||
|
setProgress(2, 5);
|
||||||
|
auto response = std::make_shared<QByteArray>();
|
||||||
|
|
||||||
|
QList<uint> fingerprints;
|
||||||
|
for (auto& murmur : pendingHashes.keys()) {
|
||||||
|
fingerprints.push_back(murmur.toUInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
task.reset(api.matchFingerprints(fingerprints, response));
|
||||||
|
|
||||||
|
connect(task.get(), &Task::succeeded, this, [this, response] {
|
||||||
|
QJsonParseError parseError{};
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(*response, &parseError);
|
||||||
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "Error while parsing JSON response from CurseForge::CurrentVersions at " << parseError.offset
|
||||||
|
<< " reason: " << parseError.errorString();
|
||||||
|
qWarning() << *response;
|
||||||
|
|
||||||
|
failed(parseError.errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto docObj = Json::requireObject(doc);
|
||||||
|
auto dataObj = Json::requireObject(docObj, "data");
|
||||||
|
auto dataArr = Json::requireArray(dataObj, "exactMatches");
|
||||||
|
|
||||||
|
if (dataArr.isEmpty()) {
|
||||||
|
qWarning() << "No matches found for fingerprint search!";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto match : dataArr) {
|
||||||
|
auto matchObj = Json::ensureObject(match, {});
|
||||||
|
auto fileObj = Json::ensureObject(matchObj, "file", {});
|
||||||
|
|
||||||
|
if (matchObj.isEmpty() || fileObj.isEmpty()) {
|
||||||
|
qWarning() << "Fingerprint match is empty!";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto fingerprint = QString::number(Json::ensureVariant(fileObj, "fileFingerprint").toUInt());
|
||||||
|
auto mod = pendingHashes.find(fingerprint);
|
||||||
|
if (mod == pendingHashes.end()) {
|
||||||
|
qWarning() << "Invalid fingerprint from the API response.";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(mod->name));
|
||||||
|
if (Json::ensureBoolean(fileObj, "isAvailable", false, "isAvailable"))
|
||||||
|
resolvedFiles.insert(mod->path, { Json::requireInteger(fileObj, "modId"), Json::requireInteger(fileObj, "id"),
|
||||||
|
mod->enabled, mod->isMod });
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Json::JsonException& e) {
|
||||||
|
qDebug() << e.cause();
|
||||||
|
qDebug() << doc;
|
||||||
|
}
|
||||||
|
pendingHashes.clear();
|
||||||
|
});
|
||||||
|
connect(task.get(), &Task::finished, this, &FlamePackExportTask::getProjectsInfo);
|
||||||
|
connect(task.get(), &NetJob::failed, this, &FlamePackExportTask::emitFailed);
|
||||||
|
task->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::getProjectsInfo()
|
||||||
|
{
|
||||||
|
setStatus(tr("Finding project info from CurseForge..."));
|
||||||
|
setProgress(3, 5);
|
||||||
|
QStringList addonIds;
|
||||||
|
for (const auto& resolved : resolvedFiles) {
|
||||||
|
if (resolved.slug.isEmpty()) {
|
||||||
|
addonIds << QString::number(resolved.addonId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto response = std::make_shared<QByteArray>();
|
||||||
|
Task::Ptr projTask;
|
||||||
|
|
||||||
|
if (addonIds.isEmpty()) {
|
||||||
|
buildZip();
|
||||||
|
return;
|
||||||
|
} else if (addonIds.size() == 1) {
|
||||||
|
projTask = api.getProject(*addonIds.begin(), response);
|
||||||
|
} else {
|
||||||
|
projTask = api.getProjects(addonIds, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds] {
|
||||||
|
QJsonParseError parseError{};
|
||||||
|
auto doc = QJsonDocument::fromJson(*response, &parseError);
|
||||||
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "Error while parsing JSON response from CurseForge projects task at " << parseError.offset
|
||||||
|
<< " reason: " << parseError.errorString();
|
||||||
|
qWarning() << *response;
|
||||||
|
failed(parseError.errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
QJsonArray entries;
|
||||||
|
if (addonIds.size() == 1)
|
||||||
|
entries = { Json::requireObject(Json::requireObject(doc), "data") };
|
||||||
|
else
|
||||||
|
entries = Json::requireArray(Json::requireObject(doc), "data");
|
||||||
|
|
||||||
|
for (auto entry : entries) {
|
||||||
|
auto entryObj = Json::requireObject(entry);
|
||||||
|
|
||||||
|
try {
|
||||||
|
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(Json::requireString(entryObj, "name")));
|
||||||
|
|
||||||
|
ModPlatform::IndexedPack pack;
|
||||||
|
FlameMod::loadIndexedPack(pack, entryObj);
|
||||||
|
for (auto key : resolvedFiles.keys()) {
|
||||||
|
auto val = resolvedFiles.value(key);
|
||||||
|
if (val.addonId == pack.addonId) {
|
||||||
|
val.name = pack.name;
|
||||||
|
val.slug = pack.slug;
|
||||||
|
QStringList authors;
|
||||||
|
for (auto author : pack.authors)
|
||||||
|
authors << author.name;
|
||||||
|
|
||||||
|
val.authors = authors.join(", ");
|
||||||
|
resolvedFiles[key] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Json::JsonException& e) {
|
||||||
|
qDebug() << e.cause();
|
||||||
|
qDebug() << entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Json::JsonException& e) {
|
||||||
|
qDebug() << e.cause();
|
||||||
|
qDebug() << doc;
|
||||||
|
}
|
||||||
|
buildZip();
|
||||||
|
});
|
||||||
|
task.reset(projTask);
|
||||||
|
task->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::buildZip()
|
||||||
|
{
|
||||||
|
setStatus(tr("Adding files..."));
|
||||||
|
setProgress(4, 5);
|
||||||
|
|
||||||
|
buildZipFuture = QtConcurrent::run(QThreadPool::globalInstance(), [this]() {
|
||||||
|
QuaZip zip(output);
|
||||||
|
if (!zip.open(QuaZip::mdCreate)) {
|
||||||
|
QFile::remove(output);
|
||||||
|
return BuildZipResult(tr("Could not create file"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buildZipFuture.isCanceled())
|
||||||
|
return BuildZipResult();
|
||||||
|
|
||||||
|
QuaZipFile indexFile(&zip);
|
||||||
|
if (!indexFile.open(QIODevice::WriteOnly, QuaZipNewInfo("manifest.json"))) {
|
||||||
|
QFile::remove(output);
|
||||||
|
return BuildZipResult(tr("Could not create index"));
|
||||||
|
}
|
||||||
|
indexFile.write(generateIndex());
|
||||||
|
|
||||||
|
QuaZipFile modlist(&zip);
|
||||||
|
if (!modlist.open(QIODevice::WriteOnly, QuaZipNewInfo("modlist.html"))) {
|
||||||
|
QFile::remove(output);
|
||||||
|
return BuildZipResult(tr("Could not create index"));
|
||||||
|
}
|
||||||
|
QString content = "";
|
||||||
|
for (auto mod : resolvedFiles) {
|
||||||
|
if (mod.isMod) {
|
||||||
|
content += QString(TEMPLATE)
|
||||||
|
.replace("{name}", mod.name.toHtmlEscaped())
|
||||||
|
.replace("{url}", ModPlatform::getMetaURL(ModPlatform::ResourceProvider::FLAME, mod.addonId).toHtmlEscaped())
|
||||||
|
.replace("{authors}", !mod.authors.isEmpty() ? QString(" (by %1)").arg(mod.authors).toHtmlEscaped() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
content = "<ul>" + content + "</ul>";
|
||||||
|
modlist.write(content.toUtf8());
|
||||||
|
|
||||||
|
auto progressStep = std::make_shared<TaskStepProgress>();
|
||||||
|
|
||||||
|
size_t progress = 0;
|
||||||
|
for (const QFileInfo& file : files) {
|
||||||
|
if (buildZipFuture.isCanceled()) {
|
||||||
|
QFile::remove(output);
|
||||||
|
progressStep->state = TaskStepState::Failed;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
return BuildZipResult();
|
||||||
|
}
|
||||||
|
progressStep->update(progress, files.length());
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
|
||||||
|
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||||
|
if (!resolvedFiles.contains(file.absoluteFilePath()) &&
|
||||||
|
!JlCompress::compressFile(&zip, file.absoluteFilePath(), "overrides/" + relative)) {
|
||||||
|
QFile::remove(output);
|
||||||
|
return BuildZipResult(tr("Could not read and compress %1").arg(relative));
|
||||||
|
}
|
||||||
|
progress++;
|
||||||
|
}
|
||||||
|
|
||||||
|
zip.close();
|
||||||
|
|
||||||
|
if (zip.getZipError() != 0) {
|
||||||
|
QFile::remove(output);
|
||||||
|
progressStep->state = TaskStepState::Failed;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
return BuildZipResult(tr("A zip error occurred"));
|
||||||
|
}
|
||||||
|
progressStep->state = TaskStepState::Succeeded;
|
||||||
|
stepProgress(*progressStep);
|
||||||
|
return BuildZipResult();
|
||||||
|
});
|
||||||
|
connect(&buildZipWatcher, &QFutureWatcher<BuildZipResult>::finished, this, &FlamePackExportTask::finish);
|
||||||
|
buildZipWatcher.setFuture(buildZipFuture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlamePackExportTask::finish()
|
||||||
|
{
|
||||||
|
if (buildZipFuture.isCanceled())
|
||||||
|
emitAborted();
|
||||||
|
else {
|
||||||
|
const BuildZipResult result = buildZipFuture.result();
|
||||||
|
if (result.has_value())
|
||||||
|
emitFailed(result.value());
|
||||||
|
else
|
||||||
|
emitSucceeded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray FlamePackExportTask::generateIndex()
|
||||||
|
{
|
||||||
|
QJsonObject obj;
|
||||||
|
obj["manifestType"] = "minecraftModpack";
|
||||||
|
obj["manifestVersion"] = 1;
|
||||||
|
obj["name"] = name;
|
||||||
|
obj["version"] = version;
|
||||||
|
obj["author"] = author;
|
||||||
|
obj["overrides"] = "overrides";
|
||||||
|
if (mcInstance) {
|
||||||
|
QJsonObject version;
|
||||||
|
auto profile = mcInstance->getPackProfile();
|
||||||
|
// collect all supported components
|
||||||
|
const ComponentPtr minecraft = profile->getComponent("net.minecraft");
|
||||||
|
const ComponentPtr quilt = profile->getComponent("org.quiltmc.quilt-loader");
|
||||||
|
const ComponentPtr fabric = profile->getComponent("net.fabricmc.fabric-loader");
|
||||||
|
const ComponentPtr forge = profile->getComponent("net.minecraftforge");
|
||||||
|
|
||||||
|
// convert all available components to mrpack dependencies
|
||||||
|
if (minecraft != nullptr)
|
||||||
|
version["version"] = minecraft->m_version;
|
||||||
|
QString id;
|
||||||
|
if (quilt != nullptr)
|
||||||
|
id = "quilt-" + quilt->getVersion();
|
||||||
|
else if (fabric != nullptr)
|
||||||
|
id = "fabric-" + fabric->getVersion();
|
||||||
|
else if (forge != nullptr)
|
||||||
|
id = "forge-" + forge->getVersion();
|
||||||
|
version["modLoaders"] = QJsonArray();
|
||||||
|
if (!id.isEmpty()) {
|
||||||
|
QJsonObject loader;
|
||||||
|
loader["id"] = id;
|
||||||
|
loader["primary"] = true;
|
||||||
|
version["modLoaders"] = QJsonArray({ loader });
|
||||||
|
}
|
||||||
|
obj["minecraft"] = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray files;
|
||||||
|
for (auto mod : resolvedFiles) {
|
||||||
|
QJsonObject file;
|
||||||
|
file["projectID"] = mod.addonId;
|
||||||
|
file["fileID"] = mod.version;
|
||||||
|
file["required"] = mod.enabled;
|
||||||
|
files << file;
|
||||||
|
}
|
||||||
|
obj["files"] = files;
|
||||||
|
|
||||||
|
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
||||||
|
}
|
90
launcher/modplatform/flame/FlamePackExportTask.h
Normal file
90
launcher/modplatform/flame/FlamePackExportTask.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
|
||||||
|
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QFuture>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
#include "BaseInstance.h"
|
||||||
|
#include "MMCZip.h"
|
||||||
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "modplatform/flame/FlameAPI.h"
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
|
class FlamePackExportTask : public Task {
|
||||||
|
public:
|
||||||
|
FlamePackExportTask(const QString& name,
|
||||||
|
const QString& version,
|
||||||
|
const QString& author,
|
||||||
|
InstancePtr instance,
|
||||||
|
const QString& output,
|
||||||
|
MMCZip::FilterFunction filter);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void executeTask() override;
|
||||||
|
bool abort() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const QString TEMPLATE;
|
||||||
|
static const QStringList FILE_EXTENSIONS;
|
||||||
|
|
||||||
|
// inputs
|
||||||
|
const QString name, version, author;
|
||||||
|
const InstancePtr instance;
|
||||||
|
MinecraftInstance* mcInstance;
|
||||||
|
const QDir gameRoot;
|
||||||
|
const QString output;
|
||||||
|
const MMCZip::FilterFunction filter;
|
||||||
|
|
||||||
|
typedef std::optional<QString> BuildZipResult;
|
||||||
|
struct ResolvedFile {
|
||||||
|
int addonId;
|
||||||
|
int version;
|
||||||
|
bool enabled;
|
||||||
|
bool isMod;
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QString slug;
|
||||||
|
QString authors;
|
||||||
|
};
|
||||||
|
struct HashInfo {
|
||||||
|
QString name;
|
||||||
|
QString path;
|
||||||
|
bool enabled;
|
||||||
|
bool isMod;
|
||||||
|
};
|
||||||
|
|
||||||
|
FlameAPI api;
|
||||||
|
|
||||||
|
QFileInfoList files;
|
||||||
|
QMap<QString, HashInfo> pendingHashes{};
|
||||||
|
QMap<QString, ResolvedFile> resolvedFiles{};
|
||||||
|
Task::Ptr task;
|
||||||
|
QFuture<BuildZipResult> buildZipFuture;
|
||||||
|
QFutureWatcher<BuildZipResult> buildZipWatcher;
|
||||||
|
|
||||||
|
void collectFiles();
|
||||||
|
void collectHashes();
|
||||||
|
void makeApiRequest();
|
||||||
|
void getProjectsInfo();
|
||||||
|
void buildZip();
|
||||||
|
void finish();
|
||||||
|
|
||||||
|
QByteArray generateIndex();
|
||||||
|
};
|
@ -64,7 +64,8 @@ bool ModrinthPackExportTask::abort()
|
|||||||
|
|
||||||
if (buildZipFuture.isRunning()) {
|
if (buildZipFuture.isRunning()) {
|
||||||
buildZipFuture.cancel();
|
buildZipFuture.cancel();
|
||||||
// NOTE: Here we don't do `emitAborted()` because it will be done when `buildZipFuture` actually cancels, which may not occur immediately.
|
// NOTE: Here we don't do `emitAborted()` because it will be done when `buildZipFuture` actually cancels, which may not occur
|
||||||
|
// immediately.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ void ModrinthPackExportTask::collectFiles()
|
|||||||
|
|
||||||
void ModrinthPackExportTask::collectHashes()
|
void ModrinthPackExportTask::collectHashes()
|
||||||
{
|
{
|
||||||
|
setStatus(tr("Finding file hashes..."));
|
||||||
for (const QFileInfo& file : files) {
|
for (const QFileInfo& file : files) {
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
@ -157,6 +159,7 @@ void ModrinthPackExportTask::makeApiRequest()
|
|||||||
if (pendingHashes.isEmpty())
|
if (pendingHashes.isEmpty())
|
||||||
buildZip();
|
buildZip();
|
||||||
else {
|
else {
|
||||||
|
setStatus(tr("Finding versions for hashes..."));
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
task = api.currentVersions(pendingHashes.values(), "sha512", response);
|
||||||
connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
connect(task.get(), &NetJob::succeeded, [this, response]() { parseApiResponse(response); });
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
#include "ui/dialogs/CopyInstanceDialog.h"
|
#include "ui/dialogs/CopyInstanceDialog.h"
|
||||||
#include "ui/dialogs/EditAccountDialog.h"
|
#include "ui/dialogs/EditAccountDialog.h"
|
||||||
#include "ui/dialogs/ExportInstanceDialog.h"
|
#include "ui/dialogs/ExportInstanceDialog.h"
|
||||||
#include "ui/dialogs/ExportMrPackDialog.h"
|
#include "ui/dialogs/ExportPackDialog.h"
|
||||||
#include "ui/dialogs/ImportResourceDialog.h"
|
#include "ui/dialogs/ImportResourceDialog.h"
|
||||||
#include "ui/themes/ITheme.h"
|
#include "ui/themes/ITheme.h"
|
||||||
#include "ui/themes/ThemeManager.h"
|
#include "ui/themes/ThemeManager.h"
|
||||||
@ -205,6 +205,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
auto exportInstanceMenu = new QMenu(this);
|
auto exportInstanceMenu = new QMenu(this);
|
||||||
exportInstanceMenu->addAction(ui->actionExportInstanceZip);
|
exportInstanceMenu->addAction(ui->actionExportInstanceZip);
|
||||||
exportInstanceMenu->addAction(ui->actionExportInstanceMrPack);
|
exportInstanceMenu->addAction(ui->actionExportInstanceMrPack);
|
||||||
|
exportInstanceMenu->addAction(ui->actionExportInstanceFlamePack);
|
||||||
ui->actionExportInstance->setMenu(exportInstanceMenu);
|
ui->actionExportInstance->setMenu(exportInstanceMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,11 +1406,35 @@ void MainWindow::on_actionExportInstanceMrPack_triggered()
|
|||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
{
|
{
|
||||||
ExportMrPackDialog dlg(m_selectedInstance, this);
|
ExportPackDialog dlg(m_selectedInstance, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionExportInstanceFlamePack_triggered()
|
||||||
|
{
|
||||||
|
if (m_selectedInstance) {
|
||||||
|
auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
|
||||||
|
if (instance) {
|
||||||
|
QString errorMsg;
|
||||||
|
if (instance->getPackProfile()->getComponent("org.quiltmc.quilt-loader")) {
|
||||||
|
errorMsg = tr("Quilt is currently not supported by CurseForge modpacks.");
|
||||||
|
} else if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
|
||||||
|
cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
|
||||||
|
errorMsg = tr("Snapshots are currently not supported by CurseForge modpacks.");
|
||||||
|
}
|
||||||
|
if (!errorMsg.isEmpty()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText(errorMsg);
|
||||||
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ExportPackDialog dlg(m_selectedInstance, this, ModPlatform::ResourceProvider::FLAME);
|
||||||
|
dlg.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionRenameInstance_triggered()
|
void MainWindow::on_actionRenameInstance_triggered()
|
||||||
{
|
{
|
||||||
if (m_selectedInstance)
|
if (m_selectedInstance)
|
||||||
|
@ -157,6 +157,7 @@ private slots:
|
|||||||
inline void on_actionExportInstance_triggered() { on_actionExportInstanceZip_triggered(); }
|
inline void on_actionExportInstance_triggered() { on_actionExportInstanceZip_triggered(); }
|
||||||
void on_actionExportInstanceZip_triggered();
|
void on_actionExportInstanceZip_triggered();
|
||||||
void on_actionExportInstanceMrPack_triggered();
|
void on_actionExportInstanceMrPack_triggered();
|
||||||
|
void on_actionExportInstanceFlamePack_triggered();
|
||||||
|
|
||||||
void on_actionRenameInstance_triggered();
|
void on_actionRenameInstance_triggered();
|
||||||
|
|
||||||
|
@ -479,6 +479,14 @@
|
|||||||
<string>Modrinth (mrpack)</string>
|
<string>Modrinth (mrpack)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionExportInstanceFlamePack">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="flame"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>CurseForge (zip)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionCreateInstanceShortcut">
|
<action name="actionCreateInstanceShortcut">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="shortcut">
|
<iconset theme="shortcut">
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ExportMrPackDialog.h"
|
#include "ExportPackDialog.h"
|
||||||
#include "minecraft/mod/ModFolderModel.h"
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
#include "modplatform/flame/FlamePackExportTask.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
#include "ui_ExportMrPackDialog.h"
|
#include "ui_ExportPackDialog.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
@ -32,17 +34,24 @@
|
|||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "modplatform/modrinth/ModrinthPackExportTask.h"
|
#include "modplatform/modrinth/ModrinthPackExportTask.h"
|
||||||
|
|
||||||
ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
ExportPackDialog::ExportPackDialog(InstancePtr instance, QWidget* parent, ModPlatform::ResourceProvider provider)
|
||||||
: QDialog(parent), instance(instance), ui(new Ui::ExportMrPackDialog)
|
: QDialog(parent), instance(instance), ui(new Ui::ExportPackDialog), m_provider(provider)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->name->setText(instance->name());
|
ui->name->setText(instance->name());
|
||||||
|
if (m_provider == ModPlatform::ResourceProvider::MODRINTH) {
|
||||||
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
||||||
|
setWindowTitle("Export Modrinth Pack");
|
||||||
|
} else {
|
||||||
|
setWindowTitle("Export CurseForge Pack");
|
||||||
|
ui->version->setText("");
|
||||||
|
ui->summaryLabel->setText("Author");
|
||||||
|
}
|
||||||
|
|
||||||
// ensure a valid pack is generated
|
// ensure a valid pack is generated
|
||||||
// the name and version fields mustn't be empty
|
// the name and version fields mustn't be empty
|
||||||
connect(ui->name, &QLineEdit::textEdited, this, &ExportMrPackDialog::validate);
|
connect(ui->name, &QLineEdit::textEdited, this, &ExportPackDialog::validate);
|
||||||
connect(ui->version, &QLineEdit::textEdited, this, &ExportMrPackDialog::validate);
|
connect(ui->version, &QLineEdit::textEdited, this, &ExportPackDialog::validate);
|
||||||
// the instance name can technically be empty
|
// the instance name can technically be empty
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
@ -66,6 +75,7 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
|||||||
|
|
||||||
MinecraftInstance* mcInstance = dynamic_cast<MinecraftInstance*>(instance.get());
|
MinecraftInstance* mcInstance = dynamic_cast<MinecraftInstance*>(instance.get());
|
||||||
if (mcInstance) {
|
if (mcInstance) {
|
||||||
|
mcInstance->loaderModList()->update();
|
||||||
const QDir index = mcInstance->loaderModList()->indexDir();
|
const QDir index = mcInstance->loaderModList()->indexDir();
|
||||||
if (index.exists())
|
if (index.exists())
|
||||||
proxy->blockedPaths().insert(root.relativeFilePath(index.absolutePath()));
|
proxy->blockedPaths().insert(root.relativeFilePath(index.absolutePath()));
|
||||||
@ -83,43 +93,54 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
|||||||
headerView->setSectionResizeMode(0, QHeaderView::Stretch);
|
headerView->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportMrPackDialog::~ExportMrPackDialog()
|
ExportPackDialog::~ExportPackDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportMrPackDialog::done(int result)
|
void ExportPackDialog::done(int result)
|
||||||
{
|
{
|
||||||
if (result == Accepted) {
|
if (result == Accepted) {
|
||||||
const QString filename = FS::RemoveInvalidFilenameChars(ui->name->text());
|
const QString filename = FS::RemoveInvalidFilenameChars(ui->name->text());
|
||||||
const QString output = QFileDialog::getSaveFileName(this, tr("Export %1").arg(ui->name->text()),
|
QString output;
|
||||||
FS::PathCombine(QDir::homePath(), filename + ".mrpack"),
|
if (m_provider == ModPlatform::ResourceProvider::MODRINTH)
|
||||||
"Modrinth pack (*.mrpack *.zip)", nullptr);
|
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())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
Task* task;
|
||||||
ModrinthPackExportTask task(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
|
if (m_provider == ModPlatform::ResourceProvider::MODRINTH)
|
||||||
|
task = new ModrinthPackExportTask(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
|
||||||
|
std::bind(&FileIgnoreProxy::filterFile, proxy, std::placeholders::_1));
|
||||||
|
else
|
||||||
|
task = new FlamePackExportTask(ui->name->text(), ui->version->text(), ui->summary->text(), instance, output,
|
||||||
std::bind(&FileIgnoreProxy::filterFile, proxy, std::placeholders::_1));
|
std::bind(&FileIgnoreProxy::filterFile, proxy, std::placeholders::_1));
|
||||||
|
|
||||||
connect(&task, &Task::failed,
|
connect(task, &Task::failed,
|
||||||
[this](const QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
|
[this](const QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });
|
||||||
connect(&task, &Task::aborted, [this] {
|
connect(task, &Task::aborted, [this] {
|
||||||
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
|
CustomMessageBox::selectable(this, tr("Task aborted"), tr("The task has been aborted by the user."), QMessageBox::Information)
|
||||||
->show();
|
->show();
|
||||||
});
|
});
|
||||||
|
connect(task, &Task::finished, [task] { task->deleteLater(); });
|
||||||
|
|
||||||
ProgressDialog progress(this);
|
ProgressDialog progress(this);
|
||||||
progress.setSkipButton(true, tr("Abort"));
|
progress.setSkipButton(true, tr("Abort"));
|
||||||
if (progress.execWithTask(&task) != QDialog::Accepted)
|
if (progress.execWithTask(task) != QDialog::Accepted)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::done(result);
|
QDialog::done(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportMrPackDialog::validate()
|
void ExportPackDialog::validate()
|
||||||
{
|
{
|
||||||
const bool invalid = ui->name->text().isEmpty() || ui->version->text().isEmpty();
|
const bool invalid =
|
||||||
|
ui->name->text().isEmpty() || ((m_provider == ModPlatform::ResourceProvider::MODRINTH) && ui->version->text().isEmpty());
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(invalid);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(invalid);
|
||||||
}
|
}
|
@ -22,24 +22,28 @@
|
|||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "FastFileIconProvider.h"
|
#include "FastFileIconProvider.h"
|
||||||
#include "FileIgnoreProxy.h"
|
#include "FileIgnoreProxy.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ExportMrPackDialog;
|
class ExportPackDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExportMrPackDialog : public QDialog {
|
class ExportPackDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExportMrPackDialog(InstancePtr instance, QWidget* parent = nullptr);
|
explicit ExportPackDialog(InstancePtr instance,
|
||||||
~ExportMrPackDialog();
|
QWidget* parent = nullptr,
|
||||||
|
ModPlatform::ResourceProvider provider = ModPlatform::ResourceProvider::MODRINTH);
|
||||||
|
~ExportPackDialog();
|
||||||
|
|
||||||
void done(int result) override;
|
void done(int result) override;
|
||||||
void validate();
|
void validate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const InstancePtr instance;
|
const InstancePtr instance;
|
||||||
Ui::ExportMrPackDialog* ui;
|
Ui::ExportPackDialog* ui;
|
||||||
FileIgnoreProxy* proxy;
|
FileIgnoreProxy* proxy;
|
||||||
FastFileIconProvider icons;
|
FastFileIconProvider icons;
|
||||||
|
const ModPlatform::ResourceProvider m_provider;
|
||||||
};
|
};
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ExportMrPackDialog</class>
|
<class>ExportPackDialog</class>
|
||||||
<widget class="QDialog" name="ExportMrPackDialog">
|
<widget class="QDialog" name="ExportPackDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Export Modrinth Pack</string>
|
<string>Export Pack</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeGripEnabled">
|
<property name="sizeGripEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="versionLabel">
|
<widget class="QLabel" name="summaryLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Summary</string>
|
<string>Summary</string>
|
||||||
</property>
|
</property>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="summaryLabel">
|
<widget class="QLabel" name="versionLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Version</string>
|
<string>Version</string>
|
||||||
</property>
|
</property>
|
||||||
@ -57,6 +57,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -103,7 +104,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>ExportMrPackDialog</receiver>
|
<receiver>ExportPackDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -119,7 +120,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>ExportMrPackDialog</receiver>
|
<receiver>ExportPackDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
@ -169,7 +169,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="metadataDisableBtn">
|
<widget class="QCheckBox" name="metadataDisableBtn">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Disable using metadata provided by mod providers (like Modrinth or Curseforge) for mods.</string>
|
<string>Disable using metadata provided by mod providers (like Modrinth or CurseForge) for mods.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Disable using metadata for mods</string>
|
<string>Disable using metadata for mods</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user