feat: add mod update dialog
This subclasses the Review mods dialog to make a "Update review" one. Also, all the necessary components built until now are put together in a coherent unity that checks and generates metadata on-the-fly and checks for mod updates, while giving and receiving feedback to the user. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
61
launcher/ui/dialogs/ModUpdateDialog.h
Normal file
61
launcher/ui/dialogs/ModUpdateDialog.h
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseInstance.h"
|
||||
#include "ModDownloadTask.h"
|
||||
#include "ReviewMessageBox.h"
|
||||
|
||||
#include "minecraft/mod/ModFolderModel.h"
|
||||
|
||||
#include "modplatform/CheckUpdateTask.h"
|
||||
|
||||
class Mod;
|
||||
class ModrinthCheckUpdate;
|
||||
class FlameCheckUpdate;
|
||||
|
||||
class ModUpdateDialog final : public ReviewMessageBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ModUpdateDialog(QWidget* parent,
|
||||
BaseInstance* instance,
|
||||
const std::shared_ptr<ModFolderModel>& mod_model,
|
||||
std::list<Mod>& search_for);
|
||||
|
||||
void checkCandidates();
|
||||
|
||||
void appendMod(const CheckUpdateTask::UpdatableMod& info);
|
||||
|
||||
const std::list<ModDownloadTask*> getTasks();
|
||||
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:
|
||||
void onMetadataEnsured(Mod&);
|
||||
void onMetadataFailed(Mod&);
|
||||
|
||||
private:
|
||||
QWidget* m_parent;
|
||||
|
||||
SequentialTask m_check_task;
|
||||
ModrinthCheckUpdate* m_modrinth_check_task = nullptr;
|
||||
FlameCheckUpdate* m_flame_check_task = nullptr;
|
||||
|
||||
const std::shared_ptr<ModFolderModel>& m_mod_model;
|
||||
|
||||
std::list<Mod>& m_candidates;
|
||||
std::list<Mod> m_modrinth_to_update;
|
||||
std::list<Mod> m_flame_to_update;
|
||||
|
||||
std::list<Mod> m_failed_metadata;
|
||||
std::list<std::tuple<Mod, QString, QUrl>> m_failed_check_update;
|
||||
|
||||
QHash<QString, ModDownloadTask*> m_tasks;
|
||||
BaseInstance* m_instance;
|
||||
|
||||
bool m_no_updates = false;
|
||||
bool m_aborted = false;
|
||||
};
|
Reference in New Issue
Block a user