2022-03-03 00:17:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include "modplatform/ModIndex.h"
|
2022-11-25 12:23:46 +00:00
|
|
|
|
|
|
|
#include "ui/pages/modplatform/ResourcePage.h"
|
2022-04-14 14:27:03 +01:00
|
|
|
#include "ui/widgets/ModFilterWidget.h"
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
2022-11-25 12:23:46 +00:00
|
|
|
class ResourcePage;
|
2022-03-03 00:17:10 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 22:03:52 +00:00
|
|
|
namespace ResourceDownload {
|
|
|
|
|
|
|
|
class ModDownloadDialog;
|
|
|
|
|
2022-03-08 14:12:35 +00:00
|
|
|
/* This page handles most logic related to browsing and selecting mods to download. */
|
2022-11-25 12:23:46 +00:00
|
|
|
class ModPage : public ResourcePage {
|
2022-03-03 00:17:10 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-08-21 14:50:10 +01:00
|
|
|
template<typename T>
|
2022-11-25 12:23:46 +00:00
|
|
|
static T* create(ModDownloadDialog* dialog, BaseInstance& instance)
|
2022-08-21 14:50:10 +01:00
|
|
|
{
|
|
|
|
auto page = new T(dialog, instance);
|
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
auto filter_widget = ModFilterWidget::create(static_cast<MinecraftInstance&>(instance).getPackProfile()->getComponentVersion("net.minecraft"), page);
|
2022-08-21 14:50:10 +01:00
|
|
|
page->setFilterWidget(filter_widget);
|
|
|
|
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
~ModPage() override = default;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
[[nodiscard]] inline QString resourceString() const override { return tr("mod"); }
|
2022-03-03 00:17:10 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
[[nodiscard]] QMap<QString, QString> urlHandlers() const override;
|
2022-03-06 19:04:24 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
void addResourceToDialog(ModPlatform::IndexedPack&, ModPlatform::IndexedVersion&) override;
|
2022-03-24 21:24:51 +00:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool = 0;
|
2022-05-24 13:38:48 +01:00
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
[[nodiscard]] bool supportsFiltering() const override { return true; };
|
2022-04-14 14:27:03 +01:00
|
|
|
auto getFilter() const -> const std::shared_ptr<ModFilterWidget::Filter> { return m_filter; }
|
2022-08-21 14:50:10 +01:00
|
|
|
void setFilterWidget(unique_qobject_ptr<ModFilterWidget>&);
|
|
|
|
|
2022-11-25 12:23:46 +00:00
|
|
|
public slots:
|
|
|
|
void updateVersionList() override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
protected:
|
2022-11-25 12:23:46 +00:00
|
|
|
ModPage(ModDownloadDialog* dialog, BaseInstance& instance);
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
protected slots:
|
2022-04-03 00:08:37 +01:00
|
|
|
virtual void filterMods();
|
2022-11-25 12:23:46 +00:00
|
|
|
void triggerSearch() override;
|
2022-03-03 00:17:10 +00:00
|
|
|
|
|
|
|
protected:
|
2022-08-21 14:50:10 +01:00
|
|
|
unique_qobject_ptr<ModFilterWidget> m_filter_widget;
|
2022-04-14 14:27:03 +01:00
|
|
|
std::shared_ptr<ModFilterWidget::Filter> m_filter;
|
2022-03-03 00:17:10 +00:00
|
|
|
};
|
2022-12-16 22:03:52 +00:00
|
|
|
|
|
|
|
} // namespace ResourceDownload
|