2019-08-04 02:27:53 +01:00
|
|
|
#pragma once
|
2022-04-16 00:35:17 +01:00
|
|
|
|
2019-08-04 02:27:53 +01:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QObject>
|
2022-04-16 00:35:17 +01:00
|
|
|
|
|
|
|
#include "minecraft/mod/Mod.h"
|
|
|
|
#include "minecraft/mod/ModDetails.h"
|
2019-08-04 02:27:53 +01:00
|
|
|
|
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 05:58:22 +01:00
|
|
|
#include "tasks/Task.h"
|
|
|
|
|
|
|
|
class LocalModParseTask : public Task
|
2019-08-04 02:27:53 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
struct Result {
|
2022-08-12 21:06:20 +01:00
|
|
|
ModDetails details;
|
2019-08-04 02:27:53 +01:00
|
|
|
};
|
|
|
|
using ResultPtr = std::shared_ptr<Result>;
|
|
|
|
ResultPtr result() const {
|
|
|
|
return m_result;
|
|
|
|
}
|
|
|
|
|
2022-08-12 21:09:56 +01:00
|
|
|
[[nodiscard]] bool canAbort() const override { return true; }
|
|
|
|
bool abort() override;
|
|
|
|
|
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 05:58:22 +01:00
|
|
|
LocalModParseTask(int token, ResourceType type, const QFileInfo & modFile);
|
|
|
|
void executeTask() override;
|
2019-08-04 02:27:53 +01:00
|
|
|
|
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 05:58:22 +01:00
|
|
|
[[nodiscard]] int token() const { return m_token; }
|
2019-08-04 02:27:53 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
void processAsZip();
|
|
|
|
void processAsFolder();
|
|
|
|
void processAsLitemod();
|
|
|
|
|
|
|
|
private:
|
|
|
|
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 05:58:22 +01:00
|
|
|
ResourceType m_type;
|
2019-08-04 02:27:53 +01:00
|
|
|
QFileInfo m_modFile;
|
|
|
|
ResultPtr m_result;
|
2022-08-12 21:09:56 +01:00
|
|
|
|
|
|
|
bool m_aborted = false;
|
2019-08-04 02:27:53 +01:00
|
|
|
};
|