From 6ccc7e77f918503125c363eb8ac9455aa9fc095e Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 19 Jun 2023 22:42:27 +0100 Subject: Basic, unfinished & broken impl Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 140 ++--------------------------- 1 file changed, 5 insertions(+), 135 deletions(-) (limited to 'launcher/ui/pages/instance/VersionPage.cpp') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 74b7ec7c..97a6bbe4 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -52,6 +52,7 @@ #include #include "VersionPage.h" +#include "ui/dialogs/InstallLoaderDialog.h" #include "ui_VersionPage.h" #include "ui/dialogs/CustomMessageBox.h" @@ -254,20 +255,6 @@ void VersionPage::updateRunningStatus(bool running) void VersionPage::updateVersionControls() { - // FIXME: this is a dirty hack - auto minecraftVersion = Version(m_profile->getComponentVersion("net.minecraft")); - - ui->actionInstall_Forge->setEnabled(controlsEnabled); - - bool supportsFabric = minecraftVersion >= Version("1.14"); - ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric); - - bool supportsQuilt = minecraftVersion >= Version("1.14"); - ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt); - - bool supportsLiteLoader = minecraftVersion <= Version("1.12.2"); - ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader); - updateButtons(); } @@ -287,7 +274,6 @@ void VersionPage::updateButtons(int row) ui->actionAdd_Empty->setEnabled(controlsEnabled); ui->actionImport_Components->setEnabled(controlsEnabled); ui->actionReload->setEnabled(controlsEnabled); - ui->actionInstall_mods->setEnabled(controlsEnabled); ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_Agents->setEnabled(controlsEnabled); @@ -446,17 +432,6 @@ void VersionPage::on_actionChange_version_triggered() return; } auto uid = list->uid(); - // FIXME: this is a horrible HACK. Get version filtering information from the actual metadata... - if(uid == "net.minecraftforge") - { - on_actionInstall_Forge_triggered(); - return; - } - else if (uid == "com.mumfrey.liteloader") - { - on_actionInstall_LiteLoader_triggered(); - return; - } VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") { @@ -508,87 +483,11 @@ void VersionPage::on_actionDownload_All_triggered() m_container->refreshContainer(); } -void VersionPage::on_actionInstall_Forge_triggered() +void VersionPage::on_actionInstall_Loader_triggered() { - auto vlist = APPLICATION->metadataIndex()->get("net.minecraftforge"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!")); - - auto currentVersion = m_profile->getComponentVersion("net.minecraftforge"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) - { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("net.minecraftforge", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - // m_profile->installVersion(); - preselect(m_profile->rowCount(QModelIndex())-1); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Fabric_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("net.fabricmc.fabric-loader"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Fabric Loader version"), this); - vselect.setEmptyString(tr("No Fabric Loader versions are currently available.")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Fabric Loader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("net.fabricmc.fabric-loader"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) - { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("net.fabricmc.fabric-loader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - preselect(m_profile->rowCount(QModelIndex())-1); - m_container->refreshContainer(); - } -} - -void VersionPage::on_actionInstall_Quilt_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this); - vselect.setEmptyString(tr("No Quilt Loader versions are currently available.")); - vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) - { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - preselect(m_profile->rowCount(QModelIndex())-1); - m_container->refreshContainer(); - } + InstallLoaderDialog dialog(m_inst->getPackProfile(), this); + dialog.exec(); + m_container->refreshContainer(); } void VersionPage::on_actionAdd_Empty_triggered() @@ -609,35 +508,6 @@ void VersionPage::on_actionAdd_Empty_triggered() } } -void VersionPage::on_actionInstall_LiteLoader_triggered() -{ - auto vlist = APPLICATION->metadataIndex()->get("com.mumfrey.liteloader"); - if(!vlist) - { - return; - } - VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_profile->getComponentVersion("net.minecraft")); - vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!")); - - auto currentVersion = m_profile->getComponentVersion("com.mumfrey.liteloader"); - if(!currentVersion.isEmpty()) - { - vselect.setCurrentVersion(currentVersion); - } - - if (vselect.exec() && vselect.selectedVersion()) - { - auto vsn = vselect.selectedVersion(); - m_profile->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor()); - m_profile->resolve(Net::Mode::Online); - // m_profile->installVersion(vselect.selectedVersion()); - preselect(m_profile->rowCount(QModelIndex())-1); - m_container->refreshContainer(); - } -} - void VersionPage::on_actionLibrariesFolder_triggered() { DesktopServices::openDirectory(m_inst->getLocalLibraryPath(), true); -- cgit From 82d3755e25fc01e3468e6940abab9dcc0a819e22 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 19 Jun 2023 23:36:18 +0100 Subject: License all the things Signed-off-by: TheKodeToad --- launcher/ui/InstanceWindow.cpp | 3 ++- launcher/ui/InstanceWindow.h | 3 ++- launcher/ui/dialogs/InstallLoaderDialog.cpp | 18 ++++++++++++++++++ launcher/ui/dialogs/InstallLoaderDialog.h | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.cpp | 2 +- launcher/ui/dialogs/ResourceDownloadDialog.h | 2 +- launcher/ui/pages/instance/VersionPage.cpp | 2 +- launcher/ui/pages/modplatform/ResourcePage.cpp | 2 +- launcher/ui/widgets/PageContainer.cpp | 3 ++- launcher/ui/widgets/PageContainer.h | 3 ++- 10 files changed, 31 insertions(+), 9 deletions(-) (limited to 'launcher/ui/pages/instance/VersionPage.cpp') diff --git a/launcher/ui/InstanceWindow.cpp b/launcher/ui/InstanceWindow.cpp index d9a21f6f..30a215e3 100644 --- a/launcher/ui/InstanceWindow.cpp +++ b/launcher/ui/InstanceWindow.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/InstanceWindow.h b/launcher/ui/InstanceWindow.h index 78d7474d..adbc46ac 100644 --- a/launcher/ui/InstanceWindow.h +++ b/launcher/ui/InstanceWindow.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 34c91c68..1b003e52 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 TheKodeToad + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "InstallLoaderDialog.h" #include diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 26b39e4a..7a32e427 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only /* * Prism Launcher - Minecraft Launcher - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.cpp b/launcher/ui/dialogs/ResourceDownloadDialog.cpp index 784662a0..8d4e51b2 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.cpp +++ b/launcher/ui/dialogs/ResourceDownloadDialog.cpp @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/dialogs/ResourceDownloadDialog.h b/launcher/ui/dialogs/ResourceDownloadDialog.h index 5077b2ca..b56a9adc 100644 --- a/launcher/ui/dialogs/ResourceDownloadDialog.h +++ b/launcher/ui/dialogs/ResourceDownloadDialog.h @@ -2,7 +2,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 97a6bbe4..53a71008 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -6,7 +6,7 @@ * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022-2023 Sefa Eyeoglu - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp index 91d722fc..ace7fb1b 100644 --- a/launcher/ui/pages/modplatform/ResourcePage.cpp +++ b/launcher/ui/pages/modplatform/ResourcePage.cpp @@ -4,7 +4,7 @@ /* * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu - * Copyright (C) 2022 TheKodeToad + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index c3606b78..308fad6b 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h index 89c3343e..1da269ce 100644 --- a/launcher/ui/widgets/PageContainer.h +++ b/launcher/ui/widgets/PageContainer.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2023 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 4cdf669154327b764ea2f7371e3d29f71d06daa7 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 17:02:39 +0100 Subject: Modify "Change Version" to use "Install Loader" dialog Signed-off-by: TheKodeToad --- launcher/ui/dialogs/InstallLoaderDialog.cpp | 18 ++++++++++++++---- launcher/ui/dialogs/InstallLoaderDialog.h | 4 ++-- launcher/ui/pages/instance/VersionPage.cpp | 12 +++++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) (limited to 'launcher/ui/pages/instance/VersionPage.cpp') diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index f62fb8c4..74b3ea92 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -74,7 +74,14 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { bool m_loaded = false; }; -InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, QWidget* parent) +InstallLoaderPage* pageCast(BasePage* page) +{ + auto result = dynamic_cast(page); + Q_ASSERT(result != nullptr); + return result; +} + +InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, const QString& uid, QWidget* parent) : QDialog(parent), m_profile(profile), m_container(new PageContainer(this)), m_buttons(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); @@ -86,7 +93,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q auto refreshButton = new QPushButton(tr("&Refresh"), this); connect(refreshButton, &QPushButton::pressed, this, [this] { - dynamic_cast(m_container->selectedPage())->loadList(); + pageCast(m_container->selectedPage())->loadList(); }); buttonLayout->addWidget(refreshButton); @@ -105,7 +112,10 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, Q [this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); }); updateAcceptButton(m_container->selectedPage()); - dynamic_cast(m_container->selectedPage())->selectSearch(); + pageCast(m_container->selectedPage())->selectSearch(); + for (BasePage* page : m_container->getPages()) + if (page->id() == uid) + m_container->selectPage(page->id()); } QList InstallLoaderDialog::getPages() @@ -135,7 +145,7 @@ void InstallLoaderDialog::updateAcceptButton(const BasePage* page) void InstallLoaderDialog::done(int result) { if (result == Accepted) { - auto* page = dynamic_cast(m_container->selectedPage()); + auto* page = pageCast(m_container->selectedPage()); if (page->selectedVersion()) { m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor()); m_profile->resolve(Net::Mode::Online); diff --git a/launcher/ui/dialogs/InstallLoaderDialog.h b/launcher/ui/dialogs/InstallLoaderDialog.h index 6c8762dc..24064eaa 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.h +++ b/launcher/ui/dialogs/InstallLoaderDialog.h @@ -26,11 +26,11 @@ class PageContainer; class PackProfile; class QDialogButtonBox; -class InstallLoaderDialog : public QDialog, public BasePageProvider { +class InstallLoaderDialog final : public QDialog, public BasePageProvider { Q_OBJECT public: - explicit InstallLoaderDialog(std::shared_ptr instance, QWidget* parent = nullptr); + explicit InstallLoaderDialog(std::shared_ptr instance, const QString& uid = QString(), QWidget* parent = nullptr); QList getPages() override; QString dialogTitle() override; diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 53a71008..86ba5c27 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -432,6 +432,16 @@ void VersionPage::on_actionChange_version_triggered() return; } auto uid = list->uid(); + + // FIXME: this is still a horrible HACK. + if (uid == "net.minecraftforge" || uid == "com.mumfrey.liteloader" || uid == "net.fabricmc.fabric-loader" || + uid == "org.quiltmc.quilt-loader") { + InstallLoaderDialog dialog(m_inst->getPackProfile(), uid, this); + dialog.exec(); + m_container->refreshContainer(); + return; + } + VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this); if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed") { @@ -485,7 +495,7 @@ void VersionPage::on_actionDownload_All_triggered() void VersionPage::on_actionInstall_Loader_triggered() { - InstallLoaderDialog dialog(m_inst->getPackProfile(), this); + InstallLoaderDialog dialog(m_inst->getPackProfile(), QString(), this); dialog.exec(); m_container->refreshContainer(); } -- cgit From 6cc3587da2a87c87d37f205fd39a31a5a136814a Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 1 Jul 2023 20:10:38 +0100 Subject: Disable as intended Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/VersionPage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'launcher/ui/pages/instance/VersionPage.cpp') diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 86ba5c27..31e0b9b3 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -274,8 +274,9 @@ void VersionPage::updateButtons(int row) ui->actionAdd_Empty->setEnabled(controlsEnabled); ui->actionImport_Components->setEnabled(controlsEnabled); ui->actionReload->setEnabled(controlsEnabled); - ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); + ui->actionInstall_Loader->setEnabled(controlsEnabled); ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); + ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_Agents->setEnabled(controlsEnabled); } -- cgit From 64c591b234cec2519d8a04b32d4b6e85dcf204da Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 3 Jul 2023 20:48:37 +0100 Subject: Better parent version filtering; handle old fabric :P Signed-off-by: TheKodeToad --- launcher/Filter.cpp | 6 ++++++ launcher/Filter.h | 10 ++++++++++ launcher/ui/dialogs/InstallLoaderDialog.cpp | 17 +++++++++-------- launcher/ui/dialogs/VersionSelectDialog.cpp | 4 ++++ launcher/ui/dialogs/VersionSelectDialog.h | 1 + launcher/ui/pages/instance/VersionPage.cpp | 12 ++---------- launcher/ui/widgets/VersionSelectWidget.cpp | 9 +++++++-- launcher/ui/widgets/VersionSelectWidget.h | 1 + 8 files changed, 40 insertions(+), 20 deletions(-) (limited to 'launcher/ui/pages/instance/VersionPage.cpp') diff --git a/launcher/Filter.cpp b/launcher/Filter.cpp index c65ca0ce..f9530597 100644 --- a/launcher/Filter.cpp +++ b/launcher/Filter.cpp @@ -16,6 +16,12 @@ bool ExactFilter::accepts(const QString& value) return value == pattern; } +ExactIfPresentFilter::ExactIfPresentFilter(const QString& pattern) : pattern(pattern) {} +bool ExactIfPresentFilter::accepts(const QString& value) +{ + return value.isEmpty() || value == pattern; +} + RegexpFilter::RegexpFilter(const QString& regexp, bool invert) :invert(invert) { diff --git a/launcher/Filter.h b/launcher/Filter.h index b55067ac..d3cee2d8 100644 --- a/launcher/Filter.h +++ b/launcher/Filter.h @@ -30,6 +30,16 @@ private: QString pattern; }; +class ExactIfPresentFilter: public Filter +{ + public: + ExactIfPresentFilter(const QString& pattern); + ~ExactIfPresentFilter() override = default; + bool accepts(const QString& value) override; + private: + QString pattern; +}; + class RegexpFilter: public Filter { public: diff --git a/launcher/ui/dialogs/InstallLoaderDialog.cpp b/launcher/ui/dialogs/InstallLoaderDialog.cpp index 31d6f9ab..bab5b835 100644 --- a/launcher/ui/dialogs/InstallLoaderDialog.cpp +++ b/launcher/ui/dialogs/InstallLoaderDialog.cpp @@ -35,15 +35,16 @@ class InstallLoaderPage : public VersionSelectWidget, public BasePage { InstallLoaderPage(const QString& id, const QString& icon, const QString& name, - // "lightweight" loaders are independent to any game version - const bool lightweight, + const Version& oldestVersion, const std::shared_ptr profile) : VersionSelectWidget(nullptr), uid(id), iconName(icon), name(name) { const QString minecraftVersion = profile->getComponentVersion("net.minecraft"); setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion)); - if (!lightweight) - setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + setExactIfPresentFilter(BaseVersionList::ParentVersionRole, minecraftVersion); + + if (oldestVersion != Version() && Version(minecraftVersion) < oldestVersion) + setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); if (const QString currentVersion = profile->getComponentVersion(id); !currentVersion.isNull()) setCurrentVersion(currentVersion); @@ -129,13 +130,13 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr profile, c QList InstallLoaderDialog::getPages() { return { // Forge - new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, profile), + new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), {}, profile), // Fabric - new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, profile), + new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), Version("1.14"), profile), // Quilt - new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, profile), + new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), Version("1.14"), profile), // LiteLoader - new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, profile) + new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), {}, profile) }; } diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index e45787e4..9fa3c90f 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -152,6 +152,10 @@ void VersionSelectDialog::setExactFilter(BaseVersionList::ModelRoles role, QStri m_versionWidget->setExactFilter(role, filter); } +void VersionSelectDialog::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter) { + m_versionWidget->setExactIfPresentFilter(role, filter); +} + void VersionSelectDialog::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) { m_versionWidget->setFuzzyFilter(role, filter); diff --git a/launcher/ui/dialogs/VersionSelectDialog.h b/launcher/ui/dialogs/VersionSelectDialog.h index 18a50cdb..c20a9ed5 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.h +++ b/launcher/ui/dialogs/VersionSelectDialog.h @@ -49,6 +49,7 @@ public: void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); void setExactFilter(BaseVersionList::ModelRoles role, QString filter); + void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter); void setEmptyString(QString emptyString); void setEmptyErrorString(QString emptyErrorString); void setResizeOn(int column); diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 31e0b9b3..a8e6e948 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -434,22 +434,14 @@ void VersionPage::on_actionChange_version_triggered() } auto uid = list->uid(); - // FIXME: this is still a horrible HACK. - if (uid == "net.minecraftforge" || uid == "com.mumfrey.liteloader" || uid == "net.fabricmc.fabric-loader" || - uid == "org.quiltmc.quilt-loader") { - InstallLoaderDialog dialog(m_inst->getPackProfile(), uid, this); - dialog.exec(); - m_container->refreshContainer(); - return; - } - 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.")); vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!")); - vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); } + vselect.setExactIfPresentFilter(BaseVersionList::ParentVersionRole, m_profile->getComponentVersion("net.minecraft")); + auto currentVersion = patch->getVersion(); if(!currentVersion.isEmpty()) { diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index f20dad71..2b22a4a9 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -238,14 +238,19 @@ BaseVersion::Ptr VersionSelectWidget::selectedVersion() const return variant.value(); } +void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) +{ + m_proxyModel->setFilter(role, new ContainsFilter(filter)); +} + void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QString filter) { m_proxyModel->setFilter(role, new ExactFilter(filter)); } -void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter) +void VersionSelectWidget::setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter) { - m_proxyModel->setFilter(role, new ContainsFilter(filter)); + m_proxyModel->setFilter(role, new ExactIfPresentFilter(filter)); } void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter *filter) diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index 624d9a23..598e1059 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -70,6 +70,7 @@ public: void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); void setExactFilter(BaseVersionList::ModelRoles role, QString filter); + void setExactIfPresentFilter(BaseVersionList::ModelRoles role, QString filter); void setFilter(BaseVersionList::ModelRoles role, Filter *filter); void setEmptyString(QString emptyString); void setEmptyErrorString(QString emptyErrorString); -- cgit