corected side and added loaders
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
7015b8f7b2
commit
ab725eeb18
@ -117,7 +117,7 @@ QString getMetaURL(ResourceProvider provider, QVariant projectID)
|
|||||||
projectID.toString();
|
projectID.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getModLoaderString(ModLoaderType type) -> const QString
|
auto getModLoaderAsString(ModLoaderType type) -> const QString
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NeoForge:
|
case NeoForge:
|
||||||
@ -138,4 +138,21 @@ auto getModLoaderString(ModLoaderType type) -> const QString
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto getModLoaderFromString(QString type) -> const ModLoaderType
|
||||||
|
{
|
||||||
|
if (type == "neoforge")
|
||||||
|
return NeoForge;
|
||||||
|
if (type == "forge")
|
||||||
|
return Forge;
|
||||||
|
if (type == "cauldron")
|
||||||
|
return Cauldron;
|
||||||
|
if (type == "liteloader")
|
||||||
|
return LiteLoader;
|
||||||
|
if (type == "fabric")
|
||||||
|
return Fabric;
|
||||||
|
if (type == "quilt")
|
||||||
|
return Quilt;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ModPlatform
|
} // namespace ModPlatform
|
||||||
|
@ -109,6 +109,7 @@ struct IndexedVersion {
|
|||||||
bool is_preferred = true;
|
bool is_preferred = true;
|
||||||
QString changelog;
|
QString changelog;
|
||||||
QList<Dependency> dependencies;
|
QList<Dependency> dependencies;
|
||||||
|
QString side; // this is for flame API
|
||||||
|
|
||||||
// For internal use, not provided by APIs
|
// For internal use, not provided by APIs
|
||||||
bool is_currently_selected = false;
|
bool is_currently_selected = false;
|
||||||
@ -181,7 +182,8 @@ inline auto getOverrideDeps() -> QList<OverrideDep>
|
|||||||
|
|
||||||
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
||||||
|
|
||||||
auto getModLoaderString(ModLoaderType type) -> const QString;
|
auto getModLoaderAsString(ModLoaderType type) -> const QString;
|
||||||
|
auto getModLoaderFromString(QString type) -> const ModLoaderType;
|
||||||
|
|
||||||
constexpr bool hasSingleModLoaderSelected(ModLoaderTypes l) noexcept
|
constexpr bool hasSingleModLoaderSelected(ModLoaderTypes l) noexcept
|
||||||
{
|
{
|
||||||
|
@ -130,6 +130,12 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
|||||||
file.loaders |= ModPlatform::Fabric;
|
file.loaders |= ModPlatform::Fabric;
|
||||||
if (loader == "quilt")
|
if (loader == "quilt")
|
||||||
file.loaders |= ModPlatform::Quilt;
|
file.loaders |= ModPlatform::Quilt;
|
||||||
|
if (loader == "server" || loader == "client") {
|
||||||
|
if (file.side.isEmpty())
|
||||||
|
file.side = loader;
|
||||||
|
else if (file.side != loader)
|
||||||
|
file.side = "both";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file.addonId = Json::requireInteger(obj, "modId");
|
file.addonId = Json::requireInteger(obj, "modId");
|
||||||
|
@ -41,7 +41,7 @@ class ModrinthAPI : public NetworkResourceAPI {
|
|||||||
for (auto loader :
|
for (auto loader :
|
||||||
{ ModPlatform::NeoForge, ModPlatform::Forge, ModPlatform::Fabric, ModPlatform::Quilt, ModPlatform::LiteLoader }) {
|
{ ModPlatform::NeoForge, ModPlatform::Forge, ModPlatform::Fabric, ModPlatform::Quilt, ModPlatform::LiteLoader }) {
|
||||||
if (types & loader) {
|
if (types & loader) {
|
||||||
l << getModLoaderString(loader);
|
l << getModLoaderAsString(loader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
|
@ -113,7 +113,8 @@ auto V1::createModFormat([[maybe_unused]] QDir& index_dir, ModPlatform::IndexedP
|
|||||||
mod.provider = mod_pack.provider;
|
mod.provider = mod_pack.provider;
|
||||||
mod.file_id = mod_version.fileId;
|
mod.file_id = mod_version.fileId;
|
||||||
mod.project_id = mod_pack.addonId;
|
mod.project_id = mod_pack.addonId;
|
||||||
mod.side = stringToSide(mod_pack.side);
|
mod.side = stringToSide(mod_version.side.isEmpty() ? mod_pack.side : mod_version.side);
|
||||||
|
mod.loaders = mod_version.loaders;
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
@ -181,6 +182,14 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toml::array loaders;
|
||||||
|
for (auto loader : { ModPlatform::NeoForge, ModPlatform::Forge, ModPlatform::Cauldron, ModPlatform::LiteLoader, ModPlatform::Fabric,
|
||||||
|
ModPlatform::Quilt }) {
|
||||||
|
if (mod.loaders & loader) {
|
||||||
|
loaders.push_back(getModLoaderAsString(loader));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!index_file.open(QIODevice::ReadWrite)) {
|
if (!index_file.open(QIODevice::ReadWrite)) {
|
||||||
qCritical() << QString("Could not open file %1!").arg(normalized_fname);
|
qCritical() << QString("Could not open file %1!").arg(normalized_fname);
|
||||||
return;
|
return;
|
||||||
@ -192,6 +201,7 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
|||||||
auto tbl = toml::table{ { "name", mod.name.toStdString() },
|
auto tbl = toml::table{ { "name", mod.name.toStdString() },
|
||||||
{ "filename", mod.filename.toStdString() },
|
{ "filename", mod.filename.toStdString() },
|
||||||
{ "side", sideToString(mod.side).toStdString() },
|
{ "side", sideToString(mod.side).toStdString() },
|
||||||
|
{ "loader", loaders },
|
||||||
{ "download",
|
{ "download",
|
||||||
toml::table{
|
toml::table{
|
||||||
{ "mode", mod.mode.toStdString() },
|
{ "mode", mod.mode.toStdString() },
|
||||||
@ -276,6 +286,13 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
|
|||||||
mod.name = stringEntry(table, "name");
|
mod.name = stringEntry(table, "name");
|
||||||
mod.filename = stringEntry(table, "filename");
|
mod.filename = stringEntry(table, "filename");
|
||||||
mod.side = stringToSide(stringEntry(table, "side"));
|
mod.side = stringToSide(stringEntry(table, "side"));
|
||||||
|
if (auto loaders = table["loaders"]; loaders && loaders.is_array()) {
|
||||||
|
for (auto&& loader : *loaders.as_array()) {
|
||||||
|
if (loader.is_string()) {
|
||||||
|
mod.loaders |= ModPlatform::getModLoaderFromString(QString::fromStdString(loader.as_string()->value_or("")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // [download] info
|
{ // [download] info
|
||||||
|
@ -41,6 +41,7 @@ class V1 {
|
|||||||
QString name{};
|
QString name{};
|
||||||
QString filename{};
|
QString filename{};
|
||||||
Side side{ Side::UniversalSide };
|
Side side{ Side::UniversalSide };
|
||||||
|
ModPlatform::ModLoaderTypes loaders;
|
||||||
|
|
||||||
// [download]
|
// [download]
|
||||||
QString mode{};
|
QString mode{};
|
||||||
|
Loading…
Reference in New Issue
Block a user