refactor: move mod tasks to their own subfolder

Makes the launcher/minecraft/mod/ folder a little more organized.
This commit is contained in:
flow
2022-04-15 20:35:17 -03:00
committed by flow
parent fcfb2cfc3d
commit 5a34e8fd7c
11 changed files with 34 additions and 27 deletions

View File

@ -0,0 +1,35 @@
#include "ModFolderLoadTask.h"
#include <QDebug>
#include "modplatform/packwiz/Packwiz.h"
ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir) :
m_mods_dir(mods_dir), m_index_dir(index_dir), m_result(new Result())
{
}
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, Packwiz::getIndexForMod(m_index_dir, entry));
m_result->mods[mod.mmc_id()] = mod;
}
// Read JAR files that don't have metadata
m_mods_dir.refresh();
for (auto entry : m_mods_dir.entryInfoList())
{
Mod mod(entry);
if(!m_result->mods.contains(mod.mmc_id()))
m_result->mods[mod.mmc_id()] = mod;
}
emit succeeded();
}