aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/flame/FlamePackIndex.cpp
diff options
context:
space:
mode:
authortimoreo22 <timo.oreo34@gmail.com>2022-05-09 18:06:56 +0200
committerGitHub <noreply@github.com>2022-05-09 18:06:56 +0200
commit649b8ac7c6e12fcf91d204f908e027d3bfbb6a2a (patch)
tree51e6c30175f5bf6a1c1ab59eb36fdf8050bfb5cd /launcher/modplatform/flame/FlamePackIndex.cpp
parentf7f39854f83002f528c6f05a67f6a3b0500a8038 (diff)
parentda25f3b84eeb61ca8638976a3100e23c5080ae28 (diff)
downloadPrismLauncher-649b8ac7c6e12fcf91d204f908e027d3bfbb6a2a.tar.gz
PrismLauncher-649b8ac7c6e12fcf91d204f908e027d3bfbb6a2a.tar.bz2
PrismLauncher-649b8ac7c6e12fcf91d204f908e027d3bfbb6a2a.zip
Merge pull request #537 from PolyMC/stable
Merge stable into develop
Diffstat (limited to 'launcher/modplatform/flame/FlamePackIndex.cpp')
-rw-r--r--launcher/modplatform/flame/FlamePackIndex.cpp50
1 files changed, 17 insertions, 33 deletions
diff --git a/launcher/modplatform/flame/FlamePackIndex.cpp b/launcher/modplatform/flame/FlamePackIndex.cpp
index 3d8ea22a..549cace6 100644
--- a/launcher/modplatform/flame/FlamePackIndex.cpp
+++ b/launcher/modplatform/flame/FlamePackIndex.cpp
@@ -2,76 +2,63 @@
#include "Json.h"
-void Flame::loadIndexedPack(Flame::IndexedPack & pack, QJsonObject & obj)
+void Flame::loadIndexedPack(Flame::IndexedPack& pack, QJsonObject& obj)
{
pack.addonId = Json::requireInteger(obj, "id");
pack.name = Json::requireString(obj, "name");
pack.websiteUrl = Json::ensureString(obj, "websiteUrl", "");
pack.description = Json::ensureString(obj, "summary", "");
- bool thumbnailFound = false;
- auto attachments = Json::requireArray(obj, "attachments");
- for(auto attachmentRaw: attachments) {
- auto attachmentObj = Json::requireObject(attachmentRaw);
- bool isDefault = attachmentObj.value("isDefault").toBool(false);
- if(isDefault) {
- thumbnailFound = true;
- pack.logoName = Json::requireString(attachmentObj, "title");
- pack.logoUrl = Json::requireString(attachmentObj, "thumbnailUrl");
- break;
- }
- }
-
- if(!thumbnailFound) {
- throw JSONValidationError(QString("Pack without an icon, skipping: %1").arg(pack.name));
- }
+ auto logo = Json::requireObject(obj, "logo");
+ pack.logoName = Json::requireString(logo, "title");
+ pack.logoUrl = Json::requireString(logo, "thumbnailUrl");
auto authors = Json::requireArray(obj, "authors");
- for(auto authorIter: authors) {
+ for (auto authorIter : authors) {
auto author = Json::requireObject(authorIter);
Flame::ModpackAuthor packAuthor;
packAuthor.name = Json::requireString(author, "name");
packAuthor.url = Json::requireString(author, "url");
pack.authors.append(packAuthor);
}
- int defaultFileId = Json::requireInteger(obj, "defaultFileId");
+ int defaultFileId = Json::requireInteger(obj, "mainFileId");
bool found = false;
// check if there are some files before adding the pack
auto files = Json::requireArray(obj, "latestFiles");
- for(auto fileIter: files) {
+ for (auto fileIter : files) {
auto file = Json::requireObject(fileIter);
int id = Json::requireInteger(file, "id");
// NOTE: for now, ignore everything that's not the default...
- if(id != defaultFileId) {
+ if (id != defaultFileId) {
continue;
}
- auto versionArray = Json::requireArray(file, "gameVersion");
- if(versionArray.size() < 1) {
+ auto versionArray = Json::requireArray(file, "gameVersions");
+ if (versionArray.size() < 1) {
continue;
}
found = true;
break;
}
- if(!found) {
+ if (!found) {
throw JSONValidationError(QString("Pack with no good file, skipping: %1").arg(pack.name));
}
}
-void Flame::loadIndexedPackVersions(Flame::IndexedPack & pack, QJsonArray & arr)
+void Flame::loadIndexedPackVersions(Flame::IndexedPack& pack, QJsonArray& arr)
{
QVector<Flame::IndexedVersion> unsortedVersions;
- for(auto versionIter: arr) {
+ for (auto versionIter : arr) {
auto version = Json::requireObject(versionIter);
- Flame::IndexedVersion file;
+ Flame::IndexedVersion file;
file.addonId = pack.addonId;
file.fileId = Json::requireInteger(version, "id");
- auto versionArray = Json::requireArray(version, "gameVersion");
- if(versionArray.size() < 1) {
+ auto versionArray = Json::requireArray(version, "gameVersions");
+ if (versionArray.size() < 1) {
continue;
}
@@ -82,10 +69,7 @@ void Flame::loadIndexedPackVersions(Flame::IndexedPack & pack, QJsonArray & arr)
unsortedVersions.append(file);
}
- auto orderSortPredicate = [](const IndexedVersion & a, const IndexedVersion & b) -> bool
- {
- return a.fileId > b.fileId;
- };
+ auto orderSortPredicate = [](const IndexedVersion& a, const IndexedVersion& b) -> bool { return a.fileId > b.fileId; };
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
pack.versions = unsortedVersions;
pack.versionsLoaded = true;