refactor: Use a single indexed pack for mods
Since there's little difference between them, let's remove duplication and merge them.
This commit is contained in:
parent
ca211558b5
commit
881b2f2b38
42
launcher/modplatform/ModIndex.h
Normal file
42
launcher/modplatform/ModIndex.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
namespace ModPlatform {
|
||||||
|
|
||||||
|
struct ModpackAuthor {
|
||||||
|
QString name;
|
||||||
|
QString url;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IndexedVersion {
|
||||||
|
QVariant addonId;
|
||||||
|
QVariant fileId;
|
||||||
|
QString version;
|
||||||
|
QVector<QString> mcVersion;
|
||||||
|
QString downloadUrl;
|
||||||
|
QString date;
|
||||||
|
QString fileName;
|
||||||
|
QVector<QString> loaders = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IndexedPack {
|
||||||
|
QVariant addonId;
|
||||||
|
QString name;
|
||||||
|
QString description;
|
||||||
|
QList<ModpackAuthor> authors;
|
||||||
|
QString logoName;
|
||||||
|
QString logoUrl;
|
||||||
|
QString websiteUrl;
|
||||||
|
|
||||||
|
bool versionsLoaded = false;
|
||||||
|
QVector<IndexedVersion> versions;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ModPlatform
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
@ -1,13 +1,11 @@
|
|||||||
#include <QObject>
|
|
||||||
#include "FlameModIndex.h"
|
#include "FlameModIndex.h"
|
||||||
|
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BaseInstance.h"
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
|
void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||||
void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
|
|
||||||
{
|
{
|
||||||
pack.addonId = Json::requireInteger(obj, "id");
|
pack.addonId = Json::requireInteger(obj, "id");
|
||||||
pack.name = Json::requireString(obj, "name");
|
pack.name = Json::requireString(obj, "name");
|
||||||
@ -16,10 +14,10 @@ void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
|
|||||||
|
|
||||||
bool thumbnailFound = false;
|
bool thumbnailFound = false;
|
||||||
auto attachments = Json::requireArray(obj, "attachments");
|
auto attachments = Json::requireArray(obj, "attachments");
|
||||||
for(auto attachmentRaw: attachments) {
|
for (auto attachmentRaw : attachments) {
|
||||||
auto attachmentObj = Json::requireObject(attachmentRaw);
|
auto attachmentObj = Json::requireObject(attachmentRaw);
|
||||||
bool isDefault = attachmentObj.value("isDefault").toBool(false);
|
bool isDefault = attachmentObj.value("isDefault").toBool(false);
|
||||||
if(isDefault) {
|
if (isDefault) {
|
||||||
thumbnailFound = true;
|
thumbnailFound = true;
|
||||||
pack.logoName = Json::requireString(attachmentObj, "title");
|
pack.logoName = Json::requireString(attachmentObj, "title");
|
||||||
pack.logoUrl = Json::requireString(attachmentObj, "thumbnailUrl");
|
pack.logoUrl = Json::requireString(attachmentObj, "thumbnailUrl");
|
||||||
@ -27,37 +25,35 @@ void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thumbnailFound) {
|
if (!thumbnailFound) { throw JSONValidationError(QString("Pack without an icon, skipping: %1").arg(pack.name)); }
|
||||||
throw JSONValidationError(QString("Pack without an icon, skipping: %1").arg(pack.name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
auto authors = Json::requireArray(obj, "authors");
|
auto authors = Json::requireArray(obj, "authors");
|
||||||
for(auto authorIter: authors) {
|
for (auto authorIter : authors) {
|
||||||
auto author = Json::requireObject(authorIter);
|
auto author = Json::requireObject(authorIter);
|
||||||
FlameMod::ModpackAuthor packAuthor;
|
ModPlatform::ModpackAuthor packAuthor;
|
||||||
packAuthor.name = Json::requireString(author, "name");
|
packAuthor.name = Json::requireString(author, "name");
|
||||||
packAuthor.url = Json::requireString(author, "url");
|
packAuthor.url = Json::requireString(author, "url");
|
||||||
pack.authors.append(packAuthor);
|
pack.authors.append(packAuthor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray & arr, const shared_qobject_ptr<QNetworkAccessManager>& network, BaseInstance * inst)
|
void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||||
|
QJsonArray& arr,
|
||||||
|
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||||
|
BaseInstance* inst)
|
||||||
{
|
{
|
||||||
QVector<FlameMod::IndexedVersion> unsortedVersions;
|
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
||||||
bool hasFabric = !((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
bool hasFabric = !((MinecraftInstance*)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
||||||
QString mcVersion = ((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.minecraft");
|
QString mcVersion = ((MinecraftInstance*)inst)->getPackProfile()->getComponentVersion("net.minecraft");
|
||||||
|
|
||||||
for(auto versionIter: arr) {
|
for (auto versionIter : arr) {
|
||||||
auto obj = versionIter.toObject();
|
auto obj = versionIter.toObject();
|
||||||
|
|
||||||
auto versionArray = Json::requireArray(obj, "gameVersion");
|
auto versionArray = Json::requireArray(obj, "gameVersion");
|
||||||
if (versionArray.isEmpty()) {
|
if (versionArray.isEmpty()) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FlameMod::IndexedVersion file;
|
ModPlatform::IndexedVersion file;
|
||||||
for(auto mcVer : versionArray){
|
for (auto mcVer : versionArray) {
|
||||||
file.mcVersion.append(mcVer.toString());
|
file.mcVersion.append(mcVer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,29 +66,27 @@ void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray
|
|||||||
|
|
||||||
auto modules = Json::requireArray(obj, "modules");
|
auto modules = Json::requireArray(obj, "modules");
|
||||||
bool is_valid_fabric_version = false;
|
bool is_valid_fabric_version = false;
|
||||||
for(auto m : modules){
|
for (auto m : modules) {
|
||||||
auto fname = Json::requireString(m.toObject(),"foldername");
|
auto fname = Json::requireString(m.toObject(), "foldername");
|
||||||
// FIXME: This does not work properly when a mod supports more than one mod loader, since
|
// FIXME: This does not work properly when a mod supports more than one mod loader, since
|
||||||
// they bundle the meta files for all of them in the same arquive, even when that version
|
// they bundle the meta files for all of them in the same arquive, even when that version
|
||||||
// doesn't support the given mod loader.
|
// doesn't support the given mod loader.
|
||||||
if(hasFabric){
|
if (hasFabric) {
|
||||||
if(fname == "fabric.mod.json"){
|
if (fname == "fabric.mod.json") {
|
||||||
is_valid_fabric_version = true;
|
is_valid_fabric_version = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else break;
|
break;
|
||||||
// NOTE: Since we're not validating forge versions, we can just skip this loop.
|
// NOTE: Since we're not validating forge versions, we can just skip this loop.
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasFabric && !is_valid_fabric_version)
|
if (hasFabric && !is_valid_fabric_version) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
unsortedVersions.append(file);
|
unsortedVersions.append(file);
|
||||||
}
|
}
|
||||||
auto orderSortPredicate = [](const IndexedVersion & a, const IndexedVersion & b) -> bool
|
auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
|
||||||
{
|
// dates are in RFC 3339 format
|
||||||
//dates are in RFC 3339 format
|
|
||||||
return a.date > b.date;
|
return a.date > b.date;
|
||||||
};
|
};
|
||||||
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
||||||
|
@ -3,48 +3,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QList>
|
|
||||||
#include <QMetaType>
|
#include "modplatform/ModIndex.h"
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QObjectPtr.h>
|
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
namespace FlameMod {
|
namespace FlameMod {
|
||||||
struct ModpackAuthor {
|
|
||||||
QString name;
|
|
||||||
QString url;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IndexedVersion {
|
void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj);
|
||||||
int addonId;
|
void loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||||
int fileId;
|
QJsonArray& arr,
|
||||||
QString version;
|
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||||
QVector<QString> mcVersion;
|
BaseInstance* inst);
|
||||||
QString downloadUrl;
|
|
||||||
QString date;
|
|
||||||
QString fileName;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IndexedPack
|
} // namespace FlameMod
|
||||||
{
|
|
||||||
int addonId;
|
|
||||||
QString name;
|
|
||||||
QString description;
|
|
||||||
QList<ModpackAuthor> authors;
|
|
||||||
QString logoName;
|
|
||||||
QString logoUrl;
|
|
||||||
QString websiteUrl;
|
|
||||||
|
|
||||||
bool versionsLoaded = false;
|
|
||||||
QVector<IndexedVersion> versions;
|
|
||||||
};
|
|
||||||
|
|
||||||
void loadIndexedPack(IndexedPack & m, QJsonObject & obj);
|
|
||||||
void loadIndexedPackVersions(IndexedPack &pack, QJsonArray &arr, const shared_qobject_ptr<QNetworkAccessManager> &network, BaseInstance *inst);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FlameMod::IndexedPack)
|
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
#include <QObject>
|
|
||||||
#include "ModrinthPackIndex.h"
|
#include "ModrinthPackIndex.h"
|
||||||
|
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BaseInstance.h"
|
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
|
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||||
void Modrinth::loadIndexedPack(Modrinth::IndexedPack & pack, QJsonObject & obj)
|
|
||||||
{
|
{
|
||||||
pack.addonId = Json::requireString(obj, "project_id");
|
pack.addonId = Json::requireString(obj, "project_id");
|
||||||
pack.name = Json::requireString(obj, "title");
|
pack.name = Json::requireString(obj, "title");
|
||||||
@ -16,59 +13,60 @@ void Modrinth::loadIndexedPack(Modrinth::IndexedPack & pack, QJsonObject & obj)
|
|||||||
pack.description = Json::ensureString(obj, "description", "");
|
pack.description = Json::ensureString(obj, "description", "");
|
||||||
|
|
||||||
pack.logoUrl = Json::requireString(obj, "icon_url");
|
pack.logoUrl = Json::requireString(obj, "icon_url");
|
||||||
pack.logoName = pack.addonId;
|
pack.logoName = pack.addonId.toString();
|
||||||
|
|
||||||
Modrinth::ModpackAuthor modAuthor;
|
ModPlatform::ModpackAuthor modAuthor;
|
||||||
modAuthor.name = Json::requireString(obj, "author");
|
modAuthor.name = Json::requireString(obj, "author");
|
||||||
modAuthor.url = "https://modrinth.com/user/"+modAuthor.name;
|
modAuthor.url = "https://modrinth.com/user/" + modAuthor.name;
|
||||||
pack.author = modAuthor;
|
pack.authors.append(modAuthor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray & arr, const shared_qobject_ptr<QNetworkAccessManager>& network, BaseInstance * inst)
|
void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||||
|
QJsonArray& arr,
|
||||||
|
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||||
|
BaseInstance* inst)
|
||||||
{
|
{
|
||||||
QVector<Modrinth::IndexedVersion> unsortedVersions;
|
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
||||||
bool hasFabric = !((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
bool hasFabric = !((MinecraftInstance*)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
||||||
QString mcVersion = ((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.minecraft");
|
QString mcVersion = ((MinecraftInstance*)inst)->getPackProfile()->getComponentVersion("net.minecraft");
|
||||||
|
|
||||||
for(auto versionIter: arr) {
|
for (auto versionIter : arr) {
|
||||||
auto obj = versionIter.toObject();
|
auto obj = versionIter.toObject();
|
||||||
Modrinth::IndexedVersion file;
|
ModPlatform::IndexedVersion file;
|
||||||
file.addonId = Json::requireString(obj,"project_id") ;
|
file.addonId = Json::requireString(obj, "project_id");
|
||||||
file.fileId = Json::requireString(obj, "id");
|
file.fileId = Json::requireString(obj, "id");
|
||||||
file.date = Json::requireString(obj, "date_published");
|
file.date = Json::requireString(obj, "date_published");
|
||||||
auto versionArray = Json::requireArray(obj, "game_versions");
|
auto versionArray = Json::requireArray(obj, "game_versions");
|
||||||
if (versionArray.empty()) {
|
if (versionArray.empty()) { continue; }
|
||||||
continue;
|
for (auto mcVer : versionArray) {
|
||||||
}
|
|
||||||
for(auto mcVer : versionArray){
|
|
||||||
file.mcVersion.append(mcVer.toString());
|
file.mcVersion.append(mcVer.toString());
|
||||||
}
|
}
|
||||||
auto loaders = Json::requireArray(obj,"loaders");
|
auto loaders = Json::requireArray(obj, "loaders");
|
||||||
for(auto loader : loaders){
|
for (auto loader : loaders) {
|
||||||
file.loaders.append(loader.toString());
|
file.loaders.append(loader.toString());
|
||||||
}
|
}
|
||||||
file.version = Json::requireString(obj, "name");
|
file.version = Json::requireString(obj, "name");
|
||||||
|
|
||||||
auto files = Json::requireArray(obj, "files");
|
auto files = Json::requireArray(obj, "files");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (files.count() > 1 && i < files.count()){
|
while (files.count() > 1 && i < files.count()) {
|
||||||
//try to resolve the correct file
|
// try to resolve the correct file
|
||||||
auto parent = files[i].toObject();
|
auto parent = files[i].toObject();
|
||||||
auto fileName = Json::requireString(parent, "filename");
|
auto fileName = Json::requireString(parent, "filename");
|
||||||
//avoid grabbing "dev" files
|
// avoid grabbing "dev" files
|
||||||
if(fileName.contains("javadocs",Qt::CaseInsensitive) || fileName.contains("sources",Qt::CaseInsensitive)){
|
if (fileName.contains("javadocs", Qt::CaseInsensitive) || fileName.contains("sources", Qt::CaseInsensitive)) {
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//grab the correct mod loader
|
// grab the correct mod loader
|
||||||
if(fileName.contains("forge",Qt::CaseInsensitive) || fileName.contains("fabric",Qt::CaseInsensitive) ){
|
if (fileName.contains("forge", Qt::CaseInsensitive) || fileName.contains("fabric", Qt::CaseInsensitive)) {
|
||||||
if(hasFabric){
|
if (hasFabric) {
|
||||||
if(fileName.contains("forge",Qt::CaseInsensitive)){
|
if (fileName.contains("forge", Qt::CaseInsensitive)) {
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(fileName.contains("fabric",Qt::CaseInsensitive)){
|
if (fileName.contains("fabric", Qt::CaseInsensitive)) {
|
||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -77,16 +75,15 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto parent = files[i].toObject();
|
auto parent = files[i].toObject();
|
||||||
if(parent.contains("url")) {
|
if (parent.contains("url")) {
|
||||||
file.downloadUrl = Json::requireString(parent, "url");
|
file.downloadUrl = Json::requireString(parent, "url");
|
||||||
file.fileName = Json::requireString(parent, "filename");
|
file.fileName = Json::requireString(parent, "filename");
|
||||||
|
|
||||||
unsortedVersions.append(file);
|
unsortedVersions.append(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto orderSortPredicate = [](const IndexedVersion & a, const IndexedVersion & b) -> bool
|
auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
|
||||||
{
|
// dates are in RFC 3339 format
|
||||||
//dates are in RFC 3339 format
|
|
||||||
return a.date > b.date;
|
return a.date > b.date;
|
||||||
};
|
};
|
||||||
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
|
||||||
|
@ -1,48 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QList>
|
#include "modplatform/ModIndex.h"
|
||||||
#include <QMetaType>
|
|
||||||
#include <QString>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QObjectPtr.h>
|
|
||||||
#include "net/NetJob.h"
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
namespace Modrinth {
|
namespace Modrinth {
|
||||||
|
|
||||||
struct ModpackAuthor {
|
void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj);
|
||||||
QString name;
|
void loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||||
QString url;
|
QJsonArray& arr,
|
||||||
};
|
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||||
|
BaseInstance* inst);
|
||||||
|
|
||||||
struct IndexedVersion {
|
} // namespace Modrinth
|
||||||
QString addonId;
|
|
||||||
QString fileId;
|
|
||||||
QString version;
|
|
||||||
QVector<QString> mcVersion;
|
|
||||||
QString downloadUrl;
|
|
||||||
QString date;
|
|
||||||
QString fileName;
|
|
||||||
QVector<QString> loaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IndexedPack
|
|
||||||
{
|
|
||||||
QString addonId;
|
|
||||||
QString name;
|
|
||||||
QString description;
|
|
||||||
ModpackAuthor author;
|
|
||||||
QString logoName;
|
|
||||||
QString logoUrl;
|
|
||||||
QString websiteUrl;
|
|
||||||
|
|
||||||
bool versionsLoaded = false;
|
|
||||||
QVector<IndexedVersion> versions;
|
|
||||||
};
|
|
||||||
|
|
||||||
void loadIndexedPack(IndexedPack & m, QJsonObject & obj);
|
|
||||||
void loadIndexedPackVersions(IndexedPack &pack, QJsonArray &arr, const shared_qobject_ptr<QNetworkAccessManager> &network, BaseInstance *inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Modrinth::IndexedPack)
|
|
||||||
|
@ -39,7 +39,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const
|
|||||||
return QString("INVALID INDEX %1").arg(pos);
|
return QString("INVALID INDEX %1").arg(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexedPack pack = modpacks.at(pos);
|
ModPlatform::IndexedPack pack = modpacks.at(pos);
|
||||||
if(role == Qt::DisplayRole)
|
if(role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
return pack.name;
|
return pack.name;
|
||||||
@ -225,12 +225,12 @@ void ListModel::searchRequestFinished()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<FlameMod::IndexedPack> newList;
|
QList<ModPlatform::IndexedPack> newList;
|
||||||
auto packs = doc.array();
|
auto packs = doc.array();
|
||||||
for(auto packRaw : packs) {
|
for(auto packRaw : packs) {
|
||||||
auto packObj = packRaw.toObject();
|
auto packObj = packRaw.toObject();
|
||||||
|
|
||||||
FlameMod::IndexedPack pack;
|
ModPlatform::IndexedPack pack;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FlameMod::loadIndexedPack(pack, packObj);
|
FlameMod::loadIndexedPack(pack, packObj);
|
||||||
|
@ -57,7 +57,7 @@ private:
|
|||||||
void requestLogo(QString file, QString url);
|
void requestLogo(QString file, QString url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<IndexedPack> modpacks;
|
QList<ModPlatform::IndexedPack> modpacks;
|
||||||
QStringList m_failedLogos;
|
QStringList m_failedLogos;
|
||||||
QStringList m_loadingLogos;
|
QStringList m_loadingLogos;
|
||||||
LogoMap m_logoMap;
|
LogoMap m_logoMap;
|
||||||
|
@ -77,7 +77,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = listModel->data(first, Qt::UserRole).value<FlameMod::IndexedPack>();
|
current = listModel->data(first, Qt::UserRole).value<ModPlatform::IndexedPack>();
|
||||||
QString text = "";
|
QString text = "";
|
||||||
QString name = current.name;
|
QString name = current.name;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
else
|
else
|
||||||
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
||||||
if (!current.authors.empty()) {
|
if (!current.authors.empty()) {
|
||||||
auto authorToStr = [](FlameMod::ModpackAuthor &author) {
|
auto authorToStr = [](ModPlatform::ModpackAuthor &author) {
|
||||||
if (author.url.isEmpty()) {
|
if (author.url.isEmpty()) {
|
||||||
return author.name;
|
return author.name;
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
new NetJob(QString("Flame::ModVersions(%1)").arg(current.name),
|
new NetJob(QString("Flame::ModVersions(%1)").arg(current.name),
|
||||||
APPLICATION->network());
|
APPLICATION->network());
|
||||||
auto response = new QByteArray();
|
auto response = new QByteArray();
|
||||||
int addonId = current.addonId;
|
int addonId = current.addonId.toInt();
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(
|
netJob->addNetAction(Net::Download::makeByteArray(
|
||||||
QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files")
|
QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files")
|
||||||
.arg(addonId),
|
.arg(addonId),
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
Ui::FlameModPage *ui = nullptr;
|
Ui::FlameModPage *ui = nullptr;
|
||||||
ModDownloadDialog* dialog = nullptr;
|
ModDownloadDialog* dialog = nullptr;
|
||||||
FlameMod::ListModel* listModel = nullptr;
|
FlameMod::ListModel* listModel = nullptr;
|
||||||
FlameMod::IndexedPack current;
|
ModPlatform::IndexedPack current;
|
||||||
|
|
||||||
int selectedVersion = -1;
|
int selectedVersion = -1;
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const
|
|||||||
return QString("INVALID INDEX %1").arg(pos);
|
return QString("INVALID INDEX %1").arg(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexedPack pack = modpacks.at(pos);
|
ModPlatform::IndexedPack pack = modpacks.at(pos);
|
||||||
if(role == Qt::DisplayRole)
|
if(role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
return pack.name;
|
return pack.name;
|
||||||
@ -222,12 +222,12 @@ void Modrinth::ListModel::searchRequestFinished()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Modrinth::IndexedPack> newList;
|
QList<ModPlatform::IndexedPack> newList;
|
||||||
auto packs = doc.object().value("hits").toArray();
|
auto packs = doc.object().value("hits").toArray();
|
||||||
for(auto packRaw : packs) {
|
for(auto packRaw : packs) {
|
||||||
auto packObj = packRaw.toObject();
|
auto packObj = packRaw.toObject();
|
||||||
|
|
||||||
Modrinth::IndexedPack pack;
|
ModPlatform::IndexedPack pack;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Modrinth::loadIndexedPack(pack, packObj);
|
Modrinth::loadIndexedPack(pack, packObj);
|
||||||
|
@ -57,7 +57,7 @@ private:
|
|||||||
void requestLogo(QString file, QString url);
|
void requestLogo(QString file, QString url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<IndexedPack> modpacks;
|
QList<ModPlatform::IndexedPack> modpacks;
|
||||||
QStringList m_failedLogos;
|
QStringList m_failedLogos;
|
||||||
QStringList m_loadingLogos;
|
QStringList m_loadingLogos;
|
||||||
LogoMap m_logoMap;
|
LogoMap m_logoMap;
|
||||||
|
@ -76,7 +76,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = listModel->data(first, Qt::UserRole).value<Modrinth::IndexedPack>();
|
current = listModel->data(first, Qt::UserRole).value<ModPlatform::IndexedPack>();
|
||||||
QString text = "";
|
QString text = "";
|
||||||
QString name = current.name;
|
QString name = current.name;
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
text = name;
|
text = name;
|
||||||
else
|
else
|
||||||
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
||||||
text += "<br>" + tr(" by ") + "<a href=\"" + current.author.url + "\">" +
|
text += "<br>" + tr(" by ") + "<a href=\"" + current.authors[0].url + "\">" +
|
||||||
current.author.name + "</a><br><br>";
|
current.authors[0].name + "</a><br><br>";
|
||||||
ui->packDescription->setHtml(text + current.description);
|
ui->packDescription->setHtml(text + current.description);
|
||||||
|
|
||||||
if (!current.versionsLoaded) {
|
if (!current.versionsLoaded) {
|
||||||
@ -98,7 +98,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
|
|||||||
new NetJob(QString("Modrinth::ModVersions(%1)").arg(current.name),
|
new NetJob(QString("Modrinth::ModVersions(%1)").arg(current.name),
|
||||||
APPLICATION->network());
|
APPLICATION->network());
|
||||||
auto response = new QByteArray();
|
auto response = new QByteArray();
|
||||||
QString addonId = current.addonId;
|
QString addonId = current.addonId.toString();
|
||||||
netJob->addNetAction(Net::Download::makeByteArray(
|
netJob->addNetAction(Net::Download::makeByteArray(
|
||||||
QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId),
|
QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId),
|
||||||
response));
|
response));
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
Ui::ModrinthPage *ui = nullptr;
|
Ui::ModrinthPage *ui = nullptr;
|
||||||
ModDownloadDialog* dialog = nullptr;
|
ModDownloadDialog* dialog = nullptr;
|
||||||
Modrinth::ListModel* listModel = nullptr;
|
Modrinth::ListModel* listModel = nullptr;
|
||||||
Modrinth::IndexedPack current;
|
ModPlatform::IndexedPack current;
|
||||||
|
|
||||||
int selectedVersion = -1;
|
int selectedVersion = -1;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user