made release type visible

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-10-21 18:48:55 +03:00
parent 9e85297f7a
commit 9aac8e389f
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
9 changed files with 38 additions and 10 deletions

View File

@ -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<int, bool> 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())

View File

@ -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; }

View File

@ -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();
}

View File

@ -71,6 +71,7 @@ class ModFolderModel : public ResourceFolderModel {
SideColumn,
LoadersColumn,
McVersionsColumn,
ReleaseTypeColumn,
NUM_COLUMNS
};
enum ModStatusAction { Disable, Enable, Toggle };

View File

@ -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 };

View File

@ -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()) {

View File

@ -43,6 +43,7 @@ class V1 {
Side side{ Side::UniversalSide };
ModPlatform::ModLoaderTypes loaders;
QStringList mcVersions;
ModPlatform::IndexedVersionType releaseType;
// [download]
QString mode{};

View File

@ -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();

View File

@ -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();