mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 19:37:45 -04:00
make universal resource type (#3541)
This commit is contained in:
commit
078de50951
@ -494,6 +494,8 @@ set(META_SOURCES
|
|||||||
set(API_SOURCES
|
set(API_SOURCES
|
||||||
modplatform/ModIndex.h
|
modplatform/ModIndex.h
|
||||||
modplatform/ModIndex.cpp
|
modplatform/ModIndex.cpp
|
||||||
|
modplatform/ResourceType.h
|
||||||
|
modplatform/ResourceType.cpp
|
||||||
|
|
||||||
modplatform/ResourceAPI.h
|
modplatform/ResourceAPI.h
|
||||||
|
|
||||||
|
@ -28,50 +28,38 @@
|
|||||||
#include "LocalShaderPackParseTask.h"
|
#include "LocalShaderPackParseTask.h"
|
||||||
#include "LocalTexturePackParseTask.h"
|
#include "LocalTexturePackParseTask.h"
|
||||||
#include "LocalWorldSaveParseTask.h"
|
#include "LocalWorldSaveParseTask.h"
|
||||||
|
#include "modplatform/ResourceType.h"
|
||||||
static const QMap<PackedResourceType, QString> s_packed_type_names = { { PackedResourceType::ResourcePack, QObject::tr("resource pack") },
|
|
||||||
{ PackedResourceType::TexturePack, QObject::tr("texture pack") },
|
|
||||||
{ PackedResourceType::DataPack, QObject::tr("data pack") },
|
|
||||||
{ PackedResourceType::ShaderPack, QObject::tr("shader pack") },
|
|
||||||
{ PackedResourceType::WorldSave, QObject::tr("world save") },
|
|
||||||
{ PackedResourceType::Mod, QObject::tr("mod") },
|
|
||||||
{ PackedResourceType::UNKNOWN, QObject::tr("unknown") } };
|
|
||||||
|
|
||||||
namespace ResourceUtils {
|
namespace ResourceUtils {
|
||||||
PackedResourceType identify(QFileInfo file)
|
ModPlatform::ResourceType identify(QFileInfo file)
|
||||||
{
|
{
|
||||||
if (file.exists() && file.isFile()) {
|
if (file.exists() && file.isFile()) {
|
||||||
if (ModUtils::validate(file)) {
|
if (ModUtils::validate(file)) {
|
||||||
// mods can contain resource and data packs so they must be tested first
|
// mods can contain resource and data packs so they must be tested first
|
||||||
qDebug() << file.fileName() << "is a mod";
|
qDebug() << file.fileName() << "is a mod";
|
||||||
return PackedResourceType::Mod;
|
return ModPlatform::ResourceType::Mod;
|
||||||
} else if (DataPackUtils::validateResourcePack(file)) {
|
} else if (DataPackUtils::validateResourcePack(file)) {
|
||||||
qDebug() << file.fileName() << "is a resource pack";
|
qDebug() << file.fileName() << "is a resource pack";
|
||||||
return PackedResourceType::ResourcePack;
|
return ModPlatform::ResourceType::ResourcePack;
|
||||||
} else if (TexturePackUtils::validate(file)) {
|
} else if (TexturePackUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a pre 1.6 texture pack";
|
qDebug() << file.fileName() << "is a pre 1.6 texture pack";
|
||||||
return PackedResourceType::TexturePack;
|
return ModPlatform::ResourceType::TexturePack;
|
||||||
} else if (DataPackUtils::validate(file)) {
|
} else if (DataPackUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a data pack";
|
qDebug() << file.fileName() << "is a data pack";
|
||||||
return PackedResourceType::DataPack;
|
return ModPlatform::ResourceType::DataPack;
|
||||||
} else if (WorldSaveUtils::validate(file)) {
|
} else if (WorldSaveUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a world save";
|
qDebug() << file.fileName() << "is a world save";
|
||||||
return PackedResourceType::WorldSave;
|
return ModPlatform::ResourceType::World;
|
||||||
} else if (ShaderPackUtils::validate(file)) {
|
} else if (ShaderPackUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a shader pack";
|
qDebug() << file.fileName() << "is a shader pack";
|
||||||
return PackedResourceType::ShaderPack;
|
return ModPlatform::ResourceType::ShaderPack;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Can't Identify" << file.fileName();
|
qDebug() << "Can't Identify" << file.fileName();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Can't find" << file.absolutePath();
|
qDebug() << "Can't find" << file.absolutePath();
|
||||||
}
|
}
|
||||||
return PackedResourceType::UNKNOWN;
|
return ModPlatform::ResourceType::Unknown;
|
||||||
}
|
|
||||||
|
|
||||||
QString getPackedTypeName(PackedResourceType type)
|
|
||||||
{
|
|
||||||
return s_packed_type_names.constFind(type).value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ResourceUtils
|
} // namespace ResourceUtils
|
||||||
|
@ -21,17 +21,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QObject>
|
#include "modplatform/ResourceType.h"
|
||||||
|
|
||||||
enum class PackedResourceType { DataPack, ResourcePack, TexturePack, ShaderPack, WorldSave, Mod, UNKNOWN };
|
|
||||||
namespace ResourceUtils {
|
namespace ResourceUtils {
|
||||||
static const std::set<PackedResourceType> ValidResourceTypes = { PackedResourceType::DataPack, PackedResourceType::ResourcePack,
|
ModPlatform::ResourceType identify(QFileInfo file);
|
||||||
PackedResourceType::TexturePack, PackedResourceType::ShaderPack,
|
|
||||||
PackedResourceType::WorldSave, PackedResourceType::Mod };
|
|
||||||
PackedResourceType identify(QFileInfo file);
|
|
||||||
QString getPackedTypeName(PackedResourceType type);
|
|
||||||
} // namespace ResourceUtils
|
} // namespace ResourceUtils
|
||||||
|
@ -45,8 +45,6 @@ QList<ModLoaderType> modLoaderTypesToList(ModLoaderTypes flags);
|
|||||||
|
|
||||||
enum class ResourceProvider { MODRINTH, FLAME };
|
enum class ResourceProvider { MODRINTH, FLAME };
|
||||||
|
|
||||||
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 };
|
enum class Side { NoSide = 0, ClientSide = 1 << 0, ServerSide = 1 << 1, UniversalSide = ClientSide | ServerSide };
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "../Version.h"
|
#include "../Version.h"
|
||||||
|
|
||||||
#include "modplatform/ModIndex.h"
|
#include "modplatform/ModIndex.h"
|
||||||
|
#include "modplatform/ResourceType.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
/* Simple class with a common interface for interacting with APIs */
|
/* Simple class with a common interface for interacting with APIs */
|
||||||
|
41
launcher/modplatform/ResourceType.cpp
Normal file
41
launcher/modplatform/ResourceType.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.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
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ResourceType.h"
|
||||||
|
|
||||||
|
namespace ModPlatform {
|
||||||
|
static const QMap<ResourceType, QString> s_packedTypeNames = { { ResourceType::ResourcePack, QObject::tr("resource pack") },
|
||||||
|
{ ResourceType::TexturePack, QObject::tr("texture pack") },
|
||||||
|
{ ResourceType::DataPack, QObject::tr("data pack") },
|
||||||
|
{ ResourceType::ShaderPack, QObject::tr("shader pack") },
|
||||||
|
{ ResourceType::World, QObject::tr("world save") },
|
||||||
|
{ ResourceType::Mod, QObject::tr("mod") },
|
||||||
|
{ ResourceType::Unknown, QObject::tr("unknown") } };
|
||||||
|
|
||||||
|
namespace ResourceTypeUtils {
|
||||||
|
|
||||||
|
QString getName(ResourceType type)
|
||||||
|
{
|
||||||
|
return s_packedTypeNames.constFind(type).value();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ResourceTypeUtils
|
||||||
|
} // namespace ModPlatform
|
39
launcher/modplatform/ResourceType.h
Normal file
39
launcher/modplatform/ResourceType.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prism Launcher - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.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
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace ModPlatform {
|
||||||
|
|
||||||
|
enum class ResourceType { Mod, ResourcePack, ShaderPack, Modpack, DataPack, World, Screenshots, TexturePack, Unknown };
|
||||||
|
|
||||||
|
namespace ResourceTypeUtils {
|
||||||
|
static const std::set<ResourceType> VALID_RESOURCES = { ResourceType::DataPack, ResourceType::ResourcePack, ResourceType::TexturePack,
|
||||||
|
ResourceType::ShaderPack, ResourceType::World, ResourceType::Mod };
|
||||||
|
QString getName(ResourceType type);
|
||||||
|
} // namespace ResourceTypeUtils
|
||||||
|
} // namespace ModPlatform
|
@ -84,18 +84,18 @@ void Flame::FileResolvingTask::executeTask()
|
|||||||
m_task->start();
|
m_task->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
PackedResourceType getResourceType(int classId)
|
ModPlatform::ResourceType getResourceType(int classId)
|
||||||
{
|
{
|
||||||
switch (classId) {
|
switch (classId) {
|
||||||
case 17: // Worlds
|
case 17: // Worlds
|
||||||
return PackedResourceType::WorldSave;
|
return ModPlatform::ResourceType::World;
|
||||||
case 6: // Mods
|
case 6: // Mods
|
||||||
return PackedResourceType::Mod;
|
return ModPlatform::ResourceType::Mod;
|
||||||
case 12: // Resource Packs
|
case 12: // Resource Packs
|
||||||
// return PackedResourceType::ResourcePack; // not really a resourcepack
|
// return ModPlatform::ResourceType::ResourcePack; // not really a resourcepack
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case 4546: // Customization
|
case 4546: // Customization
|
||||||
// return PackedResourceType::ShaderPack; // not really a shaderPack
|
// return ModPlatform::ResourceType::ShaderPack; // not really a shaderPack
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case 4471: // Modpacks
|
case 4471: // Modpacks
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
@ -104,7 +104,7 @@ PackedResourceType getResourceType(int classId)
|
|||||||
case 4559: // Addons
|
case 4559: // Addons
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
return PackedResourceType::UNKNOWN;
|
return ModPlatform::ResourceType::Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ void Flame::FileResolvingTask::getFlameProjects()
|
|||||||
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(file->version.fileName));
|
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(file->version.fileName));
|
||||||
FlameMod::loadIndexedPack(file->pack, entry_obj);
|
FlameMod::loadIndexedPack(file->pack, entry_obj);
|
||||||
file->resourceType = getResourceType(Json::requireInteger(entry_obj, "classId", "modClassId"));
|
file->resourceType = getResourceType(Json::requireInteger(entry_obj, "classId", "modClassId"));
|
||||||
if (file->resourceType == PackedResourceType::WorldSave) {
|
if (file->resourceType == ModPlatform::ResourceType::World) {
|
||||||
file->targetFolder = "saves";
|
file->targetFolder = "saves";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ Task::Ptr FlameAPI::getCategories(std::shared_ptr<QByteArray> response, ModPlatf
|
|||||||
|
|
||||||
Task::Ptr FlameAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
Task::Ptr FlameAPI::getModCategories(std::shared_ptr<QByteArray> response)
|
||||||
{
|
{
|
||||||
return getCategories(response, ModPlatform::ResourceType::MOD);
|
return getCategories(response, ModPlatform::ResourceType::Mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ModPlatform::Category> FlameAPI::loadModCategories(std::shared_ptr<QByteArray> response)
|
QList<ModPlatform::Category> FlameAPI::loadModCategories(std::shared_ptr<QByteArray> response)
|
||||||
|
@ -41,15 +41,15 @@ class FlameAPI : public NetworkResourceAPI {
|
|||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default:
|
default:
|
||||||
case ModPlatform::ResourceType::MOD:
|
case ModPlatform::ResourceType::Mod:
|
||||||
return 6;
|
return 6;
|
||||||
case ModPlatform::ResourceType::RESOURCE_PACK:
|
case ModPlatform::ResourceType::ResourcePack:
|
||||||
return 12;
|
return 12;
|
||||||
case ModPlatform::ResourceType::SHADER_PACK:
|
case ModPlatform::ResourceType::ShaderPack:
|
||||||
return 6552;
|
return 6552;
|
||||||
case ModPlatform::ResourceType::MODPACK:
|
case ModPlatform::ResourceType::Modpack:
|
||||||
return 4471;
|
return 4471;
|
||||||
case ModPlatform::ResourceType::DATA_PACK:
|
case ModPlatform::ResourceType::DataPack:
|
||||||
return 6945;
|
return 6945;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ void FlameCreationTask::idResolverSucceeded(QEventLoop& loop)
|
|||||||
QList<BlockedMod> blocked_mods;
|
QList<BlockedMod> blocked_mods;
|
||||||
auto anyBlocked = false;
|
auto anyBlocked = false;
|
||||||
for (const auto& result : results.values()) {
|
for (const auto& result : results.values()) {
|
||||||
if (result.resourceType != PackedResourceType::Mod) {
|
if (result.resourceType != ModPlatform::ResourceType::Mod) {
|
||||||
m_otherResources.append(std::make_pair(result.version.fileName, result.targetFolder));
|
m_otherResources.append(std::make_pair(result.version.fileName, result.targetFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,29 +687,29 @@ void FlameCreationTask::validateOtherResources(QEventLoop& loop)
|
|||||||
QString worldPath;
|
QString worldPath;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PackedResourceType::Mod:
|
case ModPlatform::ResourceType::Mod:
|
||||||
validatePath(fileName, targetFolder, "mods");
|
validatePath(fileName, targetFolder, "mods");
|
||||||
zipMods.push_back(fileName);
|
zipMods.push_back(fileName);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::ResourcePack:
|
case ModPlatform::ResourceType::ResourcePack:
|
||||||
validatePath(fileName, targetFolder, "resourcepacks");
|
validatePath(fileName, targetFolder, "resourcepacks");
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::TexturePack:
|
case ModPlatform::ResourceType::TexturePack:
|
||||||
validatePath(fileName, targetFolder, "texturepacks");
|
validatePath(fileName, targetFolder, "texturepacks");
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::DataPack:
|
case ModPlatform::ResourceType::DataPack:
|
||||||
validatePath(fileName, targetFolder, "datapacks");
|
validatePath(fileName, targetFolder, "datapacks");
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::ShaderPack:
|
case ModPlatform::ResourceType::ShaderPack:
|
||||||
// in theory flame API can't do this but who knows, that *may* change ?
|
// in theory flame API can't do this but who knows, that *may* change ?
|
||||||
// better to handle it if it *does* occur in the future
|
// better to handle it if it *does* occur in the future
|
||||||
validatePath(fileName, targetFolder, "shaderpacks");
|
validatePath(fileName, targetFolder, "shaderpacks");
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::WorldSave:
|
case ModPlatform::ResourceType::World:
|
||||||
worldPath = validatePath(fileName, targetFolder, "saves");
|
worldPath = validatePath(fileName, targetFolder, "saves");
|
||||||
installWorld(worldPath);
|
installWorld(worldPath);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::UNKNOWN:
|
case ModPlatform::ResourceType::Unknown:
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
qDebug() << "Can't Identify" << fileName << "at" << localPath << ", leaving it where it is.";
|
qDebug() << "Can't Identify" << fileName << "at" << localPath << ", leaving it where it is.";
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "minecraft/mod/tasks/LocalResourceParse.h"
|
|
||||||
#include "modplatform/ModIndex.h"
|
#include "modplatform/ModIndex.h"
|
||||||
|
#include "modplatform/ResourceType.h"
|
||||||
|
|
||||||
namespace Flame {
|
namespace Flame {
|
||||||
struct File {
|
struct File {
|
||||||
@ -55,7 +55,7 @@ struct File {
|
|||||||
|
|
||||||
// our
|
// our
|
||||||
QString targetFolder = QStringLiteral("mods");
|
QString targetFolder = QStringLiteral("mods");
|
||||||
PackedResourceType resourceType;
|
ModPlatform::ResourceType resourceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Modloader {
|
struct Modloader {
|
||||||
|
@ -104,15 +104,15 @@ class ModrinthAPI : public NetworkResourceAPI {
|
|||||||
static QString resourceTypeParameter(ModPlatform::ResourceType type)
|
static QString resourceTypeParameter(ModPlatform::ResourceType type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ModPlatform::ResourceType::MOD:
|
case ModPlatform::ResourceType::Mod:
|
||||||
return "mod";
|
return "mod";
|
||||||
case ModPlatform::ResourceType::RESOURCE_PACK:
|
case ModPlatform::ResourceType::ResourcePack:
|
||||||
return "resourcepack";
|
return "resourcepack";
|
||||||
case ModPlatform::ResourceType::SHADER_PACK:
|
case ModPlatform::ResourceType::ShaderPack:
|
||||||
return "shader";
|
return "shader";
|
||||||
case ModPlatform::ResourceType::DATA_PACK:
|
case ModPlatform::ResourceType::DataPack:
|
||||||
return "datapack";
|
return "datapack";
|
||||||
case ModPlatform::ResourceType::MODPACK:
|
case ModPlatform::ResourceType::Modpack:
|
||||||
return "modpack";
|
return "modpack";
|
||||||
default:
|
default:
|
||||||
qWarning() << "Invalid resource type for Modrinth API!";
|
qWarning() << "Invalid resource type for Modrinth API!";
|
||||||
|
@ -1041,7 +1041,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
|||||||
|
|
||||||
auto type = ResourceUtils::identify(localFileInfo);
|
auto type = ResourceUtils::identify(localFileInfo);
|
||||||
|
|
||||||
if (ResourceUtils::ValidResourceTypes.count(type) == 0) { // probably instance/modpack
|
if (ModPlatform::ResourceTypeUtils::VALID_RESOURCES.count(type) == 0) { // probably instance/modpack
|
||||||
addInstance(localFileName, extra_info);
|
addInstance(localFileName, extra_info);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1065,25 +1065,25 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
|||||||
auto minecraftInst = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
auto minecraftInst = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PackedResourceType::ResourcePack:
|
case ModPlatform::ResourceType::ResourcePack:
|
||||||
minecraftInst->resourcePackList()->installResourceWithFlameMetadata(localFileName, version);
|
minecraftInst->resourcePackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::TexturePack:
|
case ModPlatform::ResourceType::TexturePack:
|
||||||
minecraftInst->texturePackList()->installResourceWithFlameMetadata(localFileName, version);
|
minecraftInst->texturePackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::DataPack:
|
case ModPlatform::ResourceType::DataPack:
|
||||||
qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName;
|
qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName;
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::Mod:
|
case ModPlatform::ResourceType::Mod:
|
||||||
minecraftInst->loaderModList()->installResourceWithFlameMetadata(localFileName, version);
|
minecraftInst->loaderModList()->installResourceWithFlameMetadata(localFileName, version);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::ShaderPack:
|
case ModPlatform::ResourceType::ShaderPack:
|
||||||
minecraftInst->shaderPackList()->installResourceWithFlameMetadata(localFileName, version);
|
minecraftInst->shaderPackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::WorldSave:
|
case ModPlatform::ResourceType::World:
|
||||||
minecraftInst->worldList()->installWorld(localFileInfo);
|
minecraftInst->worldList()->installWorld(localFileInfo);
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::UNKNOWN:
|
case ModPlatform::ResourceType::Unknown:
|
||||||
default:
|
default:
|
||||||
qDebug() << "Can't Identify" << localFileName << "Ignoring it.";
|
qDebug() << "Can't Identify" << localFileName << "Ignoring it.";
|
||||||
break;
|
break;
|
||||||
|
@ -8,10 +8,11 @@
|
|||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
|
|
||||||
#include <InstanceList.h>
|
#include <InstanceList.h>
|
||||||
|
#include "modplatform/ResourceType.h"
|
||||||
#include "ui/instanceview/InstanceDelegate.h"
|
#include "ui/instanceview/InstanceDelegate.h"
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
|
|
||||||
ImportResourceDialog::ImportResourceDialog(QString file_path, PackedResourceType type, QWidget* parent)
|
ImportResourceDialog::ImportResourceDialog(QString file_path, ModPlatform::ResourceType type, QWidget* parent)
|
||||||
: QDialog(parent), ui(new Ui::ImportResourceDialog), m_resource_type(type), m_file_path(file_path)
|
: QDialog(parent), ui(new Ui::ImportResourceDialog), m_resource_type(type), m_file_path(file_path)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -42,7 +43,7 @@ ImportResourceDialog::ImportResourceDialog(QString file_path, PackedResourceType
|
|||||||
connect(contentsWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ImportResourceDialog::selectionChanged);
|
connect(contentsWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ImportResourceDialog::selectionChanged);
|
||||||
|
|
||||||
ui->label->setText(
|
ui->label->setText(
|
||||||
tr("Choose the instance you would like to import this %1 to.").arg(ResourceUtils::getPackedTypeName(m_resource_type)));
|
tr("Choose the instance you would like to import this %1 to.").arg(ModPlatform::ResourceTypeUtils::getName(m_resource_type)));
|
||||||
ui->label_file_path->setText(tr("File: %1").arg(m_file_path));
|
ui->label_file_path->setText(tr("File: %1").arg(m_file_path));
|
||||||
|
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
|
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
|
||||||
#include "minecraft/mod/tasks/LocalResourceParse.h"
|
#include "modplatform/ResourceType.h"
|
||||||
#include "ui/instanceview/InstanceProxyModel.h"
|
#include "ui/instanceview/InstanceProxyModel.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -14,13 +14,13 @@ class ImportResourceDialog : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ImportResourceDialog(QString file_path, PackedResourceType type, QWidget* parent = nullptr);
|
explicit ImportResourceDialog(QString file_path, ModPlatform::ResourceType type, QWidget* parent = nullptr);
|
||||||
~ImportResourceDialog() override;
|
~ImportResourceDialog() override;
|
||||||
QString selectedInstanceKey;
|
QString selectedInstanceKey;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ImportResourceDialog* ui;
|
Ui::ImportResourceDialog* ui;
|
||||||
PackedResourceType m_resource_type;
|
ModPlatform::ResourceType m_resource_type;
|
||||||
QString m_file_path;
|
QString m_file_path;
|
||||||
InstanceProxyModel* proxyModel;
|
InstanceProxyModel* proxyModel;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ DataPackResourceModel::DataPackResourceModel(BaseInstance const& base_inst, Reso
|
|||||||
ResourceAPI::SearchArgs DataPackResourceModel::createSearchArguments()
|
ResourceAPI::SearchArgs DataPackResourceModel::createSearchArguments()
|
||||||
{
|
{
|
||||||
auto sort = getCurrentSortingMethodByIndex();
|
auto sort = getCurrentSortingMethodByIndex();
|
||||||
return { ModPlatform::ResourceType::DATA_PACK, m_next_search_offset, m_search_term, sort, ModPlatform::ModLoaderType::DataPack };
|
return { ModPlatform::ResourceType::DataPack, m_next_search_offset, m_search_term, sort, ModPlatform::ModLoaderType::DataPack };
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceAPI::VersionSearchArgs DataPackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
ResourceAPI::VersionSearchArgs DataPackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||||
|
@ -41,7 +41,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments()
|
|||||||
auto sort = getCurrentSortingMethodByIndex();
|
auto sort = getCurrentSortingMethodByIndex();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term, sort, loaders, versions, side, categories, m_filter->openSource
|
ModPlatform::ResourceType::Mod, m_next_search_offset, m_search_term, sort, loaders, versions, side, categories, m_filter->openSource
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ ResourcePackResourceModel::ResourcePackResourceModel(BaseInstance const& base_in
|
|||||||
ResourceAPI::SearchArgs ResourcePackResourceModel::createSearchArguments()
|
ResourceAPI::SearchArgs ResourcePackResourceModel::createSearchArguments()
|
||||||
{
|
{
|
||||||
auto sort = getCurrentSortingMethodByIndex();
|
auto sort = getCurrentSortingMethodByIndex();
|
||||||
return { ModPlatform::ResourceType::RESOURCE_PACK, m_next_search_offset, m_search_term, sort };
|
return { ModPlatform::ResourceType::ResourcePack, m_next_search_offset, m_search_term, sort };
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceAPI::VersionSearchArgs ResourcePackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
ResourceAPI::VersionSearchArgs ResourcePackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||||
|
@ -17,7 +17,7 @@ ShaderPackResourceModel::ShaderPackResourceModel(BaseInstance const& base_inst,
|
|||||||
ResourceAPI::SearchArgs ShaderPackResourceModel::createSearchArguments()
|
ResourceAPI::SearchArgs ShaderPackResourceModel::createSearchArguments()
|
||||||
{
|
{
|
||||||
auto sort = getCurrentSortingMethodByIndex();
|
auto sort = getCurrentSortingMethodByIndex();
|
||||||
return { ModPlatform::ResourceType::SHADER_PACK, m_next_search_offset, m_search_term, sort };
|
return { ModPlatform::ResourceType::ShaderPack, m_next_search_offset, m_search_term, sort };
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceAPI::VersionSearchArgs ShaderPackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
ResourceAPI::VersionSearchArgs ShaderPackResourceModel::createVersionsArguments(const QModelIndex& entry)
|
||||||
|
@ -188,7 +188,7 @@ void ListModel::performPaginatedSearch()
|
|||||||
|
|
||||||
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
|
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
|
||||||
auto searchUrl =
|
auto searchUrl =
|
||||||
FlameAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
FlameAPI().getSearchURL({ ModPlatform::ResourceType::Modpack, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
||||||
m_filter->versions, ModPlatform::Side::NoSide, m_filter->categoryIds, m_filter->openSource });
|
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));
|
||||||
|
@ -350,7 +350,7 @@ void FlamePage::createFilterWidget()
|
|||||||
|
|
||||||
connect(m_filterWidget.get(), &ModFilterWidget::filterChanged, this, &FlamePage::triggerSearch);
|
connect(m_filterWidget.get(), &ModFilterWidget::filterChanged, this, &FlamePage::triggerSearch);
|
||||||
auto response = std::make_shared<QByteArray>();
|
auto response = std::make_shared<QByteArray>();
|
||||||
m_categoriesTask = FlameAPI::getCategories(response, ModPlatform::ResourceType::MODPACK);
|
m_categoriesTask = FlameAPI::getCategories(response, ModPlatform::ResourceType::Modpack);
|
||||||
connect(m_categoriesTask.get(), &Task::succeeded, [this, response]() {
|
connect(m_categoriesTask.get(), &Task::succeeded, [this, response]() {
|
||||||
auto categories = FlameAPI::loadModCategories(response);
|
auto categories = FlameAPI::loadModCategories(response);
|
||||||
m_filterWidget->setCategories(categories);
|
m_filterWidget->setCategories(categories);
|
||||||
|
@ -154,7 +154,7 @@ void ModpackListModel::performPaginatedSearch()
|
|||||||
ResourceAPI::SortingMethod sort{};
|
ResourceAPI::SortingMethod sort{};
|
||||||
sort.name = currentSort;
|
sort.name = currentSort;
|
||||||
auto searchUrl =
|
auto searchUrl =
|
||||||
ModrinthAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
ModrinthAPI().getSearchURL({ ModPlatform::ResourceType::Modpack, nextSearchOffset, currentSearchTerm, sort, m_filter->loaders,
|
||||||
m_filter->versions, ModPlatform::Side::NoSide, m_filter->categoryIds, m_filter->openSource });
|
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());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user