2019-08-04 06:57:53 +05:30
|
|
|
#pragma once
|
2022-04-16 05:05:17 +05:30
|
|
|
|
2019-08-04 06:57:53 +05:30
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
2022-04-16 05:05:17 +05:30
|
|
|
|
|
|
|
#include "minecraft/mod/Mod.h"
|
|
|
|
#include "minecraft/mod/ModDetails.h"
|
2019-08-04 06:57:53 +05:30
|
|
|
|
refactor: move general code from mod model to its own model
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>
2022-08-09 10:28:22 +05:30
|
|
|
#include "tasks/Task.h"
|
|
|
|
|
2022-12-10 13:22:50 +05:30
|
|
|
namespace ModUtils {
|
|
|
|
|
|
|
|
ModDetails ReadFabricModInfo(QByteArray contents);
|
|
|
|
ModDetails ReadQuiltModInfo(QByteArray contents);
|
|
|
|
ModDetails ReadForgeInfo(QByteArray contents);
|
|
|
|
ModDetails ReadLiteModInfo(QByteArray contents);
|
|
|
|
|
|
|
|
enum class ProcessingLevel { Full, BasicInfoOnly };
|
|
|
|
|
|
|
|
bool process(Mod& mod, ProcessingLevel level = ProcessingLevel::Full);
|
|
|
|
|
|
|
|
bool processZIP(Mod& mod, ProcessingLevel level = ProcessingLevel::Full);
|
|
|
|
bool processFolder(Mod& mod, ProcessingLevel level = ProcessingLevel::Full);
|
|
|
|
bool processLitemod(Mod& mod, ProcessingLevel level = ProcessingLevel::Full);
|
|
|
|
|
|
|
|
/** Checks whether a file is valid as a mod or not. */
|
|
|
|
bool validate(QFileInfo file);
|
|
|
|
} // namespace ModUtils
|
|
|
|
|
2022-12-27 02:59:13 +05:30
|
|
|
class LocalModParseTask : public Task {
|
2019-08-04 06:57:53 +05:30
|
|
|
Q_OBJECT
|
2022-12-27 02:59:13 +05:30
|
|
|
public:
|
2019-08-04 06:57:53 +05:30
|
|
|
struct Result {
|
2022-08-13 01:36:20 +05:30
|
|
|
ModDetails details;
|
2019-08-04 06:57:53 +05:30
|
|
|
};
|
|
|
|
using ResultPtr = std::shared_ptr<Result>;
|
2022-12-27 02:59:13 +05:30
|
|
|
ResultPtr result() const { return m_result; }
|
2019-08-04 06:57:53 +05:30
|
|
|
|
2022-08-13 01:39:56 +05:30
|
|
|
[[nodiscard]] bool canAbort() const override { return true; }
|
|
|
|
bool abort() override;
|
|
|
|
|
2022-12-27 02:59:13 +05:30
|
|
|
LocalModParseTask(int token, ResourceType type, const QFileInfo& modFile);
|
refactor: move general code from mod model to its own model
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>
2022-08-09 10:28:22 +05:30
|
|
|
void executeTask() override;
|
2019-08-04 06:57:53 +05:30
|
|
|
|
refactor: move general code from mod model to its own model
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>
2022-08-09 10:28:22 +05:30
|
|
|
[[nodiscard]] int token() const { return m_token; }
|
2019-08-04 06:57:53 +05:30
|
|
|
|
2022-12-27 02:59:13 +05:30
|
|
|
private:
|
2019-08-04 06:57:53 +05:30
|
|
|
void processAsZip();
|
|
|
|
void processAsFolder();
|
|
|
|
void processAsLitemod();
|
|
|
|
|
2022-12-27 02:59:13 +05:30
|
|
|
private:
|
2019-08-04 06:57:53 +05:30
|
|
|
int m_token;
|
refactor: move general code from mod model to its own model
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>
2022-08-09 10:28:22 +05:30
|
|
|
ResourceType m_type;
|
2019-08-04 06:57:53 +05:30
|
|
|
QFileInfo m_modFile;
|
|
|
|
ResultPtr m_result;
|
2022-08-13 01:39:56 +05:30
|
|
|
|
2022-09-03 21:55:05 +05:30
|
|
|
std::atomic<bool> m_aborted = false;
|
2019-08-04 06:57:53 +05:30
|
|
|
};
|