2022-03-03 00:17:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
2022-03-06 18:23:00 +00:00
|
|
|
#include "Application.h"
|
2022-03-03 02:01:23 +00:00
|
|
|
#include "modplatform/ModAPI.h"
|
2022-03-03 00:17:10 +00:00
|
|
|
#include "modplatform/ModIndex.h"
|
|
|
|
#include "ui/pages/BasePage.h"
|
|
|
|
#include "ui/pages/modplatform/ModModel.h"
|
2022-04-14 14:27:03 +01:00
|
|
|
#include "ui/widgets/ModFilterWidget.h"
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
class ModDownloadDialog;
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class ModPage;
|
|
|
|
}
|
|
|
|
|
2022-03-08 14:12:35 +00:00
|
|
|
/* This page handles most logic related to browsing and selecting mods to download. */
|
2022-03-03 00:17:10 +00:00
|
|
|
class ModPage : public QWidget, public BasePage {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-03-06 16:54:05 +00:00
|
|
|
explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api);
|
2022-03-08 14:12:35 +00:00
|
|
|
~ModPage() override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-03-06 19:04:24 +00:00
|
|
|
/* Affects what the user sees */
|
2022-03-08 14:12:35 +00:00
|
|
|
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 00:17:10 +00:00
|
|
|
|
2022-03-06 19:04:24 +00:00
|
|
|
/* Used internally */
|
2022-03-08 14:12:35 +00:00
|
|
|
virtual auto metaEntryBase() const -> QString = 0;
|
|
|
|
virtual auto debugName() const -> QString = 0;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-03-06 19:04:24 +00:00
|
|
|
|
2022-03-24 21:24:51 +00:00
|
|
|
void retranslate() override;
|
|
|
|
|
2022-05-24 13:38:48 +01:00
|
|
|
void updateUi();
|
|
|
|
|
2022-03-08 14:12:35 +00:00
|
|
|
auto shouldDisplay() const -> bool override = 0;
|
2022-05-19 07:40:28 +01:00
|
|
|
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, ModAPI::ModLoaderTypes loaders = ModAPI::Unspecified) const -> bool = 0;
|
2022-03-07 22:29:59 +00:00
|
|
|
|
2022-05-24 13:38:48 +01:00
|
|
|
auto apiProvider() -> ModAPI* { return api.get(); };
|
2022-04-14 14:27:03 +01:00
|
|
|
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-03-08 14:12:35 +00:00
|
|
|
auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
|
2022-04-03 14:21:48 +01:00
|
|
|
void updateModVersions(int prev_count = -1);
|
2022-03-06 18:23:00 +00:00
|
|
|
|
2022-03-03 00:17:10 +00:00
|
|
|
void openedImpl() override;
|
2022-03-08 14:12:35 +00:00
|
|
|
auto eventFilter(QObject* watched, QEvent* event) -> bool override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
BaseInstance* m_instance;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateSelectionButton();
|
|
|
|
|
|
|
|
protected slots:
|
2022-04-03 00:08:37 +01:00
|
|
|
virtual void filterMods();
|
2022-03-03 00:17:10 +00:00
|
|
|
void triggerSearch();
|
|
|
|
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
|
|
|
void onVersionSelectionChanged(QString data);
|
|
|
|
void onModSelected();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Ui::ModPage* ui = nullptr;
|
|
|
|
ModDownloadDialog* dialog = nullptr;
|
2022-04-02 22:33:50 +01:00
|
|
|
|
2022-04-14 14:27:03 +01:00
|
|
|
ModFilterWidget filter_widget;
|
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter;
|
2022-04-02 22:33:50 +01:00
|
|
|
|
2022-03-03 00:17:10 +00:00
|
|
|
ModPlatform::ListModel* listModel = nullptr;
|
|
|
|
ModPlatform::IndexedPack current;
|
|
|
|
|
2022-03-06 16:54:05 +00:00
|
|
|
std::unique_ptr<ModAPI> api;
|
|
|
|
|
2022-03-03 00:17:10 +00:00
|
|
|
int selectedVersion = -1;
|
|
|
|
};
|