Made it more similar to mrpack export
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
fd5b155ee7
commit
d1603f1945
@ -37,6 +37,8 @@
|
||||
#include "tasks/Task.h"
|
||||
|
||||
const QString FlamePackExportTask::TEMPLATE = "<li><a href={url}>{name}{authors}</a></li>\n";
|
||||
const QStringList FlamePackExportTask::PREFIXES({ "mods/", "resourcepacks/" });
|
||||
const QStringList FlamePackExportTask::FILE_EXTENSIONS({ "jar", "zip" });
|
||||
|
||||
FlamePackExportTask::FlamePackExportTask(const QString& name,
|
||||
const QString& version,
|
||||
@ -105,12 +107,40 @@ void FlamePackExportTask::collectHashes()
|
||||
{
|
||||
setAbortable(true);
|
||||
setStatus(tr("Find file hashes..."));
|
||||
auto mods = mcInstance->loaderModList()->allMods();
|
||||
auto allMods = mcInstance->loaderModList()->allMods();
|
||||
ConcurrentTask::Ptr hashing_task(new ConcurrentTask(this, "MakeHashesTask", 10));
|
||||
task.reset(hashing_task);
|
||||
int totalProgres = mods.count();
|
||||
int totalProgres = allMods.count();
|
||||
setProgress(0, totalProgres);
|
||||
for (auto* mod : mods) {
|
||||
|
||||
for (const QFileInfo& file : files) {
|
||||
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||
// require sensible file types
|
||||
if (!std::any_of(PREFIXES.begin(), PREFIXES.end(), [&relative](const QString& prefix) { return relative.startsWith(prefix); }))
|
||||
continue;
|
||||
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
|
||||
totalProgres++;
|
||||
auto hash_task = Hashing::createFlameHasher(file.absoluteFilePath());
|
||||
connect(hash_task.get(), &Hashing::Hasher::resultsReady, [this, relative, file, totalProgres](QString hash) {
|
||||
if (m_state == Task::State::Running) {
|
||||
setProgress(m_progress + 1, totalProgres);
|
||||
pendingHashes.insert(hash, { relative, file.absoluteFilePath(), relative.endsWith(".zip") });
|
||||
}
|
||||
});
|
||||
connect(hash_task.get(), &Task::failed, this, &FlamePackExportTask::emitFailed);
|
||||
hashing_task->addTask(hash_task);
|
||||
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) {
|
||||
setProgress(m_progress + 1, totalProgres);
|
||||
continue;
|
||||
@ -133,6 +163,7 @@ void FlamePackExportTask::collectHashes()
|
||||
connect(hash_task.get(), &Task::failed, this, &FlamePackExportTask::emitFailed);
|
||||
hashing_task->addTask(hash_task);
|
||||
}
|
||||
}
|
||||
|
||||
for (const QFileInfo& file : files) {
|
||||
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||
|
@ -42,6 +42,8 @@ class FlamePackExportTask : public Task {
|
||||
|
||||
private:
|
||||
static const QString TEMPLATE;
|
||||
static const QStringList PREFIXES;
|
||||
static const QStringList FILE_EXTENSIONS;
|
||||
|
||||
// inputs
|
||||
const QString name, version, author;
|
||||
|
Loading…
x
Reference in New Issue
Block a user