2022-03-03 02:01:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-04-20 01:10:12 +01:00
|
|
|
#include "modplatform/ModIndex.h"
|
2022-03-07 19:46:08 +00:00
|
|
|
#include "modplatform/helpers/NetworkModAPI.h"
|
2022-03-07 19:22:57 +00:00
|
|
|
|
2022-03-07 19:46:08 +00:00
|
|
|
class FlameAPI : public NetworkModAPI {
|
2022-06-03 23:06:51 +01:00
|
|
|
public:
|
2022-07-10 19:15:25 +01:00
|
|
|
auto matchFingerprints(const QList<uint>& fingerprints, QByteArray* response) -> NetJob::Ptr;
|
2022-06-03 23:06:51 +01:00
|
|
|
auto getModFileChangelog(int modId, int fileId) -> QString;
|
2022-07-19 15:50:38 +01:00
|
|
|
auto getModDescription(int modId) -> QString;
|
2022-06-03 23:06:51 +01:00
|
|
|
|
|
|
|
auto getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::IndexedVersion;
|
|
|
|
|
2022-06-28 11:09:58 +01:00
|
|
|
auto getProjects(QStringList addonIds, QByteArray* response) const -> NetJob* override;
|
2022-06-19 18:29:21 +01:00
|
|
|
|
2022-05-08 08:22:50 +01:00
|
|
|
private:
|
|
|
|
inline auto getSortFieldInt(QString sortString) const -> int
|
|
|
|
{
|
|
|
|
return sortString == "Featured" ? 1
|
|
|
|
: sortString == "Popularity" ? 2
|
|
|
|
: sortString == "LastUpdated" ? 3
|
|
|
|
: sortString == "Name" ? 4
|
|
|
|
: sortString == "Author" ? 5
|
|
|
|
: sortString == "TotalDownloads" ? 6
|
|
|
|
: sortString == "Category" ? 7
|
|
|
|
: sortString == "GameVersion" ? 8
|
|
|
|
: 1;
|
|
|
|
}
|
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
private:
|
2022-03-08 14:12:35 +00:00
|
|
|
inline auto getModSearchURL(SearchArgs& args) const -> QString override
|
2022-03-07 19:22:57 +00:00
|
|
|
{
|
2022-04-03 00:08:37 +01:00
|
|
|
auto gameVersionStr = args.versions.size() != 0 ? QString("gameVersion=%1").arg(args.versions.front().toString()) : QString();
|
|
|
|
|
2022-03-07 19:22:57 +00:00
|
|
|
return QString(
|
2022-05-08 08:22:50 +01:00
|
|
|
"https://api.curseforge.com/v1/mods/search?"
|
2022-03-07 19:22:57 +00:00
|
|
|
"gameId=432&"
|
2022-05-08 08:22:50 +01:00
|
|
|
"classId=6&"
|
2022-03-07 19:22:57 +00:00
|
|
|
|
|
|
|
"index=%1&"
|
|
|
|
"pageSize=25&"
|
|
|
|
"searchFilter=%2&"
|
2022-05-08 08:22:50 +01:00
|
|
|
"sortField=%3&"
|
|
|
|
"sortOrder=desc&"
|
2022-03-07 19:22:57 +00:00
|
|
|
"modLoaderType=%4&"
|
2022-04-03 00:08:37 +01:00
|
|
|
"%5")
|
2022-03-07 19:22:57 +00:00
|
|
|
.arg(args.offset)
|
|
|
|
.arg(args.search)
|
2022-05-08 08:22:50 +01:00
|
|
|
.arg(getSortFieldInt(args.sorting))
|
2022-05-19 07:40:28 +01:00
|
|
|
.arg(getMappedModLoader(args.loaders))
|
2022-04-03 00:08:37 +01:00
|
|
|
.arg(gameVersionStr);
|
2022-03-03 02:01:23 +00:00
|
|
|
};
|
|
|
|
|
2022-05-24 16:14:08 +01:00
|
|
|
inline auto getModInfoURL(QString& id) const -> QString override
|
|
|
|
{
|
|
|
|
return QString("https://api.curseforge.com/v1/mods/%1").arg(id);
|
|
|
|
};
|
2022-05-24 13:38:48 +01:00
|
|
|
|
2022-03-24 21:39:53 +00:00
|
|
|
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
2022-03-03 02:01:23 +00:00
|
|
|
{
|
2022-05-08 08:22:50 +01:00
|
|
|
QString gameVersionQuery = args.mcVersions.size() == 1 ? QString("gameVersion=%1&").arg(args.mcVersions.front().toString()) : "";
|
2022-05-19 07:40:28 +01:00
|
|
|
QString modLoaderQuery = QString("modLoaderType=%1&").arg(getMappedModLoader(args.loaders));
|
2022-05-08 08:22:50 +01:00
|
|
|
|
|
|
|
return QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&%2%3")
|
|
|
|
.arg(args.addonId)
|
|
|
|
.arg(gameVersionQuery)
|
|
|
|
.arg(modLoaderQuery);
|
2022-03-03 02:01:23 +00:00
|
|
|
};
|
2022-04-15 11:38:27 +01:00
|
|
|
|
|
|
|
public:
|
2022-06-17 15:34:32 +01:00
|
|
|
static auto getMappedModLoader(const ModLoaderTypes loaders) -> int
|
2022-04-15 11:38:27 +01:00
|
|
|
{
|
2022-05-19 07:40:28 +01:00
|
|
|
// https://docs.curseforge.com/?http#tocS_ModLoaderType
|
|
|
|
if (loaders & Forge)
|
|
|
|
return 1;
|
|
|
|
if (loaders & Fabric)
|
|
|
|
return 4;
|
2022-04-15 11:38:27 +01:00
|
|
|
// TODO: remove this once Quilt drops official Fabric support
|
2022-05-19 07:40:28 +01:00
|
|
|
if (loaders & Quilt) // NOTE: Most if not all Fabric mods should work *currently*
|
|
|
|
return 4; // Quilt would probably be 5
|
|
|
|
return 0;
|
2022-04-15 11:38:27 +01:00
|
|
|
}
|
2022-03-03 02:01:23 +00:00
|
|
|
};
|