Refactor updating mechanisms to work with all resources

Summary:
- It compiles
- I need to go to bed

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2024-01-26 02:53:30 +00:00
parent 2c18d0f1a5
commit 97ee0a19b5
18 changed files with 298 additions and 293 deletions

View File

@ -13,13 +13,13 @@ class CheckUpdateTask : public Task {
Q_OBJECT
public:
CheckUpdateTask(QList<Mod*>& mods,
CheckUpdateTask(QList<Resource*>& resources,
std::list<Version>& mcVersions,
std::optional<ModPlatform::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){};
std::shared_ptr<ResourceFolderModel> resource_model)
: Task(nullptr), m_resources(resources), m_game_versions(mcVersions), m_loaders(loaders), m_resource_model(resource_model){};
struct UpdatableMod {
struct Update {
QString name;
QString old_hash;
QString old_version;
@ -30,14 +30,14 @@ class CheckUpdateTask : public Task {
shared_qobject_ptr<ResourceDownloadTask> download;
public:
UpdatableMod(QString name,
QString old_h,
QString old_v,
QString new_v,
std::optional<ModPlatform::IndexedVersionType> new_v_type,
QString changelog,
ModPlatform::ResourceProvider p,
shared_qobject_ptr<ResourceDownloadTask> t)
Update(QString name,
QString old_h,
QString old_v,
QString new_v,
std::optional<ModPlatform::IndexedVersionType> new_v_type,
QString changelog,
ModPlatform::ResourceProvider p,
shared_qobject_ptr<ResourceDownloadTask> t)
: name(name)
, old_hash(old_h)
, old_version(old_v)
@ -49,7 +49,7 @@ class CheckUpdateTask : public Task {
{}
};
auto getUpdatable() -> std::vector<UpdatableMod>&& { return std::move(m_updatable); }
auto getUpdates() -> std::vector<Update>&& { return std::move(m_updates); }
auto getDependencies() -> QList<std::shared_ptr<GetModDependenciesTask::PackDependency>>&& { return std::move(m_deps); }
public slots:
@ -59,14 +59,14 @@ class CheckUpdateTask : public Task {
void executeTask() override = 0;
signals:
void checkFailed(Mod* failed, QString reason, QUrl recover_url = {});
void checkFailed(Resource* failed, QString reason, QUrl recover_url = {});
protected:
QList<Mod*>& m_mods;
QList<Resource*>& m_resources;
std::list<Version>& m_game_versions;
std::optional<ModPlatform::ModLoaderTypes> m_loaders;
std::shared_ptr<ModFolderModel> m_mods_folder;
std::shared_ptr<ResourceFolderModel> m_resource_model;
std::vector<UpdatableMod> m_updatable;
std::vector<Update> m_updates;
QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> m_deps;
};