NOISSUE Support custom,latest,recommended loader versions for ATL

This provides support for modpacks using the new loader mechanism in
ATLauncher and using a non-specific version target.
This commit is contained in:
Jamie Mansfield
2021-04-13 18:30:37 +01:00
parent 8b926d29d7
commit 87dbe82474
5 changed files with 109 additions and 26 deletions

View File

@ -4,6 +4,7 @@
#include "dialogs/NewInstanceDialog.h"
#include <modplatform/atlauncher/ATLPackInstallTask.h>
#include <BuildConfig.h>
#include <dialogs/VersionSelectDialog.h>
AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget *parent)
: QWidget(parent), ui(new Ui::AtlPage), dialog(dialog)
@ -50,7 +51,7 @@ void AtlPage::openedImpl()
void AtlPage::suggestCurrent()
{
if(isOpened) {
dialog->setSuggestedPack(selected.name, new ATLauncher::PackInstallTask(selected.safeName, selectedVersion));
dialog->setSuggestedPack(selected.name, new ATLauncher::PackInstallTask(this, selected.safeName, selectedVersion));
}
auto editedLogoName = selected.safeName;
@ -112,3 +113,39 @@ void AtlPage::onVersionSelectionChanged(QString data)
selectedVersion = data;
suggestCurrent();
}
QString AtlPage::chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) {
VersionSelectDialog vselect(vlist.get(), "Choose Version", MMC->activeWindow(), false);
if (minecraftVersion != Q_NULLPTR) {
vselect.setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
vselect.setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
}
else {
vselect.setEmptyString(tr("No versions are currently available"));
}
vselect.setEmptyErrorString(tr("Couldn't load or download the version lists!"));
// select recommended build
for (int i = 0; i < vlist->versions().size(); i++) {
auto version = vlist->versions().at(i);
auto reqs = version->requires();
// filter by minecraft version, if the loader depends on a certain version.
if (minecraftVersion != Q_NULLPTR) {
auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require &req) {
return req.uid == "net.minecraft";
});
if (iter == reqs.end()) continue;
if (iter->equalsVersion != minecraftVersion) continue;
}
// first recommended build we find, we use.
if (version->isRecommended()) {
vselect.setCurrentVersion(version->descriptor());
break;
}
}
vselect.exec();
return vselect.selectedVersion()->descriptor();
}

View File

@ -19,6 +19,7 @@
#include "AtlListModel.h"
#include <QWidget>
#include <modplatform/atlauncher/ATLPackInstallTask.h>
#include "MultiMC.h"
#include "pages/BasePage.h"
@ -31,7 +32,7 @@ namespace Ui
class NewInstanceDialog;
class AtlPage : public QWidget, public BasePage
class AtlPage : public QWidget, public BasePage, public ATLauncher::UserInteractionSupport
{
Q_OBJECT
@ -61,6 +62,8 @@ public:
private:
void suggestCurrent();
QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) override;
private slots:
void triggerSearch();
void resetSearch();