2022-06-04 20:22:46 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BaseInstance.h"
|
2022-11-25 12:23:46 +00:00
|
|
|
#include "ResourceDownloadTask.h"
|
2022-06-04 20:22:46 +01:00
|
|
|
#include "ReviewMessageBox.h"
|
|
|
|
|
|
|
|
#include "minecraft/mod/ModFolderModel.h"
|
|
|
|
|
|
|
|
#include "modplatform/CheckUpdateTask.h"
|
|
|
|
|
|
|
|
class Mod;
|
|
|
|
class ModrinthCheckUpdate;
|
|
|
|
class FlameCheckUpdate;
|
2022-07-01 20:17:05 +01:00
|
|
|
class ConcurrentTask;
|
2022-06-04 20:22:46 +01:00
|
|
|
|
|
|
|
class ModUpdateDialog final : public ReviewMessageBox {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ModUpdateDialog(QWidget* parent,
|
|
|
|
BaseInstance* instance,
|
2022-06-16 15:45:29 +01:00
|
|
|
const std::shared_ptr<ModFolderModel> mod_model,
|
2022-08-11 22:24:26 +01:00
|
|
|
QList<Mod*>& search_for);
|
2022-06-04 20:22:46 +01:00
|
|
|
|
|
|
|
void checkCandidates();
|
|
|
|
|
|
|
|
void appendMod(const CheckUpdateTask::UpdatableMod& info);
|
|
|
|
|
2023-01-24 19:52:09 +00:00
|
|
|
const QList<ResourceDownloadTask::Ptr> getTasks();
|
2022-06-04 20:22:46 +01:00
|
|
|
auto indexDir() const -> QDir { return m_mod_model->indexDir(); }
|
|
|
|
|
|
|
|
auto noUpdates() const -> bool { return m_no_updates; };
|
|
|
|
auto aborted() const -> bool { return m_aborted; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
auto ensureMetadata() -> bool;
|
|
|
|
|
|
|
|
private slots:
|
2022-06-26 18:17:15 +01:00
|
|
|
void onMetadataEnsured(Mod*);
|
2023-08-02 17:35:35 +01:00
|
|
|
void onMetadataFailed(Mod*,
|
|
|
|
bool try_others = false,
|
|
|
|
ModPlatform::ResourceProvider first_choice = ModPlatform::ResourceProvider::MODRINTH);
|
2022-06-04 20:22:46 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget* m_parent;
|
|
|
|
|
2023-01-24 19:52:09 +00:00
|
|
|
shared_qobject_ptr<ModrinthCheckUpdate> m_modrinth_check_task;
|
|
|
|
shared_qobject_ptr<FlameCheckUpdate> m_flame_check_task;
|
2022-06-04 20:22:46 +01:00
|
|
|
|
2022-06-16 15:45:29 +01:00
|
|
|
const std::shared_ptr<ModFolderModel> m_mod_model;
|
2022-06-04 20:22:46 +01:00
|
|
|
|
2022-08-11 22:24:26 +01:00
|
|
|
QList<Mod*>& m_candidates;
|
2022-07-10 19:15:25 +01:00
|
|
|
QList<Mod*> m_modrinth_to_update;
|
|
|
|
QList<Mod*> m_flame_to_update;
|
2022-06-04 20:22:46 +01:00
|
|
|
|
2023-01-24 19:52:09 +00:00
|
|
|
ConcurrentTask::Ptr m_second_try_metadata;
|
2022-07-10 19:15:25 +01:00
|
|
|
QList<std::tuple<Mod*, QString>> m_failed_metadata;
|
|
|
|
QList<std::tuple<Mod*, QString, QUrl>> m_failed_check_update;
|
2022-06-04 20:22:46 +01:00
|
|
|
|
2023-01-24 19:52:09 +00:00
|
|
|
QHash<QString, ResourceDownloadTask::Ptr> m_tasks;
|
2022-06-04 20:22:46 +01:00
|
|
|
BaseInstance* m_instance;
|
|
|
|
|
|
|
|
bool m_no_updates = false;
|
|
|
|
bool m_aborted = false;
|
|
|
|
};
|