diff options
| author | flow <flowlnlnln@gmail.com> | 2022-05-24 09:38:48 -0300 |
|---|---|---|
| committer | flow <flowlnlnln@gmail.com> | 2022-05-24 09:38:48 -0300 |
| commit | ca3c6c5e8a5151ea50e51f09938b894e6a610626 (patch) | |
| tree | 57d2587ee294894015ecfcaa98b5e035f2a787b0 /launcher/modplatform/modrinth | |
| parent | 3cc26b15a1a99860b1c2a9c69bc434479b4627bb (diff) | |
| download | PrismLauncher-ca3c6c5e8a5151ea50e51f09938b894e6a610626.tar.gz PrismLauncher-ca3c6c5e8a5151ea50e51f09938b894e6a610626.tar.bz2 PrismLauncher-ca3c6c5e8a5151ea50e51f09938b894e6a610626.zip | |
feat: add donate links for modrinth mods
Diffstat (limited to 'launcher/modplatform/modrinth')
| -rw-r--r-- | launcher/modplatform/modrinth/ModrinthAPI.h | 5 | ||||
| -rw-r--r-- | launcher/modplatform/modrinth/ModrinthPackIndex.cpp | 21 | ||||
| -rw-r--r-- | launcher/modplatform/modrinth/ModrinthPackIndex.h | 1 |
3 files changed, 27 insertions, 0 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h index 79bc5175..13b62f0c 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.h +++ b/launcher/modplatform/modrinth/ModrinthAPI.h @@ -75,6 +75,11 @@ class ModrinthAPI : public NetworkModAPI { .arg(getGameVersionsArray(args.versions)); }; + inline auto getModInfoURL(QString& id) const -> QString override + { + return BuildConfig.MODRINTH_PROD_URL + "/project/" + id; + }; + inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override { return QString(BuildConfig.MODRINTH_PROD_URL + diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp index f7fa9864..32b4cfd4 100644 --- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp +++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp @@ -45,6 +45,27 @@ void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj) modAuthor.name = Json::requireString(obj, "author"); modAuthor.url = api.getAuthorURL(modAuthor.name); pack.authors.append(modAuthor); + + // Modrinth can have more data than what's provided by the basic search :) + pack.extraDataLoaded = false; +} + +void Modrinth::loadExtraPackData(ModPlatform::IndexedPack& pack, QJsonObject& obj) +{ + auto donate_arr = Json::ensureArray(obj, "donation_urls"); + for(auto d : donate_arr){ + auto d_obj = Json::requireObject(d); + + ModPlatform::DonationData donate; + + donate.id = Json::ensureString(d_obj, "id"); + donate.platform = Json::ensureString(d_obj, "platform"); + donate.url = Json::ensureString(d_obj, "url"); + + pack.extraData.donate.append(donate); + } + + pack.extraDataLoaded = true; } void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack, diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.h b/launcher/modplatform/modrinth/ModrinthPackIndex.h index 7f306f25..b0e3736f 100644 --- a/launcher/modplatform/modrinth/ModrinthPackIndex.h +++ b/launcher/modplatform/modrinth/ModrinthPackIndex.h @@ -25,6 +25,7 @@ namespace Modrinth { void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj); +void loadExtraPackData(ModPlatform::IndexedPack& m, QJsonObject& obj); void loadIndexedPackVersions(ModPlatform::IndexedPack& pack, QJsonArray& arr, const shared_qobject_ptr<QNetworkAccessManager>& network, |
