Better parent version filtering; handle old fabric :P
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
0e5c377680
commit
64c591b234
@ -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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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<PackProfile> 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<PackProfile> profile, c
|
||||
QList<BasePage*> 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)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -238,14 +238,19 @@ BaseVersion::Ptr VersionSelectWidget::selectedVersion() const
|
||||
return variant.value<BaseVersion::Ptr>();
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user