diff options
-rw-r--r-- | application/dialogs/NewInstanceDialog.cpp | 2 | ||||
-rw-r--r-- | logic/BaseVersionList.cpp | 5 | ||||
-rw-r--r-- | logic/BaseVersionList.h | 10 | ||||
-rw-r--r-- | logic/java/JavaVersionList.cpp | 5 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 15 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.h | 3 | ||||
-rw-r--r-- | logic/minecraft/VersionFilterData.cpp | 4 | ||||
-rw-r--r-- | logic/minecraft/VersionFilterData.h | 4 |
8 files changed, 40 insertions, 8 deletions
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index b3aa805b..d67d3ada 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -64,7 +64,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); - setSelectedVersion(MMC->minecraftlist()->getLatestStable(), true); + setSelectedVersion(MMC->minecraftlist()->getRecommended(), true); InstIconKey = "infinity"; ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey)); 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; |