@ -134,7 +134,8 @@ void FlamePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelInde
|
||||
auto netJob = new NetJob(QString("Flame::PackVersions(%1)").arg(current.name), APPLICATION->network());
|
||||
auto response = std::make_shared<QByteArray>();
|
||||
int addonId = current.addonId;
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response));
|
||||
netJob->addNetAction(
|
||||
Net::ApiDownload::makeByteArray(QString("https://api.curseforge.com/v1/mods/%1/files").arg(addonId), response));
|
||||
|
||||
QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId, curr] {
|
||||
if (addonId != current.addonId) {
|
||||
|
@ -37,45 +37,31 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui/pages/BasePage.h"
|
||||
#include <Application.h>
|
||||
#include "tasks/Task.h"
|
||||
#include <modplatform/flame/FlamePackIndex.h>
|
||||
#include "tasks/Task.h"
|
||||
#include "ui/pages/BasePage.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class FlamePage;
|
||||
}
|
||||
|
||||
class NewInstanceDialog;
|
||||
|
||||
namespace Flame {
|
||||
class ListModel;
|
||||
class ListModel;
|
||||
}
|
||||
|
||||
class FlamePage : public QWidget, public BasePage
|
||||
{
|
||||
class FlamePage : public QWidget, public BasePage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FlamePage(NewInstanceDialog* dialog, QWidget *parent = 0);
|
||||
public:
|
||||
explicit FlamePage(NewInstanceDialog* dialog, QWidget* parent = 0);
|
||||
virtual ~FlamePage();
|
||||
virtual QString displayName() const override
|
||||
{
|
||||
return "CurseForge";
|
||||
}
|
||||
virtual QIcon icon() const override
|
||||
{
|
||||
return APPLICATION->getThemedIcon("flame");
|
||||
}
|
||||
virtual QString id() const override
|
||||
{
|
||||
return "flame";
|
||||
}
|
||||
virtual QString helpPage() const override
|
||||
{
|
||||
return "Flame-platform";
|
||||
}
|
||||
virtual QString displayName() const override { return "CurseForge"; }
|
||||
virtual QIcon icon() const override { return APPLICATION->getThemedIcon("flame"); }
|
||||
virtual QString id() const override { return "flame"; }
|
||||
virtual QString helpPage() const override { return "Flame-platform"; }
|
||||
virtual bool shouldDisplay() const override;
|
||||
void retranslate() override;
|
||||
|
||||
@ -83,18 +69,18 @@ public:
|
||||
|
||||
void openedImpl() override;
|
||||
|
||||
bool eventFilter(QObject * watched, QEvent * event) override;
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
void suggestCurrent();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void triggerSearch();
|
||||
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
||||
void onVersionSelectionChanged(QString data);
|
||||
|
||||
private:
|
||||
Ui::FlamePage *ui = nullptr;
|
||||
private:
|
||||
Ui::FlamePage* ui = nullptr;
|
||||
NewInstanceDialog* dialog = nullptr;
|
||||
Flame::ListModel* listModel = nullptr;
|
||||
Flame::IndexedPack current;
|
||||
|
@ -49,8 +49,7 @@ static bool isOptedOut(ModPlatform::IndexedVersion const& ver)
|
||||
return ver.downloadUrl.isEmpty();
|
||||
}
|
||||
|
||||
FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
|
||||
: ModPage(dialog, instance)
|
||||
FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ModPage(dialog, instance)
|
||||
{
|
||||
m_model = new FlameModModel(instance);
|
||||
m_ui->packView->setModel(m_model);
|
||||
@ -67,7 +66,9 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
|
||||
m_ui->packDescription->setMetaEntry(metaEntryBase());
|
||||
}
|
||||
|
||||
auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
|
||||
auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
|
||||
{
|
||||
Q_UNUSED(loaders);
|
||||
return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty();
|
||||
@ -86,7 +87,7 @@ void FlameModPage::openUrl(const QUrl& url)
|
||||
if (query.startsWith("remoteUrl=")) {
|
||||
// attempt to resolve url from warning page
|
||||
query.remove(0, 10);
|
||||
ModPage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
|
||||
ModPage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -125,7 +126,7 @@ void FlameResourcePackPage::openUrl(const QUrl& url)
|
||||
if (query.startsWith("remoteUrl=")) {
|
||||
// attempt to resolve url from warning page
|
||||
query.remove(0, 10);
|
||||
ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
|
||||
ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -164,7 +165,7 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
|
||||
if (query.startsWith("remoteUrl=")) {
|
||||
// attempt to resolve url from warning page
|
||||
query.remove(0, 10);
|
||||
ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
|
||||
ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -175,8 +176,17 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
|
||||
// I don't know why, but doing this on the parent class makes it so that
|
||||
// other mod providers start loading before being selected, at least with
|
||||
// my Qt, so we need to implement this in every derived class...
|
||||
auto FlameModPage::shouldDisplay() const -> bool { return true; }
|
||||
auto FlameResourcePackPage::shouldDisplay() const -> bool { return true; }
|
||||
auto FlameTexturePackPage::shouldDisplay() const -> bool { return true; }
|
||||
auto FlameModPage::shouldDisplay() const -> bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
auto FlameResourcePackPage::shouldDisplay() const -> bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
auto FlameTexturePackPage::shouldDisplay() const -> bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ResourceDownload
|
||||
|
@ -49,12 +49,27 @@
|
||||
namespace ResourceDownload {
|
||||
|
||||
namespace Flame {
|
||||
static inline QString displayName() { return "CurseForge"; }
|
||||
static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); }
|
||||
static inline QString id() { return "curseforge"; }
|
||||
static inline QString debugName() { return "Flame"; }
|
||||
static inline QString metaEntryBase() { return "FlameMods"; }
|
||||
static inline QString displayName()
|
||||
{
|
||||
return "CurseForge";
|
||||
}
|
||||
static inline QIcon icon()
|
||||
{
|
||||
return APPLICATION->getThemedIcon("flame");
|
||||
}
|
||||
static inline QString id()
|
||||
{
|
||||
return "curseforge";
|
||||
}
|
||||
static inline QString debugName()
|
||||
{
|
||||
return "Flame";
|
||||
}
|
||||
static inline QString metaEntryBase()
|
||||
{
|
||||
return "FlameMods";
|
||||
}
|
||||
} // namespace Flame
|
||||
|
||||
class FlameModPage : public ModPage {
|
||||
Q_OBJECT
|
||||
@ -78,7 +93,9 @@ class FlameModPage : public ModPage {
|
||||
|
||||
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
|
||||
|
||||
bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
|
||||
bool validateVersion(ModPlatform::IndexedVersion& ver,
|
||||
QString mineVer,
|
||||
std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
|
||||
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
|
||||
|
||||
void openUrl(const QUrl& url) override;
|
||||
|
Reference in New Issue
Block a user