summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-02 12:44:37 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-02 12:44:37 +0200
commit4fc4a172562a76091721b8c488aafbd6ed2b01ed (patch)
tree618f1f0cb5e2308289178f2398550962f9eed2cd /logic
parentbb01c91469e3c5cbb250ce47c2d40f00f8be0c0a (diff)
downloadMultiMC-4fc4a172562a76091721b8c488aafbd6ed2b01ed.tar
MultiMC-4fc4a172562a76091721b8c488aafbd6ed2b01ed.tar.gz
MultiMC-4fc4a172562a76091721b8c488aafbd6ed2b01ed.tar.lz
MultiMC-4fc4a172562a76091721b8c488aafbd6ed2b01ed.tar.xz
MultiMC-4fc4a172562a76091721b8c488aafbd6ed2b01ed.zip
NOISSUE handle recommended versions better
Moved constants to the version data file Use recommended Minecraft instead of latest stable for new instances by default
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseVersionList.cpp5
-rw-r--r--logic/BaseVersionList.h10
-rw-r--r--logic/java/JavaVersionList.cpp5
-rw-r--r--logic/minecraft/MinecraftVersionList.cpp15
-rw-r--r--logic/minecraft/MinecraftVersionList.h3
-rw-r--r--logic/minecraft/VersionFilterData.cpp4
-rw-r--r--logic/minecraft/VersionFilterData.h4
7 files changed, 39 insertions, 7 deletions
diff --git a/logic/BaseVersionList.cpp b/logic/BaseVersionList.cpp
index fe17a905..73f4a7ef 100644
--- a/logic/BaseVersionList.cpp
+++ b/logic/BaseVersionList.cpp
@@ -38,6 +38,11 @@ BaseVersionPtr BaseVersionList::getLatestStable() const
return at(0);
}
+BaseVersionPtr BaseVersionList::getRecommended() const
+{
+ return getLatestStable();
+}
+
QVariant BaseVersionList::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
diff --git a/logic/BaseVersionList.h b/logic/BaseVersionList.h
index 6089c31c..432f6593 100644
--- a/logic/BaseVersionList.h
+++ b/logic/BaseVersionList.h
@@ -90,13 +90,17 @@ public:
virtual BaseVersionPtr findVersion(const QString &descriptor);
/*!
- * \brief Gets the latest stable version of this instance type.
- * This is the version that will be selected by default.
- * By default, this is simply the first version in the list.
+ * \brief Gets the latest stable version from this list
*/
virtual BaseVersionPtr getLatestStable() const;
/*!
+ * \brief Gets the recommended version from this list
+ * If the list doesn't support recommended versions, this works exactly as getLatestStable
+ */
+ virtual BaseVersionPtr getRecommended() const;
+
+ /*!
* Sorts the version list.
*/
virtual void sort() = 0;
diff --git a/logic/java/JavaVersionList.cpp b/logic/java/JavaVersionList.cpp
index d607ae72..7889853b 100644
--- a/logic/java/JavaVersionList.cpp
+++ b/logic/java/JavaVersionList.cpp
@@ -23,6 +23,7 @@
#include "java/JavaCheckerJob.h"
#include "java/JavaUtils.h"
#include "MMCStrings.h"
+#include "minecraft/VersionFilterData.h"
JavaVersionList::JavaVersionList(QObject *parent) : BaseVersionList(parent)
{
@@ -121,8 +122,8 @@ bool sortJavas(BaseVersionPtr left, BaseVersionPtr right)
if(archCompare != 0)
return archCompare > 0;
// dirty hack - 1.9 and above is too new
- auto labove19 = Strings::naturalCompare(rleft->name(), "1.9.0", Qt::CaseInsensitive) >= 0;
- auto rabove19 = Strings::naturalCompare(rright->name(), "1.9.0", Qt::CaseInsensitive) >= 0;
+ auto labove19 = Strings::naturalCompare(rleft->name(), g_VersionFilterData.discouragedJavaVersion, Qt::CaseInsensitive) >= 0;
+ auto rabove19 = Strings::naturalCompare(rright->name(), g_VersionFilterData.discouragedJavaVersion, Qt::CaseInsensitive) >= 0;
if(labove19 == rabove19)
{
// prefer higher versions in general
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp
index f57478e3..5f29bfec 100644
--- a/logic/minecraft/MinecraftVersionList.cpp
+++ b/logic/minecraft/MinecraftVersionList.cpp
@@ -364,7 +364,7 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
return version->descriptor();
case RecommendedRole:
- return version->descriptor() == "1.7.10";
+ return version->descriptor() == g_VersionFilterData.recommendedMinecraftVersion;
case TypeRole:
return version->typeString();
@@ -386,6 +386,19 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
return BaseVersionPtr();
}
+BaseVersionPtr MinecraftVersionList::getRecommended() const
+{
+ for(auto item: m_vlist)
+ {
+ auto version = std::dynamic_pointer_cast<MinecraftVersion>(item);
+ if(version->descriptor() == g_VersionFilterData.recommendedMinecraftVersion)
+ {
+ return item;
+ }
+ }
+ return getLatestStable();
+}
+
void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions)
{
beginResetModel();
diff --git a/logic/minecraft/MinecraftVersionList.h b/logic/minecraft/MinecraftVersionList.h
index 7244d453..8e45d35a 100644
--- a/logic/minecraft/MinecraftVersionList.h
+++ b/logic/minecraft/MinecraftVersionList.h
@@ -53,7 +53,8 @@ public:
virtual QVariant data(const QModelIndex & index, int role) const;
virtual RoleList providesRoles();
- virtual BaseVersionPtr getLatestStable() const;
+ virtual BaseVersionPtr getLatestStable() const override;
+ virtual BaseVersionPtr getRecommended() const override;
protected:
QList<BaseVersionPtr> m_vlist;
diff --git a/logic/minecraft/VersionFilterData.cpp b/logic/minecraft/VersionFilterData.cpp
index ef8b049e..8270a490 100644
--- a/logic/minecraft/VersionFilterData.cpp
+++ b/logic/minecraft/VersionFilterData.cpp
@@ -69,4 +69,8 @@ VersionFilterData::VersionFilterData()
QSet<QString>{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
+
+ // Version list magic
+ recommendedMinecraftVersion = "1.7.10";
+ discouragedJavaVersion = "1.9.0";
}
diff --git a/logic/minecraft/VersionFilterData.h b/logic/minecraft/VersionFilterData.h
index 98ecb36c..339e3891 100644
--- a/logic/minecraft/VersionFilterData.h
+++ b/logic/minecraft/VersionFilterData.h
@@ -24,5 +24,9 @@ struct VersionFilterData
QDateTime legacyCutoffDate;
// Libraries that belong to LWJGL
QSet<QString> lwjglWhitelist;
+ // Currently recommended minecraft version
+ QString recommendedMinecraftVersion;
+ // Currently discouraged java version (anything equal and above will be discouraged)
+ QString discouragedJavaVersion;
};
extern VersionFilterData g_VersionFilterData;