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"
|
2022-04-14 18:57:03 +05:30
|
|
|
#include "ui/widgets/ModFilterWidget.h"
|
2022-03-03 05:47:10 +05:30
|
|
|
|
|
|
|
class ModDownloadDialog;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ModPage;
|
|
|
|
}
|
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
/* This page handles most logic related to browsing and selecting mods to download. */
|
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-08 19:42:35 +05:30
|
|
|
~ModPage() override;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
/* Affects what the user sees */
|
2022-03-08 19:42:35 +05:30
|
|
|
auto displayName() const -> QString override = 0;
|
|
|
|
auto icon() const -> QIcon override = 0;
|
|
|
|
auto id() const -> QString override = 0;
|
|
|
|
auto helpPage() const -> QString override = 0;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
/* Used internally */
|
2022-03-08 19:42:35 +05:30
|
|
|
virtual auto metaEntryBase() const -> QString = 0;
|
|
|
|
virtual auto debugName() const -> QString = 0;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-07 00:34:24 +05:30
|
|
|
|
2022-03-25 02:54:51 +05:30
|
|
|
void retranslate() override;
|
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
auto shouldDisplay() const -> bool override = 0;
|
|
|
|
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool = 0;
|
2022-03-08 03:59:59 +05:30
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
auto apiProvider() const -> const ModAPI* { return api.get(); };
|
2022-04-14 18:57:03 +05:30
|
|
|
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
|
2022-03-03 05:47:10 +05:30
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
|
2022-04-03 18:51:48 +05:30
|
|
|
void updateModVersions(int prev_count = -1);
|
2022-03-06 23:53:00 +05:30
|
|
|
|
2022-03-03 05:47:10 +05:30
|
|
|
void openedImpl() override;
|
2022-03-08 19:42:35 +05:30
|
|
|
auto eventFilter(QObject* watched, QEvent* event) -> bool override;
|
2022-03-03 05:47:10 +05:30
|
|
|
|
|
|
|
BaseInstance* m_instance;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateSelectionButton();
|
|
|
|
|
|
|
|
protected slots:
|
2022-04-03 04:38:37 +05:30
|
|
|
virtual void filterMods();
|
2022-03-03 05:47:10 +05:30
|
|
|
void triggerSearch();
|
|
|
|
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
|
|
|
void onVersionSelectionChanged(QString data);
|
|
|
|
void onModSelected();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Ui::ModPage* ui = nullptr;
|
|
|
|
ModDownloadDialog* dialog = nullptr;
|
2022-04-03 03:03:50 +05:30
|
|
|
|
2022-04-14 18:57:03 +05:30
|
|
|
ModFilterWidget filter_widget;
|
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter;
|
2022-04-03 03:03:50 +05:30
|
|
|
|
2022-03-03 05:47:10 +05:30
|
|
|
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;
|
|
|
|
};
|