CurseForge shader downloading
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
caf925cbad
commit
94c1cd6bcf
@ -38,6 +38,8 @@ class FlameAPI : public NetworkResourceAPI {
|
|||||||
return 6;
|
return 6;
|
||||||
case ModPlatform::ResourceType::RESOURCE_PACK:
|
case ModPlatform::ResourceType::RESOURCE_PACK:
|
||||||
return 12;
|
return 12;
|
||||||
|
case ModPlatform::ResourceType::SHADER_PACK:
|
||||||
|
return 6552;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +370,8 @@ QList<BasePage*> ShaderPackDownloadDialog::getPages()
|
|||||||
{
|
{
|
||||||
QList<BasePage*> pages;
|
QList<BasePage*> pages;
|
||||||
pages.append(ModrinthShaderPackPage::create(this, *m_instance));
|
pages.append(ModrinthShaderPackPage::create(this, *m_instance));
|
||||||
|
if (APPLICATION->capabilities() & Application::SupportsFlame)
|
||||||
|
pages.append(FlameShaderPackPage::create(this, *m_instance));
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,4 +121,27 @@ auto FlameTexturePackModel::documentToArray(QJsonDocument& obj) const -> QJsonAr
|
|||||||
return Json::ensureArray(obj.object(), "data");
|
return Json::ensureArray(obj.object(), "data");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlameShaderPackModel::FlameShaderPackModel(const BaseInstance& base) : ShaderPackResourceModel(base, new FlameAPI) {}
|
||||||
|
|
||||||
|
void FlameShaderPackModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||||
|
{
|
||||||
|
FlameMod::loadIndexedPack(m, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We already deal with the URLs when initializing the pack, due to the API response's structure
|
||||||
|
void FlameShaderPackModel::loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj)
|
||||||
|
{
|
||||||
|
FlameMod::loadBody(m, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlameShaderPackModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr)
|
||||||
|
{
|
||||||
|
FlameMod::loadIndexedPackVersions(m, arr, APPLICATION->network(), &m_base_instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto FlameShaderPackModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
|
||||||
|
{
|
||||||
|
return Json::ensureArray(obj.object(), "data");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -68,4 +68,21 @@ class FlameTexturePackModel : public TexturePackResourceModel {
|
|||||||
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
|
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FlameShaderPackModel : public ShaderPackResourceModel {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
FlameShaderPackModel(const BaseInstance&);
|
||||||
|
~FlameShaderPackModel() override = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
[[nodiscard]] QString debugName() const override { return Flame::debugName() + " (Model)"; }
|
||||||
|
[[nodiscard]] QString metaEntryBase() const override { return Flame::metaEntryBase(); }
|
||||||
|
|
||||||
|
void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) override;
|
||||||
|
void loadExtraPackInfo(ModPlatform::IndexedPack& m, QJsonObject& obj) override;
|
||||||
|
void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) override;
|
||||||
|
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -173,6 +173,45 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
|
|||||||
TexturePackResourcePage::openUrl(url);
|
TexturePackResourcePage::openUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlameShaderPackPage::FlameShaderPackPage(ShaderPackDownloadDialog* dialog, BaseInstance& instance)
|
||||||
|
: ShaderPackResourcePage(dialog, instance)
|
||||||
|
{
|
||||||
|
m_model = new FlameShaderPackModel(instance);
|
||||||
|
m_ui->packView->setModel(m_model);
|
||||||
|
|
||||||
|
addSortings();
|
||||||
|
|
||||||
|
// sometimes Qt just ignores virtual slots and doesn't work as intended it seems,
|
||||||
|
// so it's best not to connect them in the parent's constructor...
|
||||||
|
connect(m_ui->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch()));
|
||||||
|
connect(m_ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlameShaderPackPage::onSelectionChanged);
|
||||||
|
connect(m_ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlameShaderPackPage::onVersionSelectionChanged);
|
||||||
|
connect(m_ui->resourceSelectionButton, &QPushButton::clicked, this, &FlameShaderPackPage::onResourceSelected);
|
||||||
|
|
||||||
|
m_ui->packDescription->setMetaEntry(metaEntryBase());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlameShaderPackPage::optedOut(ModPlatform::IndexedVersion& ver) const
|
||||||
|
{
|
||||||
|
return isOptedOut(ver);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlameShaderPackPage::openUrl(const QUrl& url)
|
||||||
|
{
|
||||||
|
if (url.scheme().isEmpty()) {
|
||||||
|
QString query = url.query(QUrl::FullyDecoded);
|
||||||
|
|
||||||
|
if (query.startsWith("remoteUrl=")) {
|
||||||
|
// attempt to resolve url from warning page
|
||||||
|
query.remove(0, 10);
|
||||||
|
ShaderPackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderPackResourcePage::openUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
// I don't know why, but doing this on the parent class makes it so that
|
// 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
|
// other mod providers start loading before being selected, at least with
|
||||||
// my Qt, so we need to implement this in every derived class...
|
// my Qt, so we need to implement this in every derived class...
|
||||||
@ -188,5 +227,9 @@ auto FlameTexturePackPage::shouldDisplay() const -> bool
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
auto FlameShaderPackPage::shouldDisplay() const -> bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "ui/pages/modplatform/ModPage.h"
|
#include "ui/pages/modplatform/ModPage.h"
|
||||||
#include "ui/pages/modplatform/ResourcePackPage.h"
|
#include "ui/pages/modplatform/ResourcePackPage.h"
|
||||||
|
#include "ui/pages/modplatform/ShaderPackPage.h"
|
||||||
#include "ui/pages/modplatform/TexturePackPage.h"
|
#include "ui/pages/modplatform/TexturePackPage.h"
|
||||||
|
|
||||||
namespace ResourceDownload {
|
namespace ResourceDownload {
|
||||||
@ -155,4 +156,31 @@ class FlameTexturePackPage : public TexturePackResourcePage {
|
|||||||
void openUrl(const QUrl& url) override;
|
void openUrl(const QUrl& url) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FlameShaderPackPage : public ShaderPackResourcePage {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static FlameShaderPackPage* create(ShaderPackDownloadDialog* dialog, BaseInstance& instance)
|
||||||
|
{
|
||||||
|
return ShaderPackResourcePage::create<FlameShaderPackPage>(dialog, instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
FlameShaderPackPage(ShaderPackDownloadDialog* dialog, BaseInstance& instance);
|
||||||
|
~FlameShaderPackPage() override = default;
|
||||||
|
|
||||||
|
[[nodiscard]] bool shouldDisplay() const override;
|
||||||
|
|
||||||
|
[[nodiscard]] inline auto displayName() const -> QString override { return Flame::displayName(); }
|
||||||
|
[[nodiscard]] inline auto icon() const -> QIcon override { return Flame::icon(); }
|
||||||
|
[[nodiscard]] inline auto id() const -> QString override { return Flame::id(); }
|
||||||
|
[[nodiscard]] inline auto debugName() const -> QString override { return Flame::debugName(); }
|
||||||
|
[[nodiscard]] inline auto metaEntryBase() const -> QString override { return Flame::metaEntryBase(); }
|
||||||
|
|
||||||
|
[[nodiscard]] inline auto helpPage() const -> QString override { return ""; }
|
||||||
|
|
||||||
|
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
|
||||||
|
|
||||||
|
void openUrl(const QUrl& url) override;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace ResourceDownload
|
} // namespace ResourceDownload
|
||||||
|
Loading…
Reference in New Issue
Block a user