mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-04 04:16:57 +03:00
suppoer non mods deps
fixes #3962 Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
245ff2b555
commit
2e45d135c5
17 changed files with 282 additions and 205 deletions
|
|
@ -3,9 +3,11 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "ModrinthAPI.h"
|
||||
#include <array>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Json.h"
|
||||
#include "modplatform/ResourceType.h"
|
||||
#include "net/ApiDownload.h"
|
||||
#include "net/ApiUpload.h"
|
||||
#include "net/NetJob.h"
|
||||
|
|
@ -122,6 +124,37 @@ QList<ResourceAPI::SortingMethod> ModrinthAPI::getSortingMethods() const
|
|||
{ .index = 4, .name = "newest", .readable_name = QObject::tr("Sort by Newest") },
|
||||
{ .index = 5, .name = "updated", .readable_name = QObject::tr("Sort by Last Updated") } };
|
||||
}
|
||||
namespace {
|
||||
const auto resourceTypeMap = std::array{
|
||||
std::pair{ ModPlatform::ResourceType::Mod, "mod" }, std::pair{ ModPlatform::ResourceType::ResourcePack, "resourcepack" },
|
||||
std::pair{ ModPlatform::ResourceType::ShaderPack, "shader" }, std::pair{ ModPlatform::ResourceType::DataPack, "datapack" },
|
||||
std::pair{ ModPlatform::ResourceType::Modpack, "modpack" },
|
||||
};
|
||||
}
|
||||
|
||||
ModPlatform::ResourceType ModrinthAPI::getResourceType(const QString& param)
|
||||
{
|
||||
for (const auto& [key, value] : resourceTypeMap) {
|
||||
if (value == param) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Invalid resource type for Modrinth API!" << param;
|
||||
return ModPlatform::ResourceType::Unknown;
|
||||
}
|
||||
|
||||
QString ModrinthAPI::resourceTypeParameter(ModPlatform::ResourceType type)
|
||||
{
|
||||
for (const auto& [key, value] : resourceTypeMap) {
|
||||
if (key == type) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Invalid resource type for Modrinth API!" << static_cast<std::uint8_t>(type);
|
||||
return "";
|
||||
}
|
||||
|
||||
std::pair<Task::Ptr, QByteArray*> ModrinthAPI::getModCategories()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue