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 13:27:03 +00: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-03-08 14:12:35 +00:00
|
|
|
auto shouldDisplay() const -> bool override = 0;
|
2022-04-18 11:12:42 +00:00
|
|
|
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, ModAPI::ModLoaderType loader = ModAPI::Unspecified) const -> bool = 0;
|
2022-03-07 22:29:59 +00:00
|
|
|
|
2022-03-08 14:12:35 +00:00
|
|
|
auto apiProvider() const -> const ModAPI* { return api.get(); };
|
2022-04-14 13:27:03 +00:00
|
|
|
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
|
2022-04-28 23:14:03 +00:00
|
|
|
auto getDialog() const -> const ModDownloadDialog* { return dialog; }
|
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 13:21:48 +00: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-02 23:08:37 +00: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 21:33:50 +00:00
|
|
|
|
2022-04-14 13:27:03 +00:00
|
|
|
ModFilterWidget filter_widget;
|
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter;
|
2022-04-02 21:33:50 +00: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;
|
|
|
|
};
|