aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/modplatform/CheckUpdateTask.h28
-rw-r--r--launcher/modplatform/ModIndex.cpp68
-rw-r--r--launcher/modplatform/ModIndex.h31
-rw-r--r--launcher/modplatform/flame/FlameAPI.cpp3
-rw-r--r--launcher/modplatform/flame/FlameCheckUpdate.cpp2
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp4
-rw-r--r--launcher/modplatform/flame/FlamePackIndex.cpp1
-rw-r--r--launcher/modplatform/flame/FlamePackIndex.h3
-rw-r--r--launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp4
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp5
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackManifest.cpp4
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackManifest.h3
-rw-r--r--launcher/ui/dialogs/ModUpdateDialog.cpp5
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp6
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.cpp3
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp3
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp6
17 files changed, 161 insertions, 18 deletions
diff --git a/launcher/modplatform/CheckUpdateTask.h b/launcher/modplatform/CheckUpdateTask.h
index f7582b8f..fbafedd7 100644
--- a/launcher/modplatform/CheckUpdateTask.h
+++ b/launcher/modplatform/CheckUpdateTask.h
@@ -1,8 +1,8 @@
#pragma once
#include "minecraft/mod/Mod.h"
-#include "modplatform/ResourceAPI.h"
#include "modplatform/ModIndex.h"
+#include "modplatform/ResourceAPI.h"
#include "tasks/Task.h"
class ResourceDownloadTask;
@@ -12,21 +12,39 @@ class CheckUpdateTask : public Task {
Q_OBJECT
public:
- CheckUpdateTask(QList<Mod*>& mods, std::list<Version>& mcVersions, std::optional<ResourceAPI::ModLoaderTypes> loaders, std::shared_ptr<ModFolderModel> mods_folder)
- : Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder) {};
+ CheckUpdateTask(QList<Mod*>& mods,
+ std::list<Version>& mcVersions,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders,
+ std::shared_ptr<ModFolderModel> mods_folder)
+ : Task(nullptr), m_mods(mods), m_game_versions(mcVersions), m_loaders(loaders), m_mods_folder(mods_folder){};
struct UpdatableMod {
QString name;
QString old_hash;
QString old_version;
QString new_version;
+ std::optional<ModPlatform::IndexedVersionType> new_verison_type;
QString changelog;
ModPlatform::ResourceProvider provider;
shared_qobject_ptr<ResourceDownloadTask> download;
public:
- UpdatableMod(QString name, QString old_h, QString old_v, QString new_v, QString changelog, ModPlatform::ResourceProvider p, shared_qobject_ptr<ResourceDownloadTask> t)
- : name(name), old_hash(old_h), old_version(old_v), new_version(new_v), changelog(changelog), provider(p), download(t)
+ UpdatableMod(QString name,
+ QString old_h,
+ QString old_v,
+ QString new_v,
+ std::optional<ModPlatform::IndexedVersionType> new_v_type,
+ QString changelog,
+ ModPlatform::ResourceProvider p,
+ shared_qobject_ptr<ResourceDownloadTask> t)
+ : name(name)
+ , old_hash(old_h)
+ , old_version(old_v)
+ , new_version(new_v)
+ , new_verison_type(new_v_type)
+ , changelog(changelog)
+ , provider(p)
+ , download(t)
{}
};
diff --git a/launcher/modplatform/ModIndex.cpp b/launcher/modplatform/ModIndex.cpp
index 6a507caf..3e1f473e 100644
--- a/launcher/modplatform/ModIndex.cpp
+++ b/launcher/modplatform/ModIndex.cpp
@@ -24,6 +24,74 @@
namespace ModPlatform {
+static const QMap<QString, IndexedVersionType::Enum> s_indexed_version_type_names = {
+ {"release", IndexedVersionType::Enum::Release},
+ {"beta", IndexedVersionType::Enum::Beta},
+ {"alpha", IndexedVersionType::Enum::Alpha}
+};
+
+IndexedVersionType::IndexedVersionType(const QString& type): IndexedVersionType(enumFromString(type))
+{}
+
+IndexedVersionType::IndexedVersionType(int type)
+{
+ switch (type) {
+ case 1:
+ m_type = IndexedVersionType::Enum::Release;
+ break;
+ case 2:
+ m_type = IndexedVersionType::Enum::Beta;
+ break;
+ case 3:
+ m_type = IndexedVersionType::Enum::Alpha;
+ break;
+ default:
+ m_type = IndexedVersionType::Enum::UNKNOWN;
+ }
+}
+
+IndexedVersionType::IndexedVersionType(const IndexedVersionType::Enum& type)
+{
+ m_type = type;
+}
+
+IndexedVersionType::IndexedVersionType(const IndexedVersionType& other)
+{
+ m_type = other.m_type;
+}
+
+IndexedVersionType& IndexedVersionType::operator=(const IndexedVersionType& other)
+{
+ m_type = other.m_type;
+ return *this;
+}
+
+const QString IndexedVersionType::toString (const IndexedVersionType::Enum& type)
+{
+ switch (type) {
+ case IndexedVersionType::Enum::Release:
+ return "release";
+ case IndexedVersionType::Enum::Beta:
+ return "beta";
+ case IndexedVersionType::Enum::Alpha:
+ return "alpha";
+ case IndexedVersionType::Enum::UNKNOWN:
+ default:
+ return "unknown";
+
+ }
+}
+
+IndexedVersionType::Enum IndexedVersionType::enumFromString(const QString& type)
+{
+ auto found = s_indexed_version_type_names.constFind(type);
+ if (found != s_indexed_version_type_names.constEnd()) {
+ return *found;
+ } else {
+ return IndexedVersionType::Enum::UNKNOWN;
+ }
+}
+
auto ProviderCapabilities::name(ResourceProvider p) -> const char*
{
switch (p) {
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
index 3b0a03a1..b47d0948 100644
--- a/launcher/modplatform/ModIndex.h
+++ b/launcher/modplatform/ModIndex.h
@@ -25,6 +25,7 @@
#include <QVariant>
#include <QVector>
#include <memory>
+#include <optional>
class QIODevice;
@@ -55,6 +56,35 @@ struct DonationData {
QString url;
};
+struct IndexedVersionType {
+ enum class Enum { Release = 1, Beta, Alpha, UNKNOWN };
+ IndexedVersionType(const QString& type);
+ IndexedVersionType(int type);
+ IndexedVersionType(const IndexedVersionType::Enum& type);
+ IndexedVersionType(const IndexedVersionType& type);
+ IndexedVersionType() : IndexedVersionType(IndexedVersionType::Enum::UNKNOWN) {}
+ static const QString toString(const IndexedVersionType::Enum& type);
+ static IndexedVersionType::Enum enumFromString(const QString& type);
+ bool isValid() const { return m_type != IndexedVersionType::Enum::UNKNOWN; }
+ IndexedVersionType& operator=(const IndexedVersionType& other);
+ bool operator==(const IndexedVersionType& other) const { return m_type == other.m_type; }
+ bool operator==(const IndexedVersionType::Enum& type) const { return m_type == type; }
+ bool operator!=(const IndexedVersionType& other) const { return m_type != other.m_type; }
+ bool operator!=(const IndexedVersionType::Enum& type) const { return m_type != type; }
+ bool operator<(const IndexedVersionType& other) const { return m_type < other.m_type; }
+ bool operator<(const IndexedVersionType::Enum& type) const { return m_type < type; }
+ bool operator<=(const IndexedVersionType& other) const { return m_type <= other.m_type; }
+ bool operator<=(const IndexedVersionType::Enum& type) const { return m_type <= type; }
+ bool operator>(const IndexedVersionType& other) const { return m_type > other.m_type; }
+ bool operator>(const IndexedVersionType::Enum& type) const { return m_type > type; }
+ bool operator>=(const IndexedVersionType& other) const { return m_type >= other.m_type; }
+ bool operator>=(const IndexedVersionType::Enum& type) const { return m_type >= type; }
+
+ QString toString() const { return toString(m_type); }
+
+ IndexedVersionType::Enum m_type;
+};
+
struct Dependency {
QVariant addonId;
DependencyType type;
@@ -66,6 +96,7 @@ struct IndexedVersion {
QVariant fileId;
QString version;
QString version_number = {};
+ IndexedVersionType verison_type;
QStringList mcVersion;
QString downloadUrl;
QString date;
diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp
index 5b0b1d8b..43470300 100644
--- a/launcher/modplatform/flame/FlameAPI.cpp
+++ b/launcher/modplatform/flame/FlameAPI.cpp
@@ -135,7 +135,8 @@ auto FlameAPI::getLatestVersion(VersionSearchArgs&& args) -> ModPlatform::Indexe
for (auto file : arr) {
auto file_obj = Json::requireObject(file);
auto file_tmp = FlameMod::loadIndexedPackVersion(file_obj);
- if (file_tmp.date > ver_tmp.date) {
+ bool better_release = file_tmp.verison_type <= ver_tmp.verison_type;
+ if (file_tmp.date > ver_tmp.date && better_release) {
ver_tmp = file_tmp;
latest_file_obj = file_obj;
}
diff --git a/launcher/modplatform/flame/FlameCheckUpdate.cpp b/launcher/modplatform/flame/FlameCheckUpdate.cpp
index a2628e34..cf159cad 100644
--- a/launcher/modplatform/flame/FlameCheckUpdate.cpp
+++ b/launcher/modplatform/flame/FlameCheckUpdate.cpp
@@ -173,7 +173,7 @@ void FlameCheckUpdate::executeTask()
}
auto download_task = makeShared<ResourceDownloadTask>(pack, latest_ver, m_mods_folder);
- m_updatable.emplace_back(pack->name, mod->metadata()->hash, old_version, latest_ver.version,
+ m_updatable.emplace_back(pack->name, mod->metadata()->hash, old_version, latest_ver.version, latest_ver.verison_type,
api.getModFileChangelog(latest_ver.addonId.toInt(), latest_ver.fileId.toInt()),
ModPlatform::ResourceProvider::FLAME, download_task);
}
diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp
index 227ce489..108d8b37 100644
--- a/launcher/modplatform/flame/FlameModIndex.cpp
+++ b/launcher/modplatform/flame/FlameModIndex.cpp
@@ -94,8 +94,9 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
}
auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
+ bool a_better_release = a.verison_type <= b.verison_type;
// dates are in RFC 3339 format
- return a.date > b.date;
+ return a.date > b.date && a_better_release;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
pack.versions = unsortedVersions;
@@ -123,6 +124,7 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) ->
file.version = Json::requireString(obj, "displayName");
file.downloadUrl = Json::ensureString(obj, "downloadUrl");
file.fileName = Json::requireString(obj, "fileName");
+ file.verison_type = ModPlatform::IndexedVersionType(Json::requireInteger(obj, "releaseType"));
auto hash_list = Json::ensureArray(obj, "hashes");
for (auto h : hash_list) {
diff --git a/launcher/modplatform/flame/FlamePackIndex.cpp b/launcher/modplatform/flame/FlamePackIndex.cpp
index ad48b7b6..e643c96b 100644
--- a/launcher/modplatform/flame/FlamePackIndex.cpp
+++ b/launcher/modplatform/flame/FlamePackIndex.cpp
@@ -90,6 +90,7 @@ void Flame::loadIndexedPackVersions(Flame::IndexedPack& pack, QJsonArray& arr)
// pick the latest version supported
file.mcVersion = versionArray[0].toString();
file.version = Json::requireString(version, "displayName");
+ file.version_type = ModPlatform::IndexedVersionType(Json::requireInteger(version, "releaseType"));
file.downloadUrl = Json::ensureString(version, "downloadUrl");
// only add if we have a download URL (third party distribution is enabled)
diff --git a/launcher/modplatform/flame/FlamePackIndex.h b/launcher/modplatform/flame/FlamePackIndex.h
index b089b722..5f642ace 100644
--- a/launcher/modplatform/flame/FlamePackIndex.h
+++ b/launcher/modplatform/flame/FlamePackIndex.h
@@ -6,6 +6,8 @@
#include <QVector>
#include "modplatform/ModIndex.h"
+#include "modplatform/ModIndex.h"
+
namespace Flame {
struct ModpackAuthor {
@@ -17,6 +19,7 @@ struct IndexedVersion {
int addonId;
int fileId;
QString version;
+ ModPlatform::IndexedVersionType version_type;
QString mcVersion;
QString downloadUrl;
};
diff --git a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp
index a7c22832..3ee22818 100644
--- a/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp
+++ b/launcher/modplatform/modrinth/ModrinthCheckUpdate.cpp
@@ -162,8 +162,8 @@ void ModrinthCheckUpdate::executeTask()
auto download_task = makeShared<ResourceDownloadTask>(pack, project_ver, m_mods_folder);
- m_updatable.emplace_back(pack->name, hash, mod->version(), project_ver.version_number, project_ver.changelog,
- ModPlatform::ResourceProvider::MODRINTH, download_task);
+ m_updatable.emplace_back(pack->name, hash, mod->version(), project_ver.version_number, project_ver.verison_type,
+ project_ver.changelog, ModPlatform::ResourceProvider::MODRINTH, download_task);
}
}
} catch (Json::JsonException& e) {
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index b4037349..4d0882f6 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -109,8 +109,9 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
unsortedVersions.append(file);
}
auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
+ bool a_better_release = a.verison_type <= b.verison_type;
// dates are in RFC 3339 format
- return a.date > b.date;
+ return a.date > b.date && a_better_release;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
pack.versions = unsortedVersions;
@@ -138,6 +139,8 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
}
file.version = Json::requireString(obj, "name");
file.version_number = Json::requireString(obj, "version_number");
+ file.verison_type = ModPlatform::IndexedVersionType(Json::requireString(obj, "version_type"));
+
file.changelog = Json::requireString(obj, "changelog");
auto dependencies = Json::ensureArray(obj, "dependencies");
diff --git a/launcher/modplatform/modrinth/ModrinthPackManifest.cpp b/launcher/modplatform/modrinth/ModrinthPackManifest.cpp
index 4dca786f..aff29fb8 100644
--- a/launcher/modplatform/modrinth/ModrinthPackManifest.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackManifest.cpp
@@ -111,8 +111,9 @@ void loadIndexedVersions(Modpack& pack, QJsonDocument& doc)
unsortedVersions.append(file);
}
auto orderSortPredicate = [](const ModpackVersion& a, const ModpackVersion& b) -> bool {
+ bool a_better_release = a.version_type <= b.version_type;
// dates are in RFC 3339 format
- return a.date > b.date;
+ return a.date > b.date && a_better_release;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
@@ -128,6 +129,7 @@ auto loadIndexedVersion(QJsonObject &obj) -> ModpackVersion
file.name = Json::requireString(obj, "name");
file.version = Json::requireString(obj, "version_number");
+ file.version_type = ModPlatform::IndexedVersionType(Json::requireString(obj, "version_type"));
file.changelog = Json::ensureString(obj, "changelog");
file.id = Json::requireString(obj, "id");
diff --git a/launcher/modplatform/modrinth/ModrinthPackManifest.h b/launcher/modplatform/modrinth/ModrinthPackManifest.h
index 2973dfba..5f8c50a1 100644
--- a/launcher/modplatform/modrinth/ModrinthPackManifest.h
+++ b/launcher/modplatform/modrinth/ModrinthPackManifest.h
@@ -45,6 +45,8 @@
#include <QUrl>
#include <QVector>
+#include "modplatform/ModIndex.h"
+
class MinecraftInstance;
namespace Modrinth {
@@ -80,6 +82,7 @@ struct ModpackExtra {
struct ModpackVersion {
QString name;
QString version;
+ ModPlatform::IndexedVersionType version_type;
QString changelog;
QString id;
diff --git a/launcher/ui/dialogs/ModUpdateDialog.cpp b/launcher/ui/dialogs/ModUpdateDialog.cpp
index 8618b924..9e010444 100644
--- a/launcher/ui/dialogs/ModUpdateDialog.cpp
+++ b/launcher/ui/dialogs/ModUpdateDialog.cpp
@@ -362,6 +362,11 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
auto new_version_item = new QTreeWidgetItem(item_top);
new_version_item->setText(0, tr("New version: %1").arg(info.new_version));
+ if (info.new_verison_type.has_value()) {
+ auto new_version_type_itme = new QTreeWidgetItem(item_top);
+ new_version_type_itme->setText(0, tr("New Version Type: %1").arg(info.new_verison_type.value().toString()));
+ }
+
auto changelog_item = new QTreeWidgetItem(item_top);
changelog_item->setText(0, tr("Changelog of the latest version"));
diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp
index 60a43128..9c9954a4 100644
--- a/launcher/ui/pages/modplatform/ModPage.cpp
+++ b/launcher/ui/pages/modplatform/ModPage.cpp
@@ -132,8 +132,10 @@ void ModPage::updateVersionList()
}
// Only add the version if it's valid or using the 'Any' filter, but never if the version is opted out
- if ((valid || m_filter->versions.empty()) && !optedOut(version))
- m_ui->versionSelectionBox->addItem(version.version, QVariant(i));
+ if ((valid || m_filter->versions.empty()) && !optedOut(version)) {
+ auto release_type = version.verison_type.isValid() ? QString(" : %1").arg(version.verison_type.toString()) : "";
+ m_ui->versionSelectionBox->addItem(QString("%1%2").arg(version.version, release_type), QVariant(i));
+ }
}
if (m_ui->versionSelectionBox->count() == 0) {
m_ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1));
diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp
index aab2ee89..5c8f23d2 100644
--- a/launcher/ui/pages/modplatform/ResourcePage.cpp
+++ b/launcher/ui/pages/modplatform/ResourcePage.cpp
@@ -268,6 +268,9 @@ void ResourcePage::updateVersionList()
if (optedOut(version))
continue;
+ auto release_type = current_pack->versions[i].verison_type.isValid()
+ ? QString(" : %1").arg(current_pack->versions[i].verison_type.toString())
+ : "";
m_ui->versionSelectionBox->addItem(current_pack->versions[i].version, QVariant(i));
}
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
index cef26bb6..57521151 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
@@ -155,7 +155,8 @@ void FlamePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
}
for (auto version : current.versions) {
- ui->versionSelectionBox->addItem(version.version, QVariant(version.downloadUrl));
+ auto release_type = version.version_type.isValid() ? QString(" : %1").arg(version.version_type.toString()) : "";
+ ui->versionSelectionBox->addItem(QString("%1%2").arg(version.version, release_type), QVariant(version.downloadUrl));
}
QVariant current_updated;
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index c71dd903..9ca26ea9 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -198,12 +198,12 @@ void ModrinthPage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
qDebug() << *response;
qWarning() << "Error while reading modrinth modpack version: " << e.cause();
}
-
for (auto version : current.versions) {
+ auto release_type = version.version_type.isValid() ? QString(" : %1").arg(version.version_type.toString()) : "";
if (!version.name.contains(version.version))
- ui->versionSelectionBox->addItem(QString("%1 — %2").arg(version.name, version.version), QVariant(version.id));
+ ui->versionSelectionBox->addItem(QString("%1 — %2%3").arg(version.name, version.version, release_type), QVariant(version.id));
else
- ui->versionSelectionBox->addItem(version.name, QVariant(version.id));
+ ui->versionSelectionBox->addItem(QString("%1%2").arg(version.name, release_type), QVariant(version.id));
}
QVariant current_updated;