mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 13:17:41 +02:00
Merge remote-tracking branch 'upstream/develop' into resource-meta
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
||||
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -112,10 +113,14 @@ auto V1::createModFormat([[maybe_unused]] const QDir& index_dir,
|
||||
mod.provider = mod_pack.provider;
|
||||
mod.file_id = mod_version.fileId;
|
||||
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;
|
||||
mod.mcVersions = mod_version.mcVersion;
|
||||
mod.mcVersions.sort();
|
||||
mod.releaseType = mod_version.version_type;
|
||||
|
||||
mod.version_number = mod_version.version_number;
|
||||
if (mod.version_number.isNull()) // on CurseForge, there is only a version name - not a versio
|
||||
if (mod.version_number.isNull()) // on CurseForge, there is only a version name - not a version number
|
||||
mod.version_number = mod_version.version;
|
||||
|
||||
return mod;
|
||||
@ -184,6 +189,18 @@ void V1::updateModIndex(const QDir& index_dir, Mod& mod)
|
||||
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).toStdString());
|
||||
}
|
||||
}
|
||||
toml::array mcVersions;
|
||||
for (auto version : mod.mcVersions) {
|
||||
mcVersions.push_back(version.toStdString());
|
||||
}
|
||||
|
||||
if (!index_file.open(QIODevice::ReadWrite)) {
|
||||
qCritical() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
return;
|
||||
@ -195,6 +212,9 @@ void V1::updateModIndex(const QDir& index_dir, Mod& mod)
|
||||
auto tbl = toml::table{ { "name", mod.name.toStdString() },
|
||||
{ "filename", mod.filename.toStdString() },
|
||||
{ "side", sideToString(mod.side).toStdString() },
|
||||
{ "loaders", loaders },
|
||||
{ "mcVersions", mcVersions },
|
||||
{ "releaseType", mod.releaseType.toString().toStdString() },
|
||||
{ "download",
|
||||
toml::table{
|
||||
{ "mode", mod.mode.toStdString() },
|
||||
@ -279,6 +299,25 @@ auto V1::getIndexForMod(const QDir& index_dir, QString slug) -> Mod
|
||||
mod.name = stringEntry(table, "name");
|
||||
mod.filename = stringEntry(table, "filename");
|
||||
mod.side = stringToSide(stringEntry(table, "side"));
|
||||
mod.releaseType = ModPlatform::IndexedVersionType(stringEntry(table, "releaseType"));
|
||||
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("")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (auto versions = table["mcVersions"]; versions && versions.is_array()) {
|
||||
for (auto&& version : *versions.as_array()) {
|
||||
if (version.is_string()) {
|
||||
auto ver = QString::fromStdString(version.as_string()->value_or(""));
|
||||
if (!ver.isEmpty()) {
|
||||
mod.mcVersions << ver;
|
||||
}
|
||||
}
|
||||
}
|
||||
mod.mcVersions.sort();
|
||||
}
|
||||
}
|
||||
|
||||
{ // [download] info
|
||||
|
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
||||
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -43,6 +44,9 @@ class V1 {
|
||||
QString name{};
|
||||
QString filename{};
|
||||
Side side{ Side::UniversalSide };
|
||||
ModPlatform::ModLoaderTypes loaders;
|
||||
QStringList mcVersions;
|
||||
ModPlatform::IndexedVersionType releaseType;
|
||||
|
||||
// [download]
|
||||
QString mode{};
|
||||
|
Reference in New Issue
Block a user