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:
Rachel Powers
2024-06-20 15:55:58 -07:00
parent 9d903175ab
commit 44bf0315ad
3 changed files with 30 additions and 3 deletions

View File

@ -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."));