2022-03-03 05:47:10 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2022-03-06 23:53:00 +05:30
|
|
|
#include "Application.h"
|
2022-03-03 07:31:23 +05:30
|
|
|
#include "modplatform/ModAPI.h"
|
2022-03-03 05:47:10 +05:30
|
|
|
#include "modplatform/ModIndex.h"
|
|
|
|
#include "ui/pages/BasePage.h"
|
|
|
|
#include "ui/pages/modplatform/ModModel.h"
|
|
|
|
|
|
|
|
class ModDownloadDialog;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ModPage;
|
|
|
|
}
|
|
|
|
|
2022-03-06 22:24:05 +05:30
|
|
|
/* This page handles most logic related to browsing and selecting mods to download.
|
|
|
|
* By default, the methods provided work with net requests, to fetch data from remote APIs. */
|
2022-03-03 05:47:10 +05:30
|
|
|
class ModPage : public QWidget, public BasePage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-03-06 22:24:05 +05:30
|
|
|
explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api);
|
2022-03-03 05:47:10 +05:30
|
|
|
virtual ~ModPage();
|
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
/* Affects what the user sees */
|
2022-03-03 08:36:37 +05:30
|
|
|
virtual QString displayName() const override = 0;
|
|
|
|
virtual QIcon icon() const override = 0;
|
|
|
|
virtual QString id() const override = 0;
|
|
|
|
virtual QString helpPage() const override = 0;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
/* Used internally */
|
2022-03-03 08:36:37 +05:30
|
|
|
virtual QString metaEntryBase() const = 0;
|
2022-03-06 22:24:05 +05:30
|
|
|
virtual QString debugName() const = 0;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
|
2022-03-03 05:47:10 +05:30
|
|
|
virtual bool shouldDisplay() const override = 0;
|
2022-03-08 03:59:59 +05:30
|
|
|
virtual bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const = 0;
|
|
|
|
|
2022-03-06 22:24:05 +05:30
|
|
|
const ModAPI* apiProvider() const { return api.get(); };
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-08 03:59:59 +05:30
|
|
|
ModPlatform::IndexedPack& getCurrent() { return current; }
|
|
|
|
void updateModVersions();
|
2022-03-06 23:53:00 +05:30
|
|
|
|
2022-03-03 05:47:10 +05:30
|
|
|
void openedImpl() override;
|
|
|
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
|
|
|
|
BaseInstance* m_instance;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateSelectionButton();
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void triggerSearch();
|
|
|
|
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
|
|
|
void onVersionSelectionChanged(QString data);
|
|
|
|
void onModSelected();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Ui::ModPage* ui = nullptr;
|
|
|
|
ModDownloadDialog* dialog = nullptr;
|
|
|
|
ModPlatform::ListModel* listModel = nullptr;
|
|
|
|
ModPlatform::IndexedPack current;
|
|
|
|
|
2022-03-06 22:24:05 +05:30
|
|
|
std::unique_ptr<ModAPI> api;
|
|
|
|
|
2022-03-03 05:47:10 +05:30
|
|
|
int selectedVersion = -1;
|
|
|
|
};
|