feat: add very early mod.toml packwiz support
Also use it as a on-disk format for storing mod metadata. This will be used later on to make better mod managment.
This commit is contained in:
32
launcher/minecraft/mod/LocalModUpdateTask.cpp
Normal file
32
launcher/minecraft/mod/LocalModUpdateTask.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "LocalModUpdateTask.h"
|
||||
|
||||
#include <toml.h>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "modplatform/packwiz/Packwiz.h"
|
||||
|
||||
LocalModUpdateTask::LocalModUpdateTask(QDir mods_dir, ModPlatform::IndexedPack& mod, ModPlatform::IndexedVersion& mod_version)
|
||||
: m_mod(mod), m_mod_version(mod_version)
|
||||
{
|
||||
// Ensure a '.index' folder exists in the mods folder, and create it if it does not
|
||||
m_index_dir = { QString("%1/.index").arg(mods_dir.absolutePath()) };
|
||||
if (!FS::ensureFolderPathExists(m_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;
|
||||
}
|
26
launcher/minecraft/mod/LocalModUpdateTask.h
Normal file
26
launcher/minecraft/mod/LocalModUpdateTask.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#include "tasks/Task.h"
|
||||
#include "modplatform/ModIndex.h"
|
||||
|
||||
class LocalModUpdateTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<LocalModUpdateTask>;
|
||||
|
||||
explicit LocalModUpdateTask(QDir mods_dir, ModPlatform::IndexedPack& mod, ModPlatform::IndexedVersion& mod_version);
|
||||
|
||||
bool canAbort() const override { return true; }
|
||||
bool abort() override;
|
||||
|
||||
protected slots:
|
||||
//! Entry point for tasks.
|
||||
void executeTask() override;
|
||||
|
||||
private:
|
||||
QDir m_index_dir;
|
||||
ModPlatform::IndexedPack& m_mod;
|
||||
ModPlatform::IndexedVersion& m_mod_version;
|
||||
};
|
Reference in New Issue
Block a user