feat(components) recomend the correct lwjgl version for the minecraft version
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
9d903175ab
commit
44bf0315ad
@ -99,7 +99,7 @@ QVariant VersionList::data(const QModelIndex& index, int role) const
|
||||
case VersionPtrRole:
|
||||
return QVariant::fromValue(version);
|
||||
case RecommendedRole:
|
||||
return version->isRecommended();
|
||||
return version->isRecommended() || m_externalRecommendsVersions.contains(version->version());
|
||||
// FIXME: this should be determined in whatever view/proxy is used...
|
||||
// case LatestRole: return version == getLatestStable();
|
||||
default:
|
||||
@ -179,6 +179,16 @@ void VersionList::parse(const QJsonObject& obj)
|
||||
parseVersionList(obj, this);
|
||||
}
|
||||
|
||||
void VersionList::addExternalRecomends(const QVector<QString>& recomends)
|
||||
{
|
||||
m_externalRecommendsVersions.append(recomends);
|
||||
}
|
||||
|
||||
void VersionList::clearExternalRecomends()
|
||||
{
|
||||
m_externalRecommendsVersions.clear();
|
||||
}
|
||||
|
||||
// FIXME: this is dumb, we have 'recommended' as part of the metadata already...
|
||||
static const Meta::Version::Ptr& getBetterVersion(const Meta::Version::Ptr& a, const Meta::Version::Ptr& b)
|
||||
{
|
||||
|
@ -68,6 +68,8 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
||||
void merge(const VersionList::Ptr& other);
|
||||
void mergeFromIndex(const VersionList::Ptr& other);
|
||||
void parse(const QJsonObject& obj) override;
|
||||
void addExternalRecomends(const QVector<QString>& recomends);
|
||||
void clearExternalRecomends();
|
||||
|
||||
signals:
|
||||
void nameChanged(const QString& name);
|
||||
@ -77,6 +79,7 @@ class VersionList : public BaseVersionList, public BaseEntity {
|
||||
|
||||
private:
|
||||
QVector<Version::Ptr> m_versions;
|
||||
QStringList m_externalRecommendsVersions;
|
||||
QHash<QString, Version::Ptr> m_lookup;
|
||||
QString m_uid;
|
||||
QString m_name;
|
||||
|
@ -49,8 +49,10 @@
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <algorithm>
|
||||
|
||||
#include "VersionPage.h"
|
||||
#include "meta/JsonFormat.h"
|
||||
#include "ui/dialogs/InstallLoaderDialog.h"
|
||||
#include "ui_VersionPage.h"
|
||||
|
||||
@ -63,11 +65,9 @@
|
||||
|
||||
#include "DesktopServices.h"
|
||||
#include "Exception.h"
|
||||
#include "Version.h"
|
||||
#include "icons/IconList.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "minecraft/auth/AccountList.h"
|
||||
#include "minecraft/mod/Mod.h"
|
||||
|
||||
#include "meta/Index.h"
|
||||
#include "meta/VersionList.h"
|
||||
@ -370,11 +370,25 @@ void VersionPage::on_actionChange_version_triggered()
|
||||
auto patch = m_profile->getComponent(versionRow);
|
||||
auto name = patch->getName();
|
||||
auto list = patch->getVersionList();
|
||||
list->clearExternalRecomends();
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
auto uid = list->uid();
|
||||
|
||||
// recommend the correct lwjgl version for the current minecraft version
|
||||
if (uid == "org.lwjgl" || uid == "org.lwjgl3") {
|
||||
auto minecraft = m_profile->getComponent("net.minecraft");
|
||||
auto lwjglReq = std::find_if(minecraft->m_cachedRequires.cbegin(), minecraft->m_cachedRequires.cend(),
|
||||
[uid](const Meta::Require& req) -> bool { return req.uid == uid; });
|
||||
if (lwjglReq != minecraft->m_cachedRequires.cend()) {
|
||||
auto lwjglVersion = !lwjglReq->equalsVersion.isEmpty() ? lwjglReq->equalsVersion : lwjglReq->suggests;
|
||||
if (!lwjglVersion.isEmpty()) {
|
||||
list->addExternalRecomends({ lwjglVersion });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
|
||||
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") {
|
||||
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
|
||||
|
Loading…
Reference in New Issue
Block a user