From db6dae754135a4e05420489571ad1233d0ec8933 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 20 Apr 2022 09:43:25 +0200 Subject: [PATCH] fix: disable major version match for snapshots --- launcher/ui/widgets/ModFilterWidget.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/launcher/ui/widgets/ModFilterWidget.cpp b/launcher/ui/widgets/ModFilterWidget.cpp index ffc8d05d..4ab34375 100644 --- a/launcher/ui/widgets/ModFilterWidget.cpp +++ b/launcher/ui/widgets/ModFilterWidget.cpp @@ -23,12 +23,21 @@ void ModFilterWidget::setInstance(MinecraftInstance* instance) { m_instance = instance; - auto mcVersionSplit = mcVersionStr().split("."); - ui->strictVersionButton->setText( tr("Strict match (= %1)").arg(mcVersionStr())); - ui->majorVersionButton->setText( - tr("Major version match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1])); + + // we can't do this for snapshots sadly + if(mcVersionStr().contains('.')) + { + auto mcVersionSplit = mcVersionStr().split("."); + ui->majorVersionButton->setText( + tr("Major version match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1])); + } + else + { + ui->majorVersionButton->setText(tr("Major version match (unsupported)")); + disableVersionButton(Major); + } ui->allVersionsButton->setText( tr("Any version")); //ui->betweenVersionsButton->setText( @@ -67,7 +76,6 @@ void ModFilterWidget::onVersionFilterChanged(int id) //ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between); //ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between); - auto versionSplit = mcVersionStr().split("."); int index = 0; auto cast_id = (VersionButtonID) id; @@ -83,12 +91,14 @@ void ModFilterWidget::onVersionFilterChanged(int id) case(VersionButtonID::Strict): m_filter->versions.push_front(mcVersion()); break; - case(VersionButtonID::Major): + case(VersionButtonID::Major): { + auto versionSplit = mcVersionStr().split("."); for(auto i = Version(QString("%1.%2").arg(versionSplit[0], versionSplit[1])); i <= mcVersion(); index++){ m_filter->versions.push_front(i); i = Version(QString("%1.%2.%3").arg(versionSplit[0], versionSplit[1], QString("%1").arg(index))); } break; + } case(VersionButtonID::All): // Empty list to avoid enumerating all versions :P break;