make universal resource type

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2025-03-24 23:06:53 +02:00
parent d63dba43d6
commit 9a51cd55df
23 changed files with 143 additions and 81 deletions

View File

@@ -1041,7 +1041,7 @@ void MainWindow::processURLs(QList<QUrl> urls)
auto type = ResourceUtils::identify(localFileInfo);
if (ResourceUtils::ValidResourceTypes.count(type) == 0) { // probably instance/modpack
if (ModPlatform::ResourceTypeUtils::ValidResources.count(type) == 0) { // probably instance/modpack
addInstance(localFileName, extra_info);
continue;
}
@@ -1065,25 +1065,25 @@ void MainWindow::processURLs(QList<QUrl> urls)
auto minecraftInst = std::dynamic_pointer_cast<MinecraftInstance>(inst);
switch (type) {
case PackedResourceType::ResourcePack:
case ModPlatform::ResourceType::ResourcePack:
minecraftInst->resourcePackList()->installResourceWithFlameMetadata(localFileName, version);
break;
case PackedResourceType::TexturePack:
case ModPlatform::ResourceType::TexturePack:
minecraftInst->texturePackList()->installResourceWithFlameMetadata(localFileName, version);
break;
case PackedResourceType::DataPack:
case ModPlatform::ResourceType::DataPack:
qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName;
break;
case PackedResourceType::Mod:
case ModPlatform::ResourceType::Mod:
minecraftInst->loaderModList()->installResourceWithFlameMetadata(localFileName, version);
break;
case PackedResourceType::ShaderPack:
case ModPlatform::ResourceType::ShaderPack:
minecraftInst->shaderPackList()->installResourceWithFlameMetadata(localFileName, version);
break;
case PackedResourceType::WorldSave:
case ModPlatform::ResourceType::World:
minecraftInst->worldList()->installWorld(localFileInfo);
break;
case PackedResourceType::UNKNOWN:
case ModPlatform::ResourceType::Unknown:
default:
qDebug() << "Can't Identify" << localFileName << "Ignoring it.";
break;

View File

@@ -8,10 +8,11 @@
#include "InstanceList.h"
#include <InstanceList.h>
#include "modplatform/ResourceType.h"
#include "ui/instanceview/InstanceDelegate.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)
{
ui->setupUi(this);
@@ -42,7 +43,7 @@ ImportResourceDialog::ImportResourceDialog(QString file_path, PackedResourceType
connect(contentsWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ImportResourceDialog::selectionChanged);
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->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));

View File

@@ -3,7 +3,7 @@
#include <QDialog>
#include <QItemSelection>
#include "minecraft/mod/tasks/LocalResourceParse.h"
#include "modplatform/ResourceType.h"
#include "ui/instanceview/InstanceProxyModel.h"
namespace Ui {
@@ -14,13 +14,13 @@ class ImportResourceDialog : public QDialog {
Q_OBJECT
public:
explicit ImportResourceDialog(QString file_path, PackedResourceType type, QWidget* parent = nullptr);
explicit ImportResourceDialog(QString file_path, ModPlatform::ResourceType type, QWidget* parent = nullptr);
~ImportResourceDialog() override;
QString selectedInstanceKey;
private:
Ui::ImportResourceDialog* ui;
PackedResourceType m_resource_type;
ModPlatform::ResourceType m_resource_type;
QString m_file_path;
InstanceProxyModel* proxyModel;

View File

@@ -18,7 +18,7 @@ DataPackResourceModel::DataPackResourceModel(BaseInstance const& base_inst, Reso
ResourceAPI::SearchArgs DataPackResourceModel::createSearchArguments()
{
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)

View File

@@ -41,7 +41,7 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments()
auto sort = getCurrentSortingMethodByIndex();
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
};
}

View File

@@ -17,7 +17,7 @@ ResourcePackResourceModel::ResourcePackResourceModel(BaseInstance const& base_in
ResourceAPI::SearchArgs ResourcePackResourceModel::createSearchArguments()
{
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)

View File

@@ -17,7 +17,7 @@ ShaderPackResourceModel::ShaderPackResourceModel(BaseInstance const& base_inst,
ResourceAPI::SearchArgs ShaderPackResourceModel::createSearchArguments()
{
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)

View File

@@ -188,7 +188,7 @@ void ListModel::performPaginatedSearch()
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
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 });
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), response));

View File

@@ -350,7 +350,7 @@ void FlamePage::createFilterWidget()
connect(m_filterWidget.get(), &ModFilterWidget::filterChanged, this, &FlamePage::triggerSearch);
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]() {
auto categories = FlameAPI::loadModCategories(response);
m_filterWidget->setCategories(categories);

View File

@@ -154,7 +154,7 @@ void ModpackListModel::performPaginatedSearch()
ResourceAPI::SortingMethod sort{};
sort.name = currentSort;
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 });
auto netJob = makeShared<NetJob>("Modrinth::SearchModpack", APPLICATION->network());