diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp index 22e652319..f301cc949 100644 --- a/launcher/minecraft/mod/Mod.cpp +++ b/launcher/minecraft/mod/Mod.cpp @@ -47,6 +47,7 @@ #include "minecraft/mod/ModDetails.h" #include "minecraft/mod/Resource.h" #include "minecraft/mod/tasks/LocalModParseTask.h" +#include "modplatform/ModIndex.h" static ModPlatform::ProviderCapabilities ProviderCaps; @@ -132,6 +133,13 @@ std::pair Mod::compare(const Resource& other, SortType type) const return { compare_result, type == SortType::MC_VERSIONS }; break; } + case SortType::RELEASE_TYPE: { + if (releaseType() > cast_other->releaseType()) + return { 1, type == SortType::RELEASE_TYPE }; + else if (releaseType() < cast_other->releaseType()) + return { -1, type == SortType::RELEASE_TYPE }; + break; + } } return { 0, false }; } @@ -262,6 +270,13 @@ auto Mod::side() const -> Metadata::ModSide return Metadata::ModSide::UniversalSide; } +auto Mod::releaseType() const -> ModPlatform::IndexedVersionType +{ + if (metadata()) + return metadata()->releaseType; + return ModPlatform::IndexedVersionType::VersionType::Unknown; +} + auto Mod::loaders() const -> ModPlatform::ModLoaderTypes { if (metadata()) diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h index 92de65889..bf503bc80 100644 --- a/launcher/minecraft/mod/Mod.h +++ b/launcher/minecraft/mod/Mod.h @@ -74,6 +74,7 @@ class Mod : public Resource { auto side() const -> Metadata::ModSide; auto loaders() const -> ModPlatform::ModLoaderTypes; auto mcVersions() const -> QStringList; + auto releaseType() const -> ModPlatform::IndexedVersionType; /** Get the intneral path to the mod's icon file*/ QString iconPath() const { return m_local_details.icon_file; } diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index ef4ab957c..fb3688d5d 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -64,16 +64,17 @@ ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool is_indexed, bool create_dir) : ResourceFolderModel(QDir(dir), instance, nullptr, create_dir), m_is_indexed(is_indexed) { - m_column_names = - QStringList({ "Enable", "Image", "Name", "Version", "Last Modified", "Provider", "Side", "Loaders", "Miecraft Versions" }); + m_column_names = QStringList( + { "Enable", "Image", "Name", "Version", "Last Modified", "Provider", "Side", "Loaders", "Miecraft Versions", "Release Type" }); m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider"), - tr("Side"), tr("Loaders"), tr("Miecraft Versions") }); - m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION, SortType::DATE, - SortType::PROVIDER, SortType::SIDE, SortType::LOADERS, SortType::MC_VERSIONS }; + tr("Side"), tr("Loaders"), tr("Miecraft Versions"), tr("Release Type") }); + m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION, SortType::DATE, + SortType::PROVIDER, SortType::SIDE, SortType::LOADERS, SortType::MC_VERSIONS, SortType::RELEASE_TYPE }; m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, - QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents }; - m_columnsHideable = { false, true, false, true, true, true, true, true, true }; + QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, + QHeaderView::ResizeToContents }; + m_columnsHideable = { false, true, false, true, true, true, true, true, true, true }; } QVariant ModFolderModel::data(const QModelIndex& index, int role) const @@ -128,6 +129,9 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const case McVersionsColumn: { return at(row)->mcVersions().join(", "); } + case ReleaseTypeColumn: { + return at(row)->releaseType().toString(); + } default: return QVariant(); } @@ -180,6 +184,7 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio case SideColumn: case LoadersColumn: case McVersionsColumn: + case ReleaseTypeColumn: return columnNames().at(section); default: return QVariant(); @@ -203,6 +208,8 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio return tr("The mod loader."); case McVersionsColumn: return tr("The supported minecraft versions."); + case ReleaseTypeColumn: + return tr("The release type."); default: return QVariant(); } diff --git a/launcher/minecraft/mod/ModFolderModel.h b/launcher/minecraft/mod/ModFolderModel.h index f9a87a741..a243a3c92 100644 --- a/launcher/minecraft/mod/ModFolderModel.h +++ b/launcher/minecraft/mod/ModFolderModel.h @@ -71,6 +71,7 @@ class ModFolderModel : public ResourceFolderModel { SideColumn, LoadersColumn, McVersionsColumn, + ReleaseTypeColumn, NUM_COLUMNS }; enum ModStatusAction { Disable, Enable, Toggle }; diff --git a/launcher/minecraft/mod/Resource.h b/launcher/minecraft/mod/Resource.h index c46980837..101f65271 100644 --- a/launcher/minecraft/mod/Resource.h +++ b/launcher/minecraft/mod/Resource.h @@ -15,7 +15,7 @@ enum class ResourceType { LITEMOD, //!< The resource is a litemod }; -enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER, SIDE, LOADERS, MC_VERSIONS }; +enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER, SIDE, LOADERS, MC_VERSIONS, RELEASE_TYPE }; enum class EnableAction { ENABLE, DISABLE, TOGGLE }; diff --git a/launcher/modplatform/packwiz/Packwiz.cpp b/launcher/modplatform/packwiz/Packwiz.cpp index 0692a627d..1672cdf3d 100644 --- a/launcher/modplatform/packwiz/Packwiz.cpp +++ b/launcher/modplatform/packwiz/Packwiz.cpp @@ -117,6 +117,7 @@ auto V1::createModFormat([[maybe_unused]] QDir& index_dir, ModPlatform::IndexedP mod.loaders = mod_version.loaders; mod.mcVersions = mod_version.mcVersion; mod.mcVersions.sort(); + mod.releaseType = mod_version.version_type; return mod; } @@ -209,6 +210,7 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod) { "side", sideToString(mod.side).toStdString() }, { "loaders", loaders }, { "mcVersions", mcVersions }, + { "releaseType", mod.releaseType.toString().toStdString() }, { "download", toml::table{ { "mode", mod.mode.toStdString() }, @@ -293,6 +295,7 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod mod.name = stringEntry(table, "name"); mod.filename = stringEntry(table, "filename"); mod.side = stringToSide(stringEntry(table, "side")); + mod.releaseType = ModPlatform::IndexedVersionType(stringEntry(table, "releaseType")); if (auto loaders = table["loaders"]; loaders && loaders.is_array()) { for (auto&& loader : *loaders.as_array()) { if (loader.is_string()) { diff --git a/launcher/modplatform/packwiz/Packwiz.h b/launcher/modplatform/packwiz/Packwiz.h index 5cf99e74a..50cce9c66 100644 --- a/launcher/modplatform/packwiz/Packwiz.h +++ b/launcher/modplatform/packwiz/Packwiz.h @@ -43,6 +43,7 @@ class V1 { Side side{ Side::UniversalSide }; ModPlatform::ModLoaderTypes loaders; QStringList mcVersions; + ModPlatform::IndexedVersionType releaseType; // [download] QString mode{}; diff --git a/launcher/ui/widgets/ModFilterWidget.cpp b/launcher/ui/widgets/ModFilterWidget.cpp index dde5d7502..d702173f1 100644 --- a/launcher/ui/widgets/ModFilterWidget.cpp +++ b/launcher/ui/widgets/ModFilterWidget.cpp @@ -148,7 +148,7 @@ void ModFilterWidget::onIncludeSnapshotsChanged() m_versions_proxy->setFilter(BaseVersionList::TypeRole, new RegexpFilter(filter, false)); } -void ModFilterWidget::onVersionFilterChanged() +void ModFilterWidget::onVersionFilterChanged(int) { auto versions = ui->versionsCb->checkedItems(); m_filter->versions.clear(); diff --git a/launcher/ui/widgets/ModFilterWidget.h b/launcher/ui/widgets/ModFilterWidget.h index 50e6b3762..b6edcb21e 100644 --- a/launcher/ui/widgets/ModFilterWidget.h +++ b/launcher/ui/widgets/ModFilterWidget.h @@ -52,7 +52,7 @@ class ModFilterWidget : public QTabWidget { void prepareBasicFilter(); private slots: - void onVersionFilterChanged(); + void onVersionFilterChanged(int); void onVersionFilterTextChanged(QString version); void onReleaseFilterChanged(); void onLoadersFilterChanged();