NOISSUE handle recommended versions better
Moved constants to the version data file Use recommended Minecraft instead of latest stable for new instances by default
This commit is contained in:
parent
bb01c91469
commit
4fc4a17256
@ -64,7 +64,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent)
|
|||||||
resize(minimumSizeHint());
|
resize(minimumSizeHint());
|
||||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
|
||||||
setSelectedVersion(MMC->minecraftlist()->getLatestStable(), true);
|
setSelectedVersion(MMC->minecraftlist()->getRecommended(), true);
|
||||||
InstIconKey = "infinity";
|
InstIconKey = "infinity";
|
||||||
ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey));
|
ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey));
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ BaseVersionPtr BaseVersionList::getLatestStable() const
|
|||||||
return at(0);
|
return at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseVersionPtr BaseVersionList::getRecommended() const
|
||||||
|
{
|
||||||
|
return getLatestStable();
|
||||||
|
}
|
||||||
|
|
||||||
QVariant BaseVersionList::data(const QModelIndex &index, int role) const
|
QVariant BaseVersionList::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
@ -90,12 +90,16 @@ public:
|
|||||||
virtual BaseVersionPtr findVersion(const QString &descriptor);
|
virtual BaseVersionPtr findVersion(const QString &descriptor);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the latest stable version of this instance type.
|
* \brief Gets the latest stable version from this list
|
||||||
* This is the version that will be selected by default.
|
|
||||||
* By default, this is simply the first version in the list.
|
|
||||||
*/
|
*/
|
||||||
virtual BaseVersionPtr getLatestStable() const;
|
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.
|
* Sorts the version list.
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "java/JavaCheckerJob.h"
|
#include "java/JavaCheckerJob.h"
|
||||||
#include "java/JavaUtils.h"
|
#include "java/JavaUtils.h"
|
||||||
#include "MMCStrings.h"
|
#include "MMCStrings.h"
|
||||||
|
#include "minecraft/VersionFilterData.h"
|
||||||
|
|
||||||
JavaVersionList::JavaVersionList(QObject *parent) : BaseVersionList(parent)
|
JavaVersionList::JavaVersionList(QObject *parent) : BaseVersionList(parent)
|
||||||
{
|
{
|
||||||
@ -121,8 +122,8 @@ bool sortJavas(BaseVersionPtr left, BaseVersionPtr right)
|
|||||||
if(archCompare != 0)
|
if(archCompare != 0)
|
||||||
return archCompare > 0;
|
return archCompare > 0;
|
||||||
// dirty hack - 1.9 and above is too new
|
// dirty hack - 1.9 and above is too new
|
||||||
auto labove19 = Strings::naturalCompare(rleft->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(), "1.9.0", Qt::CaseInsensitive) >= 0;
|
auto rabove19 = Strings::naturalCompare(rright->name(), g_VersionFilterData.discouragedJavaVersion, Qt::CaseInsensitive) >= 0;
|
||||||
if(labove19 == rabove19)
|
if(labove19 == rabove19)
|
||||||
{
|
{
|
||||||
// prefer higher versions in general
|
// prefer higher versions in general
|
||||||
|
@ -364,7 +364,7 @@ QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
|
|||||||
return version->descriptor();
|
return version->descriptor();
|
||||||
|
|
||||||
case RecommendedRole:
|
case RecommendedRole:
|
||||||
return version->descriptor() == "1.7.10";
|
return version->descriptor() == g_VersionFilterData.recommendedMinecraftVersion;
|
||||||
|
|
||||||
case TypeRole:
|
case TypeRole:
|
||||||
return version->typeString();
|
return version->typeString();
|
||||||
@ -386,6 +386,19 @@ BaseVersionPtr MinecraftVersionList::getLatestStable() const
|
|||||||
return BaseVersionPtr();
|
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)
|
void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -53,7 +53,8 @@ public:
|
|||||||
virtual QVariant data(const QModelIndex & index, int role) const;
|
virtual QVariant data(const QModelIndex & index, int role) const;
|
||||||
virtual RoleList providesRoles();
|
virtual RoleList providesRoles();
|
||||||
|
|
||||||
virtual BaseVersionPtr getLatestStable() const;
|
virtual BaseVersionPtr getLatestStable() const override;
|
||||||
|
virtual BaseVersionPtr getRecommended() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<BaseVersionPtr> m_vlist;
|
QList<BaseVersionPtr> m_vlist;
|
||||||
|
@ -69,4 +69,8 @@ VersionFilterData::VersionFilterData()
|
|||||||
QSet<QString>{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
|
QSet<QString>{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
|
||||||
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
|
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
|
||||||
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
|
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
|
||||||
|
|
||||||
|
// Version list magic
|
||||||
|
recommendedMinecraftVersion = "1.7.10";
|
||||||
|
discouragedJavaVersion = "1.9.0";
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,9 @@ struct VersionFilterData
|
|||||||
QDateTime legacyCutoffDate;
|
QDateTime legacyCutoffDate;
|
||||||
// Libraries that belong to LWJGL
|
// Libraries that belong to LWJGL
|
||||||
QSet<QString> lwjglWhitelist;
|
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;
|
extern VersionFilterData g_VersionFilterData;
|
||||||
|
Loading…
Reference in New Issue
Block a user