diff options
author | flow <thiagodonato300@gmail.com> | 2022-04-15 20:35:17 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-05-23 14:42:27 -0300 |
commit | 5a34e8fd7c913bc138e1606baf9df2cd1a64baed (patch) | |
tree | 58fd00b20d6ee407a47067b16f3c5088825dd1a9 /launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp | |
parent | fcfb2cfc3da9a8f897063db05fdf3aebc41a59ae (diff) | |
download | PrismLauncher-5a34e8fd7c913bc138e1606baf9df2cd1a64baed.tar.gz PrismLauncher-5a34e8fd7c913bc138e1606baf9df2cd1a64baed.tar.bz2 PrismLauncher-5a34e8fd7c913bc138e1606baf9df2cd1a64baed.zip |
refactor: move mod tasks to their own subfolder
Makes the launcher/minecraft/mod/ folder a little more organized.
Diffstat (limited to 'launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp')
-rw-r--r-- | launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp new file mode 100644 index 00000000..63f5cf9a --- /dev/null +++ b/launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp @@ -0,0 +1,31 @@ +#include "LocalModUpdateTask.h" + +#include <toml.h> + +#include "FileSystem.h" +#include "modplatform/packwiz/Packwiz.h" + +LocalModUpdateTask::LocalModUpdateTask(QDir index_dir, ModPlatform::IndexedPack& mod, ModPlatform::IndexedVersion& mod_version) + : m_index_dir(index_dir), m_mod(mod), m_mod_version(mod_version) +{ + // Ensure a '.index' folder exists in the mods folder, and create it if it does not + if (!FS::ensureFolderPathExists(index_dir.path())) { + emitFailed(QString("Unable to create index for mod %1!").arg(m_mod.name)); + } +} + +void LocalModUpdateTask::executeTask() +{ + setStatus(tr("Updating index for mod:\n%1").arg(m_mod.name)); + + auto pw_mod = Packwiz::createModFormat(m_index_dir, m_mod, m_mod_version); + Packwiz::updateModIndex(m_index_dir, pw_mod); + + emitSucceeded(); +} + +bool LocalModUpdateTask::abort() +{ + emitAborted(); + return true; +} |