aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-04-14 23:02:33 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-04-21 18:42:05 +0300
commit4fe497cd682258ca80501be2ad616de7a40043d9 (patch)
treebc5ddd0e5156d946511d6d68f3843807fbf90336 /launcher/modplatform/modrinth/ModrinthPackIndex.cpp
parent5655a3351551aa36aeeba79b0ac7f2474ca74352 (diff)
downloadPrismLauncher-4fe497cd682258ca80501be2ad616de7a40043d9.tar.gz
PrismLauncher-4fe497cd682258ca80501be2ad616de7a40043d9.tar.bz2
PrismLauncher-4fe497cd682258ca80501be2ad616de7a40043d9.zip
First working version with curseforge mods
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/modplatform/modrinth/ModrinthPackIndex.cpp')
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index 8e97ee7c..9f898c39 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -214,3 +214,22 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
return {};
}
+
+auto Modrinth::loadDependencyVersions(ModPlatform::Dependency m, QJsonArray& arr) -> ModPlatform::IndexedVersion
+{
+ QVector<ModPlatform::IndexedVersion> unsortedVersions;
+
+ for (auto versionIter : arr) {
+ auto obj = versionIter.toObject();
+ auto file = loadIndexedPackVersion(obj);
+
+ if (file.fileId.isValid()) // Heuristic to check if the returned value is valid
+ unsortedVersions.append(file);
+ }
+ auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
+ // dates are in RFC 3339 format
+ return a.date > b.date;
+ };
+ std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
+ return unsortedVersions.front();
+} \ No newline at end of file