feat: allow disabling mod metadata usage

This commit is contained in:
flow
2022-04-17 10:19:23 -03:00
committed by flow
parent 23febc6d94
commit 4439666e67
8 changed files with 107 additions and 40 deletions

View File

@ -1,6 +1,7 @@
#include "ModFolderLoadTask.h"
#include <QDebug>
#include "Application.h"
#include "minecraft/mod/MetadataHandler.h"
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
@ -9,16 +10,9 @@ ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir)
void ModFolderLoadTask::run()
{
// Read metadata first
m_index_dir.refresh();
for (auto entry : m_index_dir.entryList()) {
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
if (entry == "." || entry == "..")
continue;
entry.chop(5); // Remove .toml at the end
Mod mod(m_mods_dir, Metadata::get(m_index_dir, entry));
m_result->mods[mod.internal_id()] = mod;
if (!APPLICATION->settings()->get("DontUseModMetadata").toBool()) {
// Read metadata first
getFromMetadata();
}
// Read JAR files that don't have metadata
@ -31,3 +25,17 @@ void ModFolderLoadTask::run()
emit succeeded();
}
void ModFolderLoadTask::getFromMetadata()
{
m_index_dir.refresh();
for (auto entry : m_index_dir.entryList()) {
// QDir::Filter::NoDotAndDotDot seems to exclude all files for some reason...
if (entry == "." || entry == "..")
continue;
entry.chop(5); // Remove .toml at the end
Mod mod(m_mods_dir, Metadata::get(m_index_dir, entry));
m_result->mods[mod.internal_id()] = mod;
}
}