2022-03-03 07:31:23 +05:30
|
|
|
#pragma once
|
|
|
|
|
2022-03-08 01:16:08 +05:30
|
|
|
#include "modplatform/helpers/NetworkModAPI.h"
|
2022-03-08 00:52:57 +05:30
|
|
|
|
2022-03-08 01:16:08 +05:30
|
|
|
class FlameAPI : public NetworkModAPI {
|
2022-05-08 12:52:50 +05:30
|
|
|
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-08 00:52:57 +05:30
|
|
|
private:
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto getModSearchURL(SearchArgs& args) const -> QString override
|
2022-03-08 00:52:57 +05:30
|
|
|
{
|
2022-04-03 04:38:37 +05:30
|
|
|
auto gameVersionStr = args.versions.size() != 0 ? QString("gameVersion=%1").arg(args.versions.front().toString()) : QString();
|
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
return QString(
|
2022-05-08 12:52:50 +05:30
|
|
|
"https://api.curseforge.com/v1/mods/search?"
|
2022-03-08 00:52:57 +05:30
|
|
|
"gameId=432&"
|
2022-05-08 12:52:50 +05:30
|
|
|
"classId=6&"
|
2022-03-08 00:52:57 +05:30
|
|
|
|
|
|
|
"index=%1&"
|
|
|
|
"pageSize=25&"
|
|
|
|
"searchFilter=%2&"
|
2022-05-08 12:52:50 +05:30
|
|
|
"sortField=%3&"
|
|
|
|
"sortOrder=desc&"
|
2022-03-08 00:52:57 +05:30
|
|
|
"modLoaderType=%4&"
|
2022-04-03 04:38:37 +05:30
|
|
|
"%5")
|
2022-03-08 00:52:57 +05:30
|
|
|
.arg(args.offset)
|
|
|
|
.arg(args.search)
|
2022-05-08 12:52:50 +05:30
|
|
|
.arg(getSortFieldInt(args.sorting))
|
2022-05-19 12:10:28 +05:30
|
|
|
.arg(getMappedModLoader(args.loaders))
|
2022-04-03 04:38:37 +05:30
|
|
|
.arg(gameVersionStr);
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|
|
|
|
|
2022-03-25 03:09:53 +05:30
|
|
|
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
2022-03-03 07:31:23 +05:30
|
|
|
{
|
2022-05-08 12:52:50 +05:30
|
|
|
QString gameVersionQuery = args.mcVersions.size() == 1 ? QString("gameVersion=%1&").arg(args.mcVersions.front().toString()) : "";
|
2022-05-19 12:10:28 +05:30
|
|
|
QString modLoaderQuery = QString("modLoaderType=%1&").arg(getMappedModLoader(args.loaders));
|
2022-05-08 12:52:50 +05:30
|
|
|
|
|
|
|
return QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&%2%3")
|
|
|
|
.arg(args.addonId)
|
|
|
|
.arg(gameVersionQuery)
|
|
|
|
.arg(modLoaderQuery);
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|
2022-04-15 16:08:27 +05:30
|
|
|
|
|
|
|
public:
|
2022-05-19 12:10:28 +05:30
|
|
|
static auto getMappedModLoader(const ModLoaderTypes loaders) -> const int
|
2022-04-15 16:08:27 +05:30
|
|
|
{
|
2022-05-19 12:10:28 +05:30
|
|
|
// https://docs.curseforge.com/?http#tocS_ModLoaderType
|
|
|
|
if (loaders & Forge)
|
|
|
|
return 1;
|
|
|
|
if (loaders & Fabric)
|
|
|
|
return 4;
|
2022-04-15 16:08:27 +05:30
|
|
|
// TODO: remove this once Quilt drops official Fabric support
|
2022-05-19 12:10:28 +05:30
|
|
|
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 16:08:27 +05:30
|
|
|
}
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|