propagate side as enum instead of Qstring
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
178965676e
commit
be963764ea
18 changed files with 89 additions and 131 deletions
|
@ -19,27 +19,16 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "modplatform/packwiz/Packwiz.h"
|
#include "modplatform/packwiz/Packwiz.h"
|
||||||
|
|
||||||
// launcher/minecraft/mod/Mod.h
|
|
||||||
class Mod;
|
|
||||||
|
|
||||||
namespace Metadata {
|
namespace Metadata {
|
||||||
using ModStruct = Packwiz::V1::Mod;
|
using ModStruct = Packwiz::V1::Mod;
|
||||||
using ModSide = Packwiz::V1::Side;
|
|
||||||
|
|
||||||
inline auto create(const QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> ModStruct
|
inline ModStruct create(const QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version)
|
||||||
{
|
{
|
||||||
return Packwiz::V1::createModFormat(index_dir, mod_pack, mod_version);
|
return Packwiz::V1::createModFormat(index_dir, mod_pack, mod_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto create(const QDir& index_dir, Mod& internal_mod, QString mod_slug) -> ModStruct
|
|
||||||
{
|
|
||||||
return Packwiz::V1::createModFormat(index_dir, internal_mod, std::move(mod_slug));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void update(const QDir& index_dir, ModStruct& mod)
|
inline void update(const QDir& index_dir, ModStruct& mod)
|
||||||
{
|
{
|
||||||
Packwiz::V1::updateModIndex(index_dir, mod);
|
Packwiz::V1::updateModIndex(index_dir, mod);
|
||||||
|
@ -50,24 +39,14 @@ inline void remove(const QDir& index_dir, QString mod_slug)
|
||||||
Packwiz::V1::deleteModIndex(index_dir, mod_slug);
|
Packwiz::V1::deleteModIndex(index_dir, mod_slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void remove(const QDir& index_dir, QVariant& mod_id)
|
inline ModStruct get(const QDir& index_dir, QString mod_slug)
|
||||||
{
|
|
||||||
Packwiz::V1::deleteModIndex(index_dir, mod_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline auto get(const QDir& index_dir, QString mod_slug) -> ModStruct
|
|
||||||
{
|
{
|
||||||
return Packwiz::V1::getIndexForMod(index_dir, std::move(mod_slug));
|
return Packwiz::V1::getIndexForMod(index_dir, std::move(mod_slug));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto get(const QDir& index_dir, QVariant& mod_id) -> ModStruct
|
inline ModStruct get(const QDir& index_dir, QVariant& mod_id)
|
||||||
{
|
{
|
||||||
return Packwiz::V1::getIndexForMod(index_dir, mod_id);
|
return Packwiz::V1::getIndexForMod(index_dir, mod_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto modSideToString(ModSide side) -> QString
|
|
||||||
{
|
|
||||||
return Packwiz::V1::sideToString(side);
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace Metadata
|
}; // namespace Metadata
|
||||||
|
|
|
@ -179,9 +179,9 @@ auto Mod::loaders() const -> QString
|
||||||
auto Mod::side() const -> QString
|
auto Mod::side() const -> QString
|
||||||
{
|
{
|
||||||
if (metadata())
|
if (metadata())
|
||||||
return Metadata::modSideToString(metadata()->side);
|
return ModPlatform::SideUtils::toString(metadata()->side);
|
||||||
|
|
||||||
return Metadata::modSideToString(Metadata::ModSide::UniversalSide);
|
return ModPlatform::SideUtils::toString(ModPlatform::Side::UniversalSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Mod::mcVersions() const -> QString
|
auto Mod::mcVersions() const -> QString
|
||||||
|
|
|
@ -152,4 +152,29 @@ auto getModLoaderFromString(QString type) -> ModLoaderType
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SideUtils::toString(Side side)
|
||||||
|
{
|
||||||
|
switch (side) {
|
||||||
|
case Side::ClientSide:
|
||||||
|
return "client";
|
||||||
|
case Side::ServerSide:
|
||||||
|
return "server";
|
||||||
|
case Side::UniversalSide:
|
||||||
|
return "both";
|
||||||
|
case Side::NoSide:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Side SideUtils::fromString(QString side)
|
||||||
|
{
|
||||||
|
if (side == "client")
|
||||||
|
return Side::ClientSide;
|
||||||
|
if (side == "server")
|
||||||
|
return Side::ServerSide;
|
||||||
|
if (side == "both")
|
||||||
|
return Side::UniversalSide;
|
||||||
|
return Side::UniversalSide;
|
||||||
|
}
|
||||||
} // namespace ModPlatform
|
} // namespace ModPlatform
|
||||||
|
|
|
@ -47,6 +47,13 @@ enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK, MODPACK, DATA_PACK };
|
||||||
|
|
||||||
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE, UNKNOWN };
|
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE, UNKNOWN };
|
||||||
|
|
||||||
|
enum class Side { NoSide = 0, ClientSide = 1 << 0, ServerSide = 1 << 1, UniversalSide = ClientSide | ServerSide };
|
||||||
|
|
||||||
|
namespace SideUtils {
|
||||||
|
QString toString(Side side);
|
||||||
|
Side fromString(QString side);
|
||||||
|
} // namespace SideUtils
|
||||||
|
|
||||||
namespace ProviderCapabilities {
|
namespace ProviderCapabilities {
|
||||||
const char* name(ResourceProvider);
|
const char* name(ResourceProvider);
|
||||||
QString readableName(ResourceProvider);
|
QString readableName(ResourceProvider);
|
||||||
|
@ -114,7 +121,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
|
Side 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;
|
||||||
|
@ -145,7 +152,7 @@ struct IndexedPack {
|
||||||
QString logoName;
|
QString logoName;
|
||||||
QString logoUrl;
|
QString logoUrl;
|
||||||
QString websiteUrl;
|
QString websiteUrl;
|
||||||
QString side;
|
Side side;
|
||||||
|
|
||||||
bool versionsLoaded = false;
|
bool versionsLoaded = false;
|
||||||
QList<IndexedVersion> versions;
|
QList<IndexedVersion> versions;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ResourceAPI {
|
||||||
std::optional<SortingMethod> sorting;
|
std::optional<SortingMethod> sorting;
|
||||||
std::optional<ModPlatform::ModLoaderTypes> loaders;
|
std::optional<ModPlatform::ModLoaderTypes> loaders;
|
||||||
std::optional<std::list<Version>> versions;
|
std::optional<std::list<Version>> versions;
|
||||||
std::optional<QString> side;
|
std::optional<ModPlatform::Side> side;
|
||||||
std::optional<QStringList> categoryIds;
|
std::optional<QStringList> categoryIds;
|
||||||
bool openSource;
|
bool openSource;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/flame/FlameAPI.h"
|
#include "modplatform/flame/FlameAPI.h"
|
||||||
|
|
||||||
static FlameAPI api;
|
static FlameAPI api;
|
||||||
|
@ -110,6 +111,7 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
||||||
if (str.contains('.'))
|
if (str.contains('.'))
|
||||||
file.mcVersion.append(str);
|
file.mcVersion.append(str);
|
||||||
|
|
||||||
|
file.side = ModPlatform::Side::NoSide;
|
||||||
if (auto loader = str.toLower(); loader == "neoforge")
|
if (auto loader = str.toLower(); loader == "neoforge")
|
||||||
file.loaders |= ModPlatform::NeoForge;
|
file.loaders |= ModPlatform::NeoForge;
|
||||||
else if (loader == "forge")
|
else if (loader == "forge")
|
||||||
|
@ -123,10 +125,10 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
||||||
else if (loader == "quilt")
|
else if (loader == "quilt")
|
||||||
file.loaders |= ModPlatform::Quilt;
|
file.loaders |= ModPlatform::Quilt;
|
||||||
else if (loader == "server" || loader == "client") {
|
else if (loader == "server" || loader == "client") {
|
||||||
if (file.side.isEmpty())
|
if (file.side == ModPlatform::Side::NoSide)
|
||||||
file.side = loader;
|
file.side = ModPlatform::SideUtils::fromString(loader);
|
||||||
else if (file.side != loader)
|
else if (file.side != ModPlatform::SideUtils::fromString(loader))
|
||||||
file.side = "both";
|
file.side = ModPlatform::Side::UniversalSide;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,18 +69,20 @@ class ModrinthAPI : public NetworkResourceAPI {
|
||||||
return l.join(',');
|
return l.join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto getSideFilters(QString side) -> const QString
|
static QString getSideFilters(ModPlatform::Side side)
|
||||||
{
|
{
|
||||||
if (side.isEmpty()) {
|
switch (side) {
|
||||||
|
case ModPlatform::Side::ClientSide:
|
||||||
|
return QString("\"client_side:required\",\"client_side:optional\"],[\"server_side:optional\",\"server_side:unsupported\"");
|
||||||
|
case ModPlatform::Side::ServerSide:
|
||||||
|
return QString("\"server_side:required\",\"server_side:optional\"],[\"client_side:optional\",\"client_side:unsupported\"");
|
||||||
|
case ModPlatform::Side::UniversalSide:
|
||||||
|
return QString("\"client_side:required\"],[\"server_side:required\"");
|
||||||
|
case ModPlatform::Side::NoSide:
|
||||||
|
// fallthrough
|
||||||
|
default:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (side == "both")
|
|
||||||
return QString("\"client_side:required\"],[\"server_side:required\"");
|
|
||||||
if (side == "client")
|
|
||||||
return QString("\"client_side:required\",\"client_side:optional\"],[\"server_side:optional\",\"server_side:unsupported\"");
|
|
||||||
if (side == "server")
|
|
||||||
return QString("\"server_side:required\",\"server_side:optional\"],[\"client_side:optional\",\"client_side:unsupported\"");
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] static inline QString mapMCVersionFromModrinth(QString v)
|
[[nodiscard]] static inline QString mapMCVersionFromModrinth(QString v)
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "minecraft/mod/MetadataHandler.h"
|
#include "minecraft/mod/MetadataHandler.h"
|
||||||
#include "minecraft/mod/ModFolderModel.h"
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/helpers/HashUtils.h"
|
#include "modplatform/helpers/HashUtils.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ QByteArray ModrinthPackExportTask::generateIndex()
|
||||||
|
|
||||||
// a server side mod does not imply that the mod does not work on the client
|
// a server side mod does not imply that the mod does not work on the client
|
||||||
// however, if a mrpack mod is marked as server-only it will not install on the client
|
// however, if a mrpack mod is marked as server-only it will not install on the client
|
||||||
if (iterator->side == Metadata::ModSide::ClientSide)
|
if (iterator->side == ModPlatform::Side::ClientSide)
|
||||||
env["server"] = "unsupported";
|
env["server"] = "unsupported";
|
||||||
|
|
||||||
fileOut["env"] = env;
|
fileOut["env"] = env;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "modplatform/modrinth/ModrinthAPI.h"
|
#include "modplatform/modrinth/ModrinthAPI.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ class ModrinthPackExportTask : public Task {
|
||||||
struct ResolvedFile {
|
struct ResolvedFile {
|
||||||
QString sha1, sha512, url;
|
QString sha1, sha512, url;
|
||||||
qint64 size;
|
qint64 size;
|
||||||
Metadata::ModSide side;
|
ModPlatform::Side side;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const QStringList PREFIXES;
|
static const QStringList PREFIXES;
|
||||||
|
|
|
@ -63,11 +63,11 @@ void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||||
auto server = shouldDownloadOnSide(Json::ensureString(obj, "server_side"));
|
auto server = shouldDownloadOnSide(Json::ensureString(obj, "server_side"));
|
||||||
|
|
||||||
if (server && client) {
|
if (server && client) {
|
||||||
pack.side = "both";
|
pack.side = ModPlatform::Side::UniversalSide;
|
||||||
} else if (server) {
|
} else if (server) {
|
||||||
pack.side = "server";
|
pack.side = ModPlatform::Side::ServerSide;
|
||||||
} else if (client) {
|
} else if (client) {
|
||||||
pack.side = "client";
|
pack.side = ModPlatform::Side::ClientSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modrinth can have more data than what's provided by the basic search :)
|
// Modrinth can have more data than what's provided by the basic search :)
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
#include "minecraft/mod/Mod.h"
|
|
||||||
#include "modplatform/ModIndex.h"
|
#include "modplatform/ModIndex.h"
|
||||||
|
|
||||||
#include <toml++/toml.h>
|
#include <toml++/toml.h>
|
||||||
|
@ -113,7 +112,7 @@ auto V1::createModFormat([[maybe_unused]] const QDir& index_dir,
|
||||||
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_version.side.isEmpty() ? mod_pack.side : mod_version.side);
|
mod.side = mod_version.side == ModPlatform::Side::NoSide ? mod_pack.side : mod_version.side;
|
||||||
mod.loaders = mod_version.loaders;
|
mod.loaders = mod_version.loaders;
|
||||||
mod.mcVersions = mod_version.mcVersion;
|
mod.mcVersions = mod_version.mcVersion;
|
||||||
mod.mcVersions.sort();
|
mod.mcVersions.sort();
|
||||||
|
@ -126,18 +125,6 @@ auto V1::createModFormat([[maybe_unused]] const QDir& index_dir,
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto V1::createModFormat(const QDir& index_dir, [[maybe_unused]] ::Mod& internal_mod, QString slug) -> Mod
|
|
||||||
{
|
|
||||||
// Try getting metadata if it exists
|
|
||||||
Mod mod{ getIndexForMod(index_dir, slug) };
|
|
||||||
if (mod.isValid())
|
|
||||||
return mod;
|
|
||||||
|
|
||||||
qWarning() << QString("Tried to create mod metadata with a Mod without metadata!");
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void V1::updateModIndex(const QDir& index_dir, Mod& mod)
|
void V1::updateModIndex(const QDir& index_dir, Mod& mod)
|
||||||
{
|
{
|
||||||
if (!mod.isValid()) {
|
if (!mod.isValid()) {
|
||||||
|
@ -208,7 +195,7 @@ void V1::updateModIndex(const 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", ModPlatform::SideUtils::toString(mod.side).toStdString() },
|
||||||
{ "x-prismlauncher-loaders", loaders },
|
{ "x-prismlauncher-loaders", loaders },
|
||||||
{ "x-prismlauncher-mc-versions", mcVersions },
|
{ "x-prismlauncher-mc-versions", mcVersions },
|
||||||
{ "x-prismlauncher-release-type", mod.releaseType.toString().toStdString() },
|
{ "x-prismlauncher-release-type", mod.releaseType.toString().toStdString() },
|
||||||
|
@ -249,18 +236,6 @@ void V1::deleteModIndex(const QDir& index_dir, QString& mod_slug)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V1::deleteModIndex(const QDir& index_dir, QVariant& mod_id)
|
|
||||||
{
|
|
||||||
for (auto& file_name : index_dir.entryList(QDir::Filter::Files)) {
|
|
||||||
auto mod = getIndexForMod(index_dir, file_name);
|
|
||||||
|
|
||||||
if (mod.mod_id() == mod_id) {
|
|
||||||
deleteModIndex(index_dir, mod.name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto V1::getIndexForMod(const QDir& index_dir, QString slug) -> Mod
|
auto V1::getIndexForMod(const QDir& index_dir, QString slug) -> Mod
|
||||||
{
|
{
|
||||||
Mod mod;
|
Mod mod;
|
||||||
|
@ -296,7 +271,7 @@ auto V1::getIndexForMod(const QDir& index_dir, QString slug) -> Mod
|
||||||
{ // Basic info
|
{ // Basic info
|
||||||
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 = ModPlatform::SideUtils::fromString(stringEntry(table, "side"));
|
||||||
mod.releaseType = ModPlatform::IndexedVersionType(table["x-prismlauncher-release-type"].value_or(""));
|
mod.releaseType = ModPlatform::IndexedVersionType(table["x-prismlauncher-release-type"].value_or(""));
|
||||||
if (auto loaders = table["x-prismlauncher-loaders"]; loaders && loaders.is_array()) {
|
if (auto loaders = table["x-prismlauncher-loaders"]; loaders && loaders.is_array()) {
|
||||||
for (auto&& loader : *loaders.as_array()) {
|
for (auto&& loader : *loaders.as_array()) {
|
||||||
|
@ -371,28 +346,4 @@ auto V1::getIndexForMod(const QDir& index_dir, QVariant& mod_id) -> Mod
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto V1::sideToString(Side side) -> QString
|
|
||||||
{
|
|
||||||
switch (side) {
|
|
||||||
case Side::ClientSide:
|
|
||||||
return "client";
|
|
||||||
case Side::ServerSide:
|
|
||||||
return "server";
|
|
||||||
case Side::UniversalSide:
|
|
||||||
return "both";
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto V1::stringToSide(QString side) -> Side
|
|
||||||
{
|
|
||||||
if (side == "client")
|
|
||||||
return Side::ClientSide;
|
|
||||||
if (side == "server")
|
|
||||||
return Side::ServerSide;
|
|
||||||
if (side == "both")
|
|
||||||
return Side::UniversalSide;
|
|
||||||
return Side::UniversalSide;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Packwiz
|
} // namespace Packwiz
|
||||||
|
|
|
@ -27,23 +27,18 @@
|
||||||
|
|
||||||
class QDir;
|
class QDir;
|
||||||
|
|
||||||
// Mod from launcher/minecraft/mod/Mod.h
|
|
||||||
class Mod;
|
|
||||||
|
|
||||||
namespace Packwiz {
|
namespace Packwiz {
|
||||||
|
|
||||||
auto getRealIndexName(const QDir& index_dir, QString normalized_index_name, bool should_match = false) -> QString;
|
auto getRealIndexName(const QDir& index_dir, QString normalized_index_name, bool should_match = false) -> QString;
|
||||||
|
|
||||||
class V1 {
|
class V1 {
|
||||||
public:
|
public:
|
||||||
enum class Side { ClientSide = 1 << 0, ServerSide = 1 << 1, UniversalSide = ClientSide | ServerSide };
|
|
||||||
|
|
||||||
// can also represent other resources beside loader mods - but this is what packwiz calls it
|
// can also represent other resources beside loader mods - but this is what packwiz calls it
|
||||||
struct Mod {
|
struct Mod {
|
||||||
QString slug{};
|
QString slug{};
|
||||||
QString name{};
|
QString name{};
|
||||||
QString filename{};
|
QString filename{};
|
||||||
Side side{ Side::UniversalSide };
|
ModPlatform::Side side{ ModPlatform::Side::UniversalSide };
|
||||||
ModPlatform::ModLoaderTypes loaders;
|
ModPlatform::ModLoaderTypes loaders;
|
||||||
QStringList mcVersions;
|
QStringList mcVersions;
|
||||||
ModPlatform::IndexedVersionType releaseType;
|
ModPlatform::IndexedVersionType releaseType;
|
||||||
|
@ -74,10 +69,6 @@ class V1 {
|
||||||
* its common representation in the launcher, when downloading mods.
|
* its common representation in the launcher, when downloading mods.
|
||||||
* */
|
* */
|
||||||
static auto createModFormat(const QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod;
|
static auto createModFormat(const QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod;
|
||||||
/* Generates the object representing the information in a mod.pw.toml file via
|
|
||||||
* its common representation in the launcher, plus a necessary slug.
|
|
||||||
* */
|
|
||||||
static auto createModFormat(const QDir& index_dir, ::Mod& internal_mod, QString slug) -> Mod;
|
|
||||||
|
|
||||||
/* Updates the mod index for the provided mod.
|
/* Updates the mod index for the provided mod.
|
||||||
* This creates a new index if one does not exist already
|
* This creates a new index if one does not exist already
|
||||||
|
@ -88,9 +79,6 @@ class V1 {
|
||||||
/* Deletes the metadata for the mod with the given slug. If the metadata doesn't exist, it does nothing. */
|
/* Deletes the metadata for the mod with the given slug. If the metadata doesn't exist, it does nothing. */
|
||||||
static void deleteModIndex(const QDir& index_dir, QString& mod_slug);
|
static void deleteModIndex(const QDir& index_dir, QString& mod_slug);
|
||||||
|
|
||||||
/* Deletes the metadata for the mod with the given id. If the metadata doesn't exist, it does nothing. */
|
|
||||||
static void deleteModIndex(const QDir& index_dir, QVariant& mod_id);
|
|
||||||
|
|
||||||
/* Gets the metadata for a mod with a particular file name.
|
/* Gets the metadata for a mod with a particular file name.
|
||||||
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
|
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
|
||||||
* */
|
* */
|
||||||
|
@ -100,9 +88,6 @@ class V1 {
|
||||||
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
|
* If the mod doesn't have a metadata, it simply returns an empty Mod object.
|
||||||
* */
|
* */
|
||||||
static auto getIndexForMod(const QDir& index_dir, QVariant& mod_id) -> Mod;
|
static auto getIndexForMod(const QDir& index_dir, QVariant& mod_id) -> Mod;
|
||||||
|
|
||||||
static auto sideToString(Side side) -> QString;
|
|
||||||
static auto stringToSide(QString side) -> Side;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Packwiz
|
} // namespace Packwiz
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "minecraft/mod/ModFolderModel.h"
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -101,9 +102,10 @@ QVariant ModModel::getInstalledPackVersion(ModPlatform::IndexedPack::Ptr pack) c
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkSide(QString filter, QString value)
|
bool checkSide(ModPlatform::Side filter, ModPlatform::Side value)
|
||||||
{
|
{
|
||||||
return filter.isEmpty() || value.isEmpty() || filter == "both" || value == "both" || filter == value;
|
return filter == ModPlatform::Side::NoSide || value == ModPlatform::Side::NoSide || filter == ModPlatform::Side::UniversalSide ||
|
||||||
|
value == ModPlatform::Side::UniversalSide || filter == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModModel::checkFilters(ModPlatform::IndexedPack::Ptr pack)
|
bool ModModel::checkFilters(ModPlatform::IndexedPack::Ptr pack)
|
||||||
|
|
|
@ -186,8 +186,9 @@ void ListModel::performPaginatedSearch()
|
||||||
sort.index = currentSort + 1;
|
sort.index = currentSort + 1;
|
||||||
|
|
||||||
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
|
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
|
||||||
auto searchUrl = FlameAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort,
|
auto searchUrl =
|
||||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds, m_filter->openSource });
|
FlameAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
||||||
|
m_filter->versions, ModPlatform::Side::NoSide, m_filter->categoryIds, m_filter->openSource });
|
||||||
|
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), response));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), response));
|
||||||
jobPtr = netJob;
|
jobPtr = netJob;
|
||||||
|
|
|
@ -152,8 +152,9 @@ void ModpackListModel::performPaginatedSearch()
|
||||||
} // TODO: Move to standalone API
|
} // TODO: Move to standalone API
|
||||||
ResourceAPI::SortingMethod sort{};
|
ResourceAPI::SortingMethod sort{};
|
||||||
sort.name = currentSort;
|
sort.name = currentSort;
|
||||||
auto searchUrl = ModrinthAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort,
|
auto searchUrl =
|
||||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds, m_filter->openSource });
|
ModrinthAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
||||||
|
m_filter->versions, ModPlatform::Side::NoSide, m_filter->categoryIds, m_filter->openSource });
|
||||||
|
|
||||||
auto netJob = makeShared<NetJob>("Modrinth::SearchModpack", APPLICATION->network());
|
auto netJob = makeShared<NetJob>("Modrinth::SearchModpack", APPLICATION->network());
|
||||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), m_allResponse));
|
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), m_allResponse));
|
||||||
|
|
|
@ -218,7 +218,7 @@ void ModFilterWidget::prepareBasicFilter()
|
||||||
m_filter->openSource = false;
|
m_filter->openSource = false;
|
||||||
if (m_instance) {
|
if (m_instance) {
|
||||||
m_filter->hideInstalled = false;
|
m_filter->hideInstalled = false;
|
||||||
m_filter->side = ""; // or "both"
|
m_filter->side = ModPlatform::Side::NoSide; // or "both"
|
||||||
ModPlatform::ModLoaderTypes loaders;
|
ModPlatform::ModLoaderTypes loaders;
|
||||||
if (m_instance->settings()->get("OverrideModDownloadLoaders").toBool()) {
|
if (m_instance->settings()->get("OverrideModDownloadLoaders").toBool()) {
|
||||||
for (auto loader : Json::toStringList(m_instance->settings()->get("ModDownloadLoaders").toString())) {
|
for (auto loader : Json::toStringList(m_instance->settings()->get("ModDownloadLoaders").toString())) {
|
||||||
|
@ -287,16 +287,16 @@ void ModFilterWidget::onLoadersFilterChanged()
|
||||||
|
|
||||||
void ModFilterWidget::onSideFilterChanged()
|
void ModFilterWidget::onSideFilterChanged()
|
||||||
{
|
{
|
||||||
QString side;
|
ModPlatform::Side side;
|
||||||
|
|
||||||
if (ui->clientSide->isChecked() && !ui->serverSide->isChecked()) {
|
if (ui->clientSide->isChecked() && !ui->serverSide->isChecked()) {
|
||||||
side = "client";
|
side = ModPlatform::Side::ClientSide;
|
||||||
} else if (!ui->clientSide->isChecked() && ui->serverSide->isChecked()) {
|
} else if (!ui->clientSide->isChecked() && ui->serverSide->isChecked()) {
|
||||||
side = "server";
|
side = ModPlatform::Side::ServerSide;
|
||||||
} else if (ui->clientSide->isChecked() && ui->serverSide->isChecked()) {
|
} else if (ui->clientSide->isChecked() && ui->serverSide->isChecked()) {
|
||||||
side = "both";
|
side = ModPlatform::Side::UniversalSide;
|
||||||
} else {
|
} else {
|
||||||
side = "";
|
side = ModPlatform::Side::NoSide;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_filter_changed = side != m_filter->side;
|
m_filter_changed = side != m_filter->side;
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ModFilterWidget : public QTabWidget {
|
||||||
std::list<Version> versions;
|
std::list<Version> versions;
|
||||||
std::list<ModPlatform::IndexedVersionType> releases;
|
std::list<ModPlatform::IndexedVersionType> releases;
|
||||||
ModPlatform::ModLoaderTypes loaders;
|
ModPlatform::ModLoaderTypes loaders;
|
||||||
QString side;
|
ModPlatform::Side side;
|
||||||
bool hideInstalled;
|
bool hideInstalled;
|
||||||
QStringList categoryIds;
|
QStringList categoryIds;
|
||||||
bool openSource;
|
bool openSource;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <QTemporaryDir>
|
#include <QTemporaryDir>
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
|
|
||||||
#include <modplatform/packwiz/Packwiz.h>
|
#include <modplatform/packwiz/Packwiz.h>
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ class PackwizTest : public QObject {
|
||||||
|
|
||||||
QCOMPARE(metadata.name, "Borderless Mining");
|
QCOMPARE(metadata.name, "Borderless Mining");
|
||||||
QCOMPARE(metadata.filename, "borderless-mining-1.1.1+1.18.jar");
|
QCOMPARE(metadata.filename, "borderless-mining-1.1.1+1.18.jar");
|
||||||
QCOMPARE(metadata.side, Packwiz::V1::Side::ClientSide);
|
QCOMPARE(metadata.side, ModPlatform::Side::ClientSide);
|
||||||
|
|
||||||
QCOMPARE(metadata.url, QUrl("https://cdn.modrinth.com/data/kYq5qkSL/versions/1.1.1+1.18/borderless-mining-1.1.1+1.18.jar"));
|
QCOMPARE(metadata.url, QUrl("https://cdn.modrinth.com/data/kYq5qkSL/versions/1.1.1+1.18/borderless-mining-1.1.1+1.18.jar"));
|
||||||
QCOMPARE(metadata.hash_format, "sha512");
|
QCOMPARE(metadata.hash_format, "sha512");
|
||||||
|
@ -72,7 +73,7 @@ class PackwizTest : public QObject {
|
||||||
|
|
||||||
QCOMPARE(metadata.name, "Screenshot to Clipboard (Fabric)");
|
QCOMPARE(metadata.name, "Screenshot to Clipboard (Fabric)");
|
||||||
QCOMPARE(metadata.filename, "screenshot-to-clipboard-1.0.7-fabric.jar");
|
QCOMPARE(metadata.filename, "screenshot-to-clipboard-1.0.7-fabric.jar");
|
||||||
QCOMPARE(metadata.side, Packwiz::V1::Side::UniversalSide);
|
QCOMPARE(metadata.side, ModPlatform::Side::UniversalSide);
|
||||||
|
|
||||||
QCOMPARE(metadata.url, QUrl("https://edge.forgecdn.net/files/3509/43/screenshot-to-clipboard-1.0.7-fabric.jar"));
|
QCOMPARE(metadata.url, QUrl("https://edge.forgecdn.net/files/3509/43/screenshot-to-clipboard-1.0.7-fabric.jar"));
|
||||||
QCOMPARE(metadata.hash_format, "murmur2");
|
QCOMPARE(metadata.hash_format, "murmur2");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue