2022-06-04 01:26:26 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "minecraft/mod/Mod.h"
|
2023-06-24 19:48:12 +01:00
|
|
|
#include "minecraft/mod/tasks/GetModDependenciesTask.h"
|
2022-06-04 01:26:26 +01:00
|
|
|
#include "modplatform/ModIndex.h"
|
2023-06-24 19:48:12 +01:00
|
|
|
#include "modplatform/ResourceAPI.h"
|
2022-06-04 01:26:26 +01:00
|
|
|
#include "tasks/Task.h"
|
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
class ResourceDownloadTask;
|
2022-06-04 01:26:26 +01:00
|
|
|
class ModFolderModel;
|
|
|
|
|
|
|
|
class CheckUpdateTask : public Task {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-06-24 19:48:12 +01:00
|
|
|
CheckUpdateTask(QList<Mod*>& mods,
|
|
|
|
std::list<Version>& mcVersions,
|
|
|
|
std::optional<ResourceAPI::ModLoaderTypes> loaders,
|
|
|
|
std::shared_ptr<ModFolderModel> mods_folder)
|
|
|
|
: Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder){};
|
2022-06-04 01:26:26 +01:00
|
|
|
|
|
|
|
struct UpdatableMod {
|
|
|
|
QString name;
|
|
|
|
QString old_hash;
|
|
|
|
QString old_version;
|
|
|
|
QString new_version;
|
|
|
|
QString changelog;
|
2022-11-25 12:23:46 +00:00
|
|
|
ModPlatform::ResourceProvider provider;
|
2023-01-24 19:52:09 +00:00
|
|
|
shared_qobject_ptr<ResourceDownloadTask> download;
|
2022-06-04 01:26:26 +01:00
|
|
|
|
|
|
|
public:
|
2023-06-24 19:48:12 +01:00
|
|
|
UpdatableMod(QString name,
|
|
|
|
QString old_h,
|
|
|
|
QString old_v,
|
|
|
|
QString new_v,
|
|
|
|
QString changelog,
|
|
|
|
ModPlatform::ResourceProvider p,
|
|
|
|
shared_qobject_ptr<ResourceDownloadTask> t)
|
2022-06-04 01:26:26 +01:00
|
|
|
: name(name), old_hash(old_h), old_version(old_v), new_version(new_v), changelog(changelog), provider(p), download(t)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
auto getUpdatable() -> std::vector<UpdatableMod>&& { return std::move(m_updatable); }
|
2023-06-24 19:48:12 +01:00
|
|
|
auto getDependencies() -> QList<std::shared_ptr<GetModDependenciesTask::PackDependency>>&& { return std::move(m_deps); }
|
2022-06-04 01:26:26 +01:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
bool abort() override = 0;
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void executeTask() override = 0;
|
|
|
|
|
|
|
|
signals:
|
2022-06-26 18:17:15 +01:00
|
|
|
void checkFailed(Mod* failed, QString reason, QUrl recover_url = {});
|
2022-06-04 01:26:26 +01:00
|
|
|
|
|
|
|
protected:
|
2022-07-10 19:15:25 +01:00
|
|
|
QList<Mod*>& m_mods;
|
2022-06-04 01:26:26 +01:00
|
|
|
std::list<Version>& m_game_versions;
|
2022-11-25 12:23:46 +00:00
|
|
|
std::optional<ResourceAPI::ModLoaderTypes> m_loaders;
|
2022-06-04 01:26:26 +01:00
|
|
|
std::shared_ptr<ModFolderModel> m_mods_folder;
|
|
|
|
|
|
|
|
std::vector<UpdatableMod> m_updatable;
|
2023-06-24 19:48:12 +01:00
|
|
|
QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> m_deps;
|
2022-06-04 01:26:26 +01:00
|
|
|
};
|