Added back api loader filtering if just one is selected
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
abfd1a4205
commit
288d0d1fd4
@ -152,6 +152,12 @@ QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
|||||||
|
|
||||||
auto getModLoaderString(ModLoaderType type) -> const QString;
|
auto getModLoaderString(ModLoaderType type) -> const QString;
|
||||||
|
|
||||||
|
constexpr bool hasSingleModLoaderSelected(ModLoaderTypes l) noexcept
|
||||||
|
{
|
||||||
|
auto x = static_cast<int>(l);
|
||||||
|
return x && !(x & (x - 1));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ModPlatform
|
} // namespace ModPlatform
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
||||||
|
@ -135,11 +135,6 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
m_checkJob->start();
|
m_checkJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool has_single_bit(int x) noexcept
|
|
||||||
{
|
|
||||||
return x && !(x & (x - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Flame::FileResolvingTask::modrinthCheckFinished()
|
void Flame::FileResolvingTask::modrinthCheckFinished()
|
||||||
{
|
{
|
||||||
setProgress(2, 3);
|
setProgress(2, 3);
|
||||||
@ -159,7 +154,7 @@ void Flame::FileResolvingTask::modrinthCheckFinished()
|
|||||||
// If there's more than one mod loader for this version, we can't know for sure
|
// If there's more than one mod loader for this version, we can't know for sure
|
||||||
// which file is relative to each loader, so it's best to not use any one and
|
// which file is relative to each loader, so it's best to not use any one and
|
||||||
// let the user download it manually.
|
// let the user download it manually.
|
||||||
if (!file.loaders || has_single_bit(file.loaders)) {
|
if (!file.loaders || hasSingleModLoaderSelected(file.loaders)) {
|
||||||
out->url = file.downloadUrl;
|
out->url = file.downloadUrl;
|
||||||
qDebug() << "Found alternative on modrinth " << out->fileName;
|
qDebug() << "Found alternative on modrinth " << out->fileName;
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,12 +111,23 @@ class FlameAPI : public NetworkResourceAPI {
|
|||||||
|
|
||||||
if (args.mcVersions.has_value())
|
if (args.mcVersions.has_value())
|
||||||
url += QString("&gameVersion=%1").arg(args.mcVersions.value().front().toString());
|
url += QString("&gameVersion=%1").arg(args.mcVersions.value().front().toString());
|
||||||
|
|
||||||
|
if (args.loaders.has_value() && ModPlatform::hasSingleModLoaderSelected(args.loaders.value())) {
|
||||||
|
int mappedModLoader = getMappedModLoader(static_cast<ModPlatform::ModLoaderType>(static_cast<int>(args.loaders.value())));
|
||||||
|
url += QString("&modLoaderType=%1").arg(mappedModLoader);
|
||||||
|
}
|
||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] std::optional<QString> getDependencyURL(DependencySearchArgs const& args) const override
|
[[nodiscard]] std::optional<QString> getDependencyURL(DependencySearchArgs const& args) const override
|
||||||
{
|
{
|
||||||
auto addonId = args.dependency.addonId.toString();
|
auto addonId = args.dependency.addonId.toString();
|
||||||
return QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&gameVersion=%2").arg(addonId, args.mcVersion.toString());
|
auto url =
|
||||||
|
QString("https://api.curseforge.com/v1/mods/%1/files?pageSize=10000&gameVersion=%2").arg(addonId, args.mcVersion.toString());
|
||||||
|
if (args.loader && ModPlatform::hasSingleModLoaderSelected(args.loader)) {
|
||||||
|
int mappedModLoader = getMappedModLoader(static_cast<ModPlatform::ModLoaderType>(static_cast<int>(args.loader)));
|
||||||
|
url += QString("&modLoaderType=%1").arg(mappedModLoader);
|
||||||
|
}
|
||||||
|
return url;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user