Added mcVersion column
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
9001d9eb75
commit
b54376062e
@ -124,6 +124,14 @@ std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const
|
||||
return { -1, type == SortType::LOADERS };
|
||||
break;
|
||||
}
|
||||
case SortType::MC_VERSIONS: {
|
||||
auto thisVersion = mcVersions().join(",");
|
||||
auto otherVersion = cast_other->mcVersions().join(",");
|
||||
auto compare_result = QString::compare(thisVersion, otherVersion, Qt::CaseInsensitive);
|
||||
if (compare_result != 0)
|
||||
return { compare_result, type == SortType::MC_VERSIONS };
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { 0, false };
|
||||
}
|
||||
@ -261,6 +269,13 @@ auto Mod::loaders() const -> ModPlatform::ModLoaderTypes
|
||||
return {};
|
||||
}
|
||||
|
||||
auto Mod::mcVersions() const -> QStringList
|
||||
{
|
||||
if (metadata())
|
||||
return metadata()->mcVersions;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto Mod::licenses() const -> const QList<ModLicense>&
|
||||
{
|
||||
return details().licenses;
|
||||
|
@ -73,6 +73,7 @@ class Mod : public Resource {
|
||||
auto metaurl() const -> QString;
|
||||
auto side() const -> Metadata::ModSide;
|
||||
auto loaders() const -> ModPlatform::ModLoaderTypes;
|
||||
auto mcVersions() const -> QStringList;
|
||||
|
||||
/** Get the intneral path to the mod's icon file*/
|
||||
QString iconPath() const { return m_local_details.icon_file; }
|
||||
|
@ -64,15 +64,16 @@
|
||||
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" });
|
||||
m_column_names_translated = QStringList(
|
||||
{ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider"), tr("Side"), tr("Loaders") });
|
||||
m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION,
|
||||
SortType::DATE, SortType::PROVIDER, SortType::SIDE, SortType::LOADERS };
|
||||
m_column_names =
|
||||
QStringList({ "Enable", "Image", "Name", "Version", "Last Modified", "Provider", "Side", "Loaders", "Miecraft Versions" });
|
||||
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 };
|
||||
m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch,
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents,
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true };
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true, true };
|
||||
}
|
||||
|
||||
QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
@ -122,7 +123,10 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
loaders << getModLoaderAsString(loader);
|
||||
}
|
||||
}
|
||||
return loaders.join(",");
|
||||
return loaders.join(", ");
|
||||
}
|
||||
case McVersionsColumn: {
|
||||
return at(row)->mcVersions().join(", ");
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
@ -175,6 +179,7 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||
case ImageColumn:
|
||||
case SideColumn:
|
||||
case LoadersColumn:
|
||||
case McVersionsColumn:
|
||||
return columnNames().at(section);
|
||||
default:
|
||||
return QVariant();
|
||||
@ -196,6 +201,8 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||
return tr("On what environment the mod is running.");
|
||||
case LoadersColumn:
|
||||
return tr("The mod loader.");
|
||||
case McVersionsColumn:
|
||||
return tr("The supported minecraft versions.");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class ModFolderModel : public ResourceFolderModel {
|
||||
ProviderColumn,
|
||||
SideColumn,
|
||||
LoadersColumn,
|
||||
McVersionsColumn,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
enum ModStatusAction { Disable, Enable, Toggle };
|
||||
|
@ -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 };
|
||||
enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER, SIDE, LOADERS, MC_VERSIONS };
|
||||
|
||||
enum class EnableAction { ENABLE, DISABLE, TOGGLE };
|
||||
|
||||
|
@ -138,7 +138,7 @@ auto getModLoaderAsString(ModLoaderType type) -> const QString
|
||||
return "";
|
||||
}
|
||||
|
||||
auto getModLoaderFromString(QString type) -> const ModLoaderType
|
||||
auto getModLoaderFromString(QString type) -> ModLoaderType
|
||||
{
|
||||
if (type == "neoforge")
|
||||
return NeoForge;
|
||||
|
@ -183,7 +183,7 @@ inline auto getOverrideDeps() -> QList<OverrideDep>
|
||||
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
||||
|
||||
auto getModLoaderAsString(ModLoaderType type) -> const QString;
|
||||
auto getModLoaderFromString(QString type) -> const ModLoaderType;
|
||||
auto getModLoaderFromString(QString type) -> ModLoaderType;
|
||||
|
||||
constexpr bool hasSingleModLoaderSelected(ModLoaderTypes l) noexcept
|
||||
{
|
||||
|
@ -117,20 +117,20 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
|
||||
|
||||
if (str.contains('.'))
|
||||
file.mcVersion.append(str);
|
||||
auto loader = str.toLower();
|
||||
if (loader == "neoforge")
|
||||
|
||||
if (auto loader = str.toLower(); loader == "neoforge")
|
||||
file.loaders |= ModPlatform::NeoForge;
|
||||
if (loader == "forge")
|
||||
else if (loader == "forge")
|
||||
file.loaders |= ModPlatform::Forge;
|
||||
if (loader == "cauldron")
|
||||
else if (loader == "cauldron")
|
||||
file.loaders |= ModPlatform::Cauldron;
|
||||
if (loader == "liteloader")
|
||||
else if (loader == "liteloader")
|
||||
file.loaders |= ModPlatform::LiteLoader;
|
||||
if (loader == "fabric")
|
||||
else if (loader == "fabric")
|
||||
file.loaders |= ModPlatform::Fabric;
|
||||
if (loader == "quilt")
|
||||
else if (loader == "quilt")
|
||||
file.loaders |= ModPlatform::Quilt;
|
||||
if (loader == "server" || loader == "client") {
|
||||
else if (loader == "server" || loader == "client") {
|
||||
if (file.side.isEmpty())
|
||||
file.side = loader;
|
||||
else if (file.side != loader)
|
||||
|
@ -152,15 +152,15 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
||||
for (auto loader : loaders) {
|
||||
if (loader == "neoforge")
|
||||
file.loaders |= ModPlatform::NeoForge;
|
||||
if (loader == "forge")
|
||||
else if (loader == "forge")
|
||||
file.loaders |= ModPlatform::Forge;
|
||||
if (loader == "cauldron")
|
||||
else if (loader == "cauldron")
|
||||
file.loaders |= ModPlatform::Cauldron;
|
||||
if (loader == "liteloader")
|
||||
else if (loader == "liteloader")
|
||||
file.loaders |= ModPlatform::LiteLoader;
|
||||
if (loader == "fabric")
|
||||
else if (loader == "fabric")
|
||||
file.loaders |= ModPlatform::Fabric;
|
||||
if (loader == "quilt")
|
||||
else if (loader == "quilt")
|
||||
file.loaders |= ModPlatform::Quilt;
|
||||
}
|
||||
file.version = Json::requireString(obj, "name");
|
||||
|
@ -115,6 +115,8 @@ auto V1::createModFormat([[maybe_unused]] QDir& index_dir, ModPlatform::IndexedP
|
||||
mod.project_id = mod_pack.addonId;
|
||||
mod.side = stringToSide(mod_version.side.isEmpty() ? mod_pack.side : mod_version.side);
|
||||
mod.loaders = mod_version.loaders;
|
||||
mod.mcVersions = mod_version.mcVersion;
|
||||
mod.mcVersions.sort();
|
||||
|
||||
return mod;
|
||||
}
|
||||
@ -189,6 +191,10 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
||||
loaders.push_back(getModLoaderAsString(loader).toStdString());
|
||||
}
|
||||
}
|
||||
toml::array mcVersions;
|
||||
for (auto version : mod.mcVersions) {
|
||||
mcVersions.push_back(version.toStdString());
|
||||
}
|
||||
|
||||
if (!index_file.open(QIODevice::ReadWrite)) {
|
||||
qCritical() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
@ -202,6 +208,7 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
|
||||
{ "filename", mod.filename.toStdString() },
|
||||
{ "side", sideToString(mod.side).toStdString() },
|
||||
{ "loaders", loaders },
|
||||
{ "mcVersions", mcVersions },
|
||||
{ "download",
|
||||
toml::table{
|
||||
{ "mode", mod.mode.toStdString() },
|
||||
@ -293,6 +300,17 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
|
||||
}
|
||||
}
|
||||
}
|
||||
if (auto versions = table["mcVersions"]; versions && versions.is_array()) {
|
||||
for (auto&& version : *versions.as_array()) {
|
||||
if (version.is_string()) {
|
||||
auto ver = QString::fromStdString(version.as_string()->value_or(""));
|
||||
if (!ver.isEmpty()) {
|
||||
mod.mcVersions << ver;
|
||||
}
|
||||
}
|
||||
}
|
||||
mod.mcVersions.sort();
|
||||
}
|
||||
}
|
||||
|
||||
{ // [download] info
|
||||
|
@ -42,6 +42,7 @@ class V1 {
|
||||
QString filename{};
|
||||
Side side{ Side::UniversalSide };
|
||||
ModPlatform::ModLoaderTypes loaders;
|
||||
QStringList mcVersions;
|
||||
|
||||
// [download]
|
||||
QString mode{};
|
||||
|
Loading…
Reference in New Issue
Block a user