2022-03-03 02:01:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
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-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-04-15 11:38:27 +01:00
|
|
|
.arg(getMappedModLoader(args.mod_loader))
|
2022-04-03 00:08:37 +01:00
|
|
|
.arg(gameVersionStr);
|
2022-03-03 02:01:23 +00: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()) : "";
|
|
|
|
QString modLoaderQuery = QString("modLoaderType=%1&").arg(getMappedModLoader(args.loader));
|
|
|
|
|
|
|
|
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:
|
|
|
|
static auto getMappedModLoader(const ModLoaderType type) -> const ModLoaderType
|
|
|
|
{
|
|
|
|
// TODO: remove this once Quilt drops official Fabric support
|
|
|
|
if (type == Quilt) // NOTE: Most if not all Fabric mods should work *currently*
|
|
|
|
return Fabric;
|
|
|
|
return type;
|
|
|
|
}
|
2022-03-03 02:01:23 +00:00
|
|
|
};
|