Added dependencies to the APIs
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
95842ee25f
commit
6d5c629b43
@ -32,6 +32,8 @@ enum class ResourceProvider { MODRINTH, FLAME };
|
|||||||
|
|
||||||
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
|
enum class ResourceType { MOD, RESOURCE_PACK, SHADER_PACK };
|
||||||
|
|
||||||
|
enum class DependencyType { REQUIRED, OPTIONAL, INCOMPATIBLE, EMBEDDED, TOOL, INCLUDE };
|
||||||
|
|
||||||
class ProviderCapabilities {
|
class ProviderCapabilities {
|
||||||
public:
|
public:
|
||||||
auto name(ResourceProvider) -> const char*;
|
auto name(ResourceProvider) -> const char*;
|
||||||
@ -51,6 +53,12 @@ struct DonationData {
|
|||||||
QString url;
|
QString url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Dependency {
|
||||||
|
QVariant addonId;
|
||||||
|
DependencyType type;
|
||||||
|
QString version;
|
||||||
|
};
|
||||||
|
|
||||||
struct IndexedVersion {
|
struct IndexedVersion {
|
||||||
QVariant addonId;
|
QVariant addonId;
|
||||||
QVariant fileId;
|
QVariant fileId;
|
||||||
@ -65,6 +73,7 @@ struct IndexedVersion {
|
|||||||
QString hash;
|
QString hash;
|
||||||
bool is_preferred = true;
|
bool is_preferred = true;
|
||||||
QString changelog;
|
QString changelog;
|
||||||
|
QList<Dependency> dependencies;
|
||||||
|
|
||||||
// For internal use, not provided by APIs
|
// For internal use, not provided by APIs
|
||||||
bool is_currently_selected = false;
|
bool is_currently_selected = false;
|
||||||
|
@ -136,7 +136,35 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(load_changelog)
|
auto dependencies = Json::ensureArray(obj, "dependencies");
|
||||||
|
for (auto d : dependencies) {
|
||||||
|
auto dep = Json::ensureObject(d);
|
||||||
|
ModPlatform::Dependency dependency;
|
||||||
|
dependency.addonId = Json::requireInteger(dep, "modId");
|
||||||
|
switch (Json::requireInteger(dep, "relationType")) {
|
||||||
|
case 1: // EmbeddedLibrary
|
||||||
|
dependency.type = ModPlatform::DependencyType::EMBEDDED;
|
||||||
|
break;
|
||||||
|
case 2: // OptionalDependency
|
||||||
|
dependency.type = ModPlatform::DependencyType::OPTIONAL;
|
||||||
|
break;
|
||||||
|
case 3: // RequiredDependency
|
||||||
|
dependency.type = ModPlatform::DependencyType::REQUIRED;
|
||||||
|
break;
|
||||||
|
case 4: // Tool
|
||||||
|
dependency.type = ModPlatform::DependencyType::TOOL;
|
||||||
|
break;
|
||||||
|
case 5: // Incompatible
|
||||||
|
dependency.type = ModPlatform::DependencyType::INCOMPATIBLE;
|
||||||
|
break;
|
||||||
|
case 6: // Include
|
||||||
|
dependency.type = ModPlatform::DependencyType::INCLUDE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
file.dependencies.append(dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (load_changelog)
|
||||||
file.changelog = api.getModFileChangelog(file.addonId.toInt(), file.fileId.toInt());
|
file.changelog = api.getModFileChangelog(file.addonId.toInt(), file.fileId.toInt());
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
|
|
||||||
static ModrinthAPI api;
|
static ModrinthAPI api;
|
||||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||||
@ -140,6 +139,26 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
|||||||
file.version_number = Json::requireString(obj, "version_number");
|
file.version_number = Json::requireString(obj, "version_number");
|
||||||
file.changelog = Json::requireString(obj, "changelog");
|
file.changelog = Json::requireString(obj, "changelog");
|
||||||
|
|
||||||
|
auto dependencies = Json::ensureArray(obj, "dependencies");
|
||||||
|
for (auto d : dependencies) {
|
||||||
|
auto dep = Json::ensureObject(d);
|
||||||
|
ModPlatform::Dependency dependency;
|
||||||
|
dependency.addonId = Json::requireString(dep, "project_id");
|
||||||
|
dependency.version = Json::requireString(dep, "version_id");
|
||||||
|
auto depType = Json::requireString(dep, "dependency_type");
|
||||||
|
|
||||||
|
if (depType == "required")
|
||||||
|
dependency.type = ModPlatform::DependencyType::REQUIRED;
|
||||||
|
else if (depType == "optional")
|
||||||
|
dependency.type = ModPlatform::DependencyType::OPTIONAL;
|
||||||
|
else if (depType == "incompatible")
|
||||||
|
dependency.type = ModPlatform::DependencyType::INCOMPATIBLE;
|
||||||
|
else if (depType == "embedded")
|
||||||
|
dependency.type = ModPlatform::DependencyType::EMBEDDED;
|
||||||
|
|
||||||
|
file.dependencies.append(dependency);
|
||||||
|
}
|
||||||
|
|
||||||
auto files = Json::requireArray(obj, "files");
|
auto files = Json::requireArray(obj, "files");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user