mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 05:37:42 +02:00
Revert "Use non-mod metadata in ModrinthPackExportTask"
Out-of-scope Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -522,8 +522,7 @@ QStringList MinecraftInstance::javaArguments()
|
|||||||
|
|
||||||
if (javaVersion.isModular() && shouldApplyOnlineFixes())
|
if (javaVersion.isModular() && shouldApplyOnlineFixes())
|
||||||
// allow reflective access to java.net - required by the skin fix
|
// allow reflective access to java.net - required by the skin fix
|
||||||
args << "--add-opens"
|
args << "--add-opens" << "java.base/java.net=ALL-UNNAMED";
|
||||||
<< "java.base/java.net=ALL-UNNAMED";
|
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@ -797,10 +796,8 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftT
|
|||||||
QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin)
|
QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, MinecraftTarget::Ptr targetToJoin)
|
||||||
{
|
{
|
||||||
QStringList out;
|
QStringList out;
|
||||||
out << "Main Class:"
|
out << "Main Class:" << " " + getMainClass() << "";
|
||||||
<< " " + getMainClass() << "";
|
out << "Native path:" << " " + getNativePath() << "";
|
||||||
out << "Native path:"
|
|
||||||
<< " " + getNativePath() << "";
|
|
||||||
|
|
||||||
auto profile = m_components->getProfile();
|
auto profile = m_components->getProfile();
|
||||||
|
|
||||||
@ -1230,11 +1227,6 @@ std::shared_ptr<ShaderPackFolderModel> MinecraftInstance::shaderPackList()
|
|||||||
return m_shader_pack_list;
|
return m_shader_pack_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<ResourceFolderModel>> MinecraftInstance::resourceLists()
|
|
||||||
{
|
|
||||||
return { loaderModList(), coreModList(), nilModList(), resourcePackList(), texturePackList(), shaderPackList() };
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<WorldList> MinecraftInstance::worldList()
|
std::shared_ptr<WorldList> MinecraftInstance::worldList()
|
||||||
{
|
{
|
||||||
if (!m_world_list) {
|
if (!m_world_list) {
|
||||||
|
@ -116,7 +116,6 @@ class MinecraftInstance : public BaseInstance {
|
|||||||
std::shared_ptr<ResourcePackFolderModel> resourcePackList();
|
std::shared_ptr<ResourcePackFolderModel> resourcePackList();
|
||||||
std::shared_ptr<TexturePackFolderModel> texturePackList();
|
std::shared_ptr<TexturePackFolderModel> texturePackList();
|
||||||
std::shared_ptr<ShaderPackFolderModel> shaderPackList();
|
std::shared_ptr<ShaderPackFolderModel> shaderPackList();
|
||||||
QList<std::shared_ptr<ResourceFolderModel>> resourceLists();
|
|
||||||
std::shared_ptr<WorldList> worldList();
|
std::shared_ptr<WorldList> worldList();
|
||||||
std::shared_ptr<GameOptions> gameOptionsModel();
|
std::shared_ptr<GameOptions> gameOptionsModel();
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
@ -40,23 +39,24 @@
|
|||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
const QString FlamePackExportTask::TEMPLATE = "<li><a href=\"{url}\">{name}{authors}</a></li>\n";
|
const QString FlamePackExportTask::TEMPLATE = "<li><a href=\"{url}\">{name}{authors}</a></li>\n";
|
||||||
const QStringList FlamePackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
const QStringList FlamePackExportTask::FILE_EXTENSIONS({ "jar", "zip" });
|
||||||
|
|
||||||
FlamePackExportTask::FlamePackExportTask(QString name,
|
FlamePackExportTask::FlamePackExportTask(const QString& name,
|
||||||
QString version,
|
const QString& version,
|
||||||
QString author,
|
const QString& author,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
MinecraftInstancePtr instance,
|
InstancePtr instance,
|
||||||
QString output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter)
|
MMCZip::FilterFunction filter)
|
||||||
: name(std::move(name))
|
: name(name)
|
||||||
, version(std::move(version))
|
, version(version)
|
||||||
, author(std::move(author))
|
, author(author)
|
||||||
, optionalFiles(optionalFiles)
|
, optionalFiles(optionalFiles)
|
||||||
, instance(std::move(instance))
|
, instance(instance)
|
||||||
, gameRoot(this->instance->gameRoot())
|
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
||||||
, output(std::move(output))
|
, gameRoot(instance->gameRoot())
|
||||||
, filter(std::move(filter))
|
, output(output)
|
||||||
|
, filter(filter)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void FlamePackExportTask::executeTask()
|
void FlamePackExportTask::executeTask()
|
||||||
@ -90,7 +90,11 @@ void FlamePackExportTask::collectFiles()
|
|||||||
pendingHashes.clear();
|
pendingHashes.clear();
|
||||||
resolvedFiles.clear();
|
resolvedFiles.clear();
|
||||||
|
|
||||||
collectHashes();
|
if (mcInstance != nullptr) {
|
||||||
|
mcInstance->loaderModList()->update();
|
||||||
|
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &FlamePackExportTask::collectHashes);
|
||||||
|
} else
|
||||||
|
collectHashes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlamePackExportTask::collectHashes()
|
void FlamePackExportTask::collectHashes()
|
||||||
@ -98,7 +102,7 @@ void FlamePackExportTask::collectHashes()
|
|||||||
setAbortable(true);
|
setAbortable(true);
|
||||||
setStatus(tr("Finding file hashes..."));
|
setStatus(tr("Finding file hashes..."));
|
||||||
setProgress(1, 5);
|
setProgress(1, 5);
|
||||||
auto allMods = instance->loaderModList()->allMods();
|
auto allMods = mcInstance->loaderModList()->allMods();
|
||||||
ConcurrentTask::Ptr hashingTask(
|
ConcurrentTask::Ptr hashingTask(
|
||||||
new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
||||||
task.reset(hashingTask);
|
task.reset(hashingTask);
|
||||||
@ -375,9 +379,9 @@ QByteArray FlamePackExportTask::generateIndex()
|
|||||||
obj["version"] = version;
|
obj["version"] = version;
|
||||||
obj["author"] = author;
|
obj["author"] = author;
|
||||||
obj["overrides"] = "overrides";
|
obj["overrides"] = "overrides";
|
||||||
if (instance) {
|
if (mcInstance) {
|
||||||
QJsonObject version;
|
QJsonObject version;
|
||||||
auto profile = instance->getPackProfile();
|
auto profile = mcInstance->getPackProfile();
|
||||||
// collect all supported components
|
// collect all supported components
|
||||||
const ComponentPtr minecraft = profile->getComponent("net.minecraft");
|
const ComponentPtr minecraft = profile->getComponent("net.minecraft");
|
||||||
const ComponentPtr quilt = profile->getComponent("org.quiltmc.quilt-loader");
|
const ComponentPtr quilt = profile->getComponent("org.quiltmc.quilt-loader");
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
class FlamePackExportTask : public Task {
|
class FlamePackExportTask : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FlamePackExportTask(QString name,
|
FlamePackExportTask(const QString& name,
|
||||||
QString version,
|
const QString& version,
|
||||||
QString author,
|
const QString& author,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
MinecraftInstancePtr instance,
|
InstancePtr instance,
|
||||||
QString output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter);
|
MMCZip::FilterFunction filter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -47,7 +47,8 @@ class FlamePackExportTask : public Task {
|
|||||||
// inputs
|
// inputs
|
||||||
const QString name, version, author;
|
const QString name, version, author;
|
||||||
const bool optionalFiles;
|
const bool optionalFiles;
|
||||||
const MinecraftInstancePtr instance;
|
const InstancePtr instance;
|
||||||
|
MinecraftInstance* mcInstance;
|
||||||
const QDir gameRoot;
|
const QDir gameRoot;
|
||||||
const QString output;
|
const QString output;
|
||||||
const MMCZip::FilterFunction filter;
|
const MMCZip::FilterFunction filter;
|
||||||
|
@ -115,7 +115,7 @@ QString hash(QIODevice* device, Algorithm type)
|
|||||||
|
|
||||||
QCryptographicHash hash(alg);
|
QCryptographicHash hash(alg);
|
||||||
if (!hash.addData(device))
|
if (!hash.addData(device))
|
||||||
qCritical() << "Failed to read file to create hash!";
|
qCritical() << "Failed to read JAR to create hash!";
|
||||||
|
|
||||||
Q_ASSERT(hash.result().length() == hash.hashLength(alg));
|
Q_ASSERT(hash.result().length() == hash.hashLength(alg));
|
||||||
auto result = hash.result().toHex();
|
auto result = hash.result().toHex();
|
||||||
|
@ -31,23 +31,25 @@
|
|||||||
#include "modplatform/helpers/HashUtils.h"
|
#include "modplatform/helpers/HashUtils.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
|
const QStringList ModrinthPackExportTask::PREFIXES({ "mods/", "coremods/", "resourcepacks/", "texturepacks/", "shaderpacks/" });
|
||||||
const QStringList ModrinthPackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
const QStringList ModrinthPackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
||||||
|
|
||||||
ModrinthPackExportTask::ModrinthPackExportTask(QString name,
|
ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||||
QString version,
|
const QString& version,
|
||||||
QString summary,
|
const QString& summary,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
MinecraftInstancePtr instance,
|
InstancePtr instance,
|
||||||
QString output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter)
|
MMCZip::FilterFunction filter)
|
||||||
: name(std::move(name))
|
: name(name)
|
||||||
, version(std::move(version))
|
, version(version)
|
||||||
, summary(std::move(summary))
|
, summary(summary)
|
||||||
, optionalFiles(optionalFiles)
|
, optionalFiles(optionalFiles)
|
||||||
, instance(std::move(instance))
|
, instance(instance)
|
||||||
, gameRoot(this->instance->gameRoot())
|
, mcInstance(dynamic_cast<MinecraftInstance*>(instance.get()))
|
||||||
, output(std::move(output))
|
, gameRoot(instance->gameRoot())
|
||||||
, filter(std::move(filter))
|
, output(output)
|
||||||
|
, filter(filter)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ModrinthPackExportTask::executeTask()
|
void ModrinthPackExportTask::executeTask()
|
||||||
@ -81,102 +83,64 @@ void ModrinthPackExportTask::collectFiles()
|
|||||||
pendingHashes.clear();
|
pendingHashes.clear();
|
||||||
resolvedFiles.clear();
|
resolvedFiles.clear();
|
||||||
|
|
||||||
collectHashes();
|
if (mcInstance) {
|
||||||
|
mcInstance->loaderModList()->update();
|
||||||
|
connect(mcInstance->loaderModList().get(), &ModFolderModel::updateFinished, this, &ModrinthPackExportTask::collectHashes);
|
||||||
|
} else
|
||||||
|
collectHashes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModrinthPackExportTask::collectHashes()
|
void ModrinthPackExportTask::collectHashes()
|
||||||
{
|
{
|
||||||
// TODO make this just use EnsureMetadataTask
|
|
||||||
|
|
||||||
setStatus(tr("Finding file hashes..."));
|
setStatus(tr("Finding file hashes..."));
|
||||||
|
|
||||||
QStringList prefixes;
|
|
||||||
|
|
||||||
for (const auto& model : instance->resourceLists()) {
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
|
|
||||||
QEventLoop loop;
|
|
||||||
connect(model.get(), &ModFolderModel::updateFinished, &loop, &QEventLoop::quit);
|
|
||||||
model->update();
|
|
||||||
loop.exec();
|
|
||||||
|
|
||||||
prefixes.append(gameRoot.relativeFilePath(model->dir().absolutePath()) + '/');
|
|
||||||
|
|
||||||
for (const Resource* resource : model->allResources()) {
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
|
|
||||||
if (resource->metadata() == nullptr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QUrl& url = resource->metadata()->url;
|
|
||||||
|
|
||||||
if (url.isEmpty() || !BuildConfig.MODRINTH_MRPACK_HOSTS.contains(url.host()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QFileInfo& fileInfo = resource->fileinfo();
|
|
||||||
const QString relativePath = gameRoot.relativeFilePath(fileInfo.absoluteFilePath());
|
|
||||||
|
|
||||||
if (filter(relativePath))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
qDebug() << "Resolving" << relativePath << "from index";
|
|
||||||
|
|
||||||
QString sha1;
|
|
||||||
QString sha512;
|
|
||||||
qint64 size;
|
|
||||||
|
|
||||||
if (resource->metadata()->hash_format == "sha1")
|
|
||||||
sha1 = resource->metadata()->hash;
|
|
||||||
else if (resource->metadata()->hash_format == "sha512")
|
|
||||||
sha512 = resource->metadata()->hash;
|
|
||||||
|
|
||||||
{
|
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly)) {
|
|
||||||
qWarning() << "Could not open" << relativePath << "for hashing";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QByteArray data = file.readAll();
|
|
||||||
|
|
||||||
if (file.error() != QFileDevice::NoError) {
|
|
||||||
qWarning() << "Could not read" << relativePath;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sha1.isEmpty())
|
|
||||||
sha1 = Hashing::hash(data, Hashing::Algorithm::Sha1);
|
|
||||||
|
|
||||||
if (sha512.isEmpty())
|
|
||||||
sha512 = Hashing::hash(data, Hashing::Algorithm::Sha512);
|
|
||||||
|
|
||||||
size = file.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
ResolvedFile resolvedFile{ sha1, sha512, url.toEncoded(), size, resource->metadata()->side };
|
|
||||||
resolvedFiles[relativePath] = resolvedFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const QFileInfo& file : files) {
|
for (const QFileInfo& file : files) {
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||||
|
|
||||||
if (resolvedFiles.contains(relative))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// require sensible file types
|
// require sensible file types
|
||||||
if (!std::any_of(prefixes.begin(), prefixes.end(), [&relative](const QString& prefix) { return relative.startsWith(prefix); }))
|
if (!std::any_of(PREFIXES.begin(), PREFIXES.end(), [&relative](const QString& prefix) { return relative.startsWith(prefix); }))
|
||||||
continue;
|
continue;
|
||||||
if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) {
|
if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) {
|
||||||
return relative.endsWith('.' + extension) || relative.endsWith('.' + extension + ".disabled");
|
return relative.endsWith('.' + extension) || relative.endsWith('.' + extension + ".disabled");
|
||||||
}))
|
}))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
QFile openFile(file.absoluteFilePath());
|
||||||
|
if (!openFile.open(QFile::ReadOnly)) {
|
||||||
|
qWarning() << "Could not open" << file << "for hashing";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray data = openFile.readAll();
|
||||||
|
if (openFile.error() != QFileDevice::NoError) {
|
||||||
|
qWarning() << "Could not read" << file;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto sha512 = Hashing::hash(data, Hashing::Algorithm::Sha512);
|
||||||
|
|
||||||
|
auto allMods = mcInstance->loaderModList()->allMods();
|
||||||
|
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->metadata() != nullptr) {
|
||||||
|
const QUrl& url = mod->metadata()->url;
|
||||||
|
// ensure the url is permitted on modrinth.com
|
||||||
|
if (!url.isEmpty() && BuildConfig.MODRINTH_MRPACK_HOSTS.contains(url.host())) {
|
||||||
|
qDebug() << "Resolving" << relative << "from index";
|
||||||
|
|
||||||
|
auto sha1 = Hashing::hash(data, Hashing::Algorithm::Sha1);
|
||||||
|
|
||||||
|
ResolvedFile resolvedFile{ sha1, sha512, url.toEncoded(), openFile.size(), mod->metadata()->side };
|
||||||
|
resolvedFiles[relative] = resolvedFile;
|
||||||
|
|
||||||
|
// nice! we've managed to resolve based on local metadata!
|
||||||
|
// no need to enqueue it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Enqueueing" << relative << "for Modrinth query";
|
qDebug() << "Enqueueing" << relative << "for Modrinth query";
|
||||||
auto sha512 = Hashing::hash(file.absoluteFilePath(), Hashing::Algorithm::Sha512);
|
|
||||||
pendingHashes[relative] = sha512;
|
pendingHashes[relative] = sha512;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,28 +241,30 @@ QByteArray ModrinthPackExportTask::generateIndex()
|
|||||||
if (!summary.isEmpty())
|
if (!summary.isEmpty())
|
||||||
out["summary"] = summary;
|
out["summary"] = summary;
|
||||||
|
|
||||||
auto profile = instance->getPackProfile();
|
if (mcInstance) {
|
||||||
// collect all supported components
|
auto profile = mcInstance->getPackProfile();
|
||||||
const ComponentPtr minecraft = profile->getComponent("net.minecraft");
|
// collect all supported components
|
||||||
const ComponentPtr quilt = profile->getComponent("org.quiltmc.quilt-loader");
|
const ComponentPtr minecraft = profile->getComponent("net.minecraft");
|
||||||
const ComponentPtr fabric = profile->getComponent("net.fabricmc.fabric-loader");
|
const ComponentPtr quilt = profile->getComponent("org.quiltmc.quilt-loader");
|
||||||
const ComponentPtr forge = profile->getComponent("net.minecraftforge");
|
const ComponentPtr fabric = profile->getComponent("net.fabricmc.fabric-loader");
|
||||||
const ComponentPtr neoForge = profile->getComponent("net.neoforged");
|
const ComponentPtr forge = profile->getComponent("net.minecraftforge");
|
||||||
|
const ComponentPtr neoForge = profile->getComponent("net.neoforged");
|
||||||
|
|
||||||
// convert all available components to mrpack dependencies
|
// convert all available components to mrpack dependencies
|
||||||
QJsonObject dependencies;
|
QJsonObject dependencies;
|
||||||
if (minecraft != nullptr)
|
if (minecraft != nullptr)
|
||||||
dependencies["minecraft"] = minecraft->m_version;
|
dependencies["minecraft"] = minecraft->m_version;
|
||||||
if (quilt != nullptr)
|
if (quilt != nullptr)
|
||||||
dependencies["quilt-loader"] = quilt->m_version;
|
dependencies["quilt-loader"] = quilt->m_version;
|
||||||
if (fabric != nullptr)
|
if (fabric != nullptr)
|
||||||
dependencies["fabric-loader"] = fabric->m_version;
|
dependencies["fabric-loader"] = fabric->m_version;
|
||||||
if (forge != nullptr)
|
if (forge != nullptr)
|
||||||
dependencies["forge"] = forge->m_version;
|
dependencies["forge"] = forge->m_version;
|
||||||
if (neoForge != nullptr)
|
if (neoForge != nullptr)
|
||||||
dependencies["neoforge"] = neoForge->m_version;
|
dependencies["neoforge"] = neoForge->m_version;
|
||||||
|
|
||||||
out["dependencies"] = dependencies;
|
out["dependencies"] = dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonArray filesOut;
|
QJsonArray filesOut;
|
||||||
for (auto iterator = resolvedFiles.constBegin(); iterator != resolvedFiles.constEnd(); iterator++) {
|
for (auto iterator = resolvedFiles.constBegin(); iterator != resolvedFiles.constEnd(); iterator++) {
|
||||||
|
@ -29,12 +29,12 @@
|
|||||||
class ModrinthPackExportTask : public Task {
|
class ModrinthPackExportTask : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ModrinthPackExportTask(QString name,
|
ModrinthPackExportTask(const QString& name,
|
||||||
QString version,
|
const QString& version,
|
||||||
QString summary,
|
const QString& summary,
|
||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
MinecraftInstancePtr instance,
|
InstancePtr instance,
|
||||||
QString output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter);
|
MMCZip::FilterFunction filter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -48,12 +48,14 @@ class ModrinthPackExportTask : public Task {
|
|||||||
Metadata::ModSide side;
|
Metadata::ModSide side;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const QStringList PREFIXES;
|
||||||
static const QStringList FILE_EXTENSIONS;
|
static const QStringList FILE_EXTENSIONS;
|
||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
const QString name, version, summary;
|
const QString name, version, summary;
|
||||||
const bool optionalFiles;
|
const bool optionalFiles;
|
||||||
const MinecraftInstancePtr instance;
|
const InstancePtr instance;
|
||||||
|
MinecraftInstance* mcInstance;
|
||||||
const QDir gameRoot;
|
const QDir gameRoot;
|
||||||
const QString output;
|
const QString output;
|
||||||
const MMCZip::FilterFunction filter;
|
const MMCZip::FilterFunction filter;
|
||||||
|
@ -1403,26 +1403,27 @@ void MainWindow::on_actionExportInstanceZip_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionExportInstanceMrPack_triggered()
|
void MainWindow::on_actionExportInstanceMrPack_triggered()
|
||||||
{
|
{
|
||||||
auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_selectedInstance);
|
if (m_selectedInstance) {
|
||||||
if (instance) {
|
ExportPackDialog dlg(m_selectedInstance, this);
|
||||||
ExportPackDialog dlg(std::move(instance), this);
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionExportInstanceFlamePack_triggered()
|
void MainWindow::on_actionExportInstanceFlamePack_triggered()
|
||||||
{
|
{
|
||||||
auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_selectedInstance);
|
if (m_selectedInstance) {
|
||||||
if (instance) {
|
auto instance = dynamic_cast<MinecraftInstance*>(m_selectedInstance.get());
|
||||||
if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
|
if (instance) {
|
||||||
cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
|
if (auto cmp = instance->getPackProfile()->getComponent("net.minecraft");
|
||||||
QMessageBox msgBox(this);
|
cmp && cmp->getVersionFile() && cmp->getVersionFile()->type == "snapshot") {
|
||||||
msgBox.setText("Snapshots are currently not supported by CurseForge modpacks.");
|
QMessageBox msgBox(this);
|
||||||
msgBox.exec();
|
msgBox.setText("Snapshots are currently not supported by CurseForge modpacks.");
|
||||||
return;
|
msgBox.exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ExportPackDialog dlg(m_selectedInstance, this, ModPlatform::ResourceProvider::FLAME);
|
||||||
|
dlg.exec();
|
||||||
}
|
}
|
||||||
ExportPackDialog dlg(std::move(instance), this, ModPlatform::ResourceProvider::FLAME);
|
|
||||||
dlg.exec();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "modplatform/modrinth/ModrinthPackExportTask.h"
|
#include "modplatform/modrinth/ModrinthPackExportTask.h"
|
||||||
|
|
||||||
ExportPackDialog::ExportPackDialog(const MinecraftInstancePtr& instance, QWidget* parent, ModPlatform::ResourceProvider provider)
|
ExportPackDialog::ExportPackDialog(InstancePtr instance, QWidget* parent, ModPlatform::ResourceProvider provider)
|
||||||
: QDialog(parent), instance(instance), ui(new Ui::ExportPackDialog), m_provider(provider)
|
: QDialog(parent), instance(instance), ui(new Ui::ExportPackDialog), m_provider(provider)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_provider == ModPlatform::ResourceProvider::MODRINTH || m_provider == ModPlatform::ResourceProvider::FLAME);
|
Q_ASSERT(m_provider == ModPlatform::ResourceProvider::MODRINTH || m_provider == ModPlatform::ResourceProvider::FLAME);
|
||||||
@ -86,9 +86,12 @@ ExportPackDialog::ExportPackDialog(const MinecraftInstancePtr& instance, QWidget
|
|||||||
proxy->blockedPaths().insert(file);
|
proxy->blockedPaths().insert(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& resourceModel : instance->resourceLists())
|
MinecraftInstance* mcInstance = dynamic_cast<MinecraftInstance*>(instance.get());
|
||||||
if (resourceModel->indexDir().exists())
|
if (mcInstance) {
|
||||||
proxy->ignoreFilesWithPath().insert(root.relativeFilePath(resourceModel->indexDir().absolutePath()));
|
const QDir index = mcInstance->loaderModList()->indexDir();
|
||||||
|
if (index.exists())
|
||||||
|
proxy->ignoreFilesWithPath().insert(root.relativeFilePath(index.absolutePath()));
|
||||||
|
}
|
||||||
|
|
||||||
ui->files->setModel(proxy);
|
ui->files->setModel(proxy);
|
||||||
ui->files->setRootIndex(proxy->mapFromSource(model->index(instance->gameRoot())));
|
ui->files->setRootIndex(proxy->mapFromSource(model->index(instance->gameRoot())));
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <minecraft/MinecraftInstance.h>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "FastFileIconProvider.h"
|
#include "FastFileIconProvider.h"
|
||||||
@ -33,7 +32,7 @@ class ExportPackDialog : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExportPackDialog(const MinecraftInstancePtr& instance,
|
explicit ExportPackDialog(InstancePtr instance,
|
||||||
QWidget* parent = nullptr,
|
QWidget* parent = nullptr,
|
||||||
ModPlatform::ResourceProvider provider = ModPlatform::ResourceProvider::MODRINTH);
|
ModPlatform::ResourceProvider provider = ModPlatform::ResourceProvider::MODRINTH);
|
||||||
~ExportPackDialog();
|
~ExportPackDialog();
|
||||||
@ -42,7 +41,7 @@ class ExportPackDialog : public QDialog {
|
|||||||
void validate();
|
void validate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const MinecraftInstancePtr instance;
|
const InstancePtr instance;
|
||||||
Ui::ExportPackDialog* ui;
|
Ui::ExportPackDialog* ui;
|
||||||
FileIgnoreProxy* proxy;
|
FileIgnoreProxy* proxy;
|
||||||
FastFileIconProvider icons;
|
FastFileIconProvider icons;
|
||||||
|
Reference in New Issue
Block a user