diff --git a/launcher/InstanceCreationTask.cpp b/launcher/InstanceCreationTask.cpp
index 4c37bd7f..24bc5f46 100644
--- a/launcher/InstanceCreationTask.cpp
+++ b/launcher/InstanceCreationTask.cpp
@@ -9,6 +9,15 @@
InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version)
{
m_version = version;
+ m_usingLoader = false;
+}
+
+InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loaderVersion)
+{
+ m_version = version;
+ m_usingLoader = true;
+ m_loader = loader;
+ m_loaderVersion = loaderVersion;
}
void InstanceCreationTask::executeTask()
@@ -21,6 +30,8 @@ void InstanceCreationTask::executeTask()
auto components = inst.getPackProfile();
components->buildingFromScratch();
components->setComponentVersion("net.minecraft", m_version->descriptor(), true);
+ if(m_usingLoader)
+ components->setComponentVersion(m_loader, m_loaderVersion->descriptor(), true);
inst.setName(m_instName);
inst.setIconKey(m_instIcon);
instanceSettings->resumeSave();
diff --git a/launcher/InstanceCreationTask.h b/launcher/InstanceCreationTask.h
index 54997116..23367c3f 100644
--- a/launcher/InstanceCreationTask.h
+++ b/launcher/InstanceCreationTask.h
@@ -12,6 +12,7 @@ class InstanceCreationTask : public InstanceTask
Q_OBJECT
public:
explicit InstanceCreationTask(BaseVersionPtr version);
+ explicit InstanceCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loaderVersion);
protected:
//! Entry point for tasks.
@@ -19,4 +20,7 @@ protected:
private: /* data */
BaseVersionPtr m_version;
+ bool m_usingLoader;
+ QString m_loader;
+ BaseVersionPtr m_loaderVersion;
};
diff --git a/launcher/ui/pages/modplatform/VanillaPage.cpp b/launcher/ui/pages/modplatform/VanillaPage.cpp
index c691128f..207d0130 100644
--- a/launcher/ui/pages/modplatform/VanillaPage.cpp
+++ b/launcher/ui/pages/modplatform/VanillaPage.cpp
@@ -44,6 +44,7 @@
#include "ui/dialogs/NewInstanceDialog.h"
#include "Filter.h"
#include "InstanceCreationTask.h"
+#include "Version.h"
VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
: QWidget(parent), dialog(dialog), ui(new Ui::VanillaPage)
@@ -59,6 +60,15 @@ VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
connect(ui->releaseFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
connect(ui->experimentsFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
connect(ui->refreshBtn, &QPushButton::clicked, this, &VanillaPage::refresh);
+
+ connect(ui->loaderVersionList, &VersionSelectWidget::selectedVersionChanged, this, &VanillaPage::setSelectedLoaderVersion);
+ connect(ui->noneFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
+ connect(ui->forgeFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
+ connect(ui->fabricFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
+ connect(ui->quiltFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
+ connect(ui->liteLoaderFilter, &QRadioButton::toggled, this, &VanillaPage::loaderFilterChanged);
+ connect(ui->loaderRefreshBtn, &QPushButton::clicked, this, &VanillaPage::loaderRefresh);
+
}
void VanillaPage::openedImpl()
@@ -80,6 +90,13 @@ void VanillaPage::refresh()
ui->versionList->loadList();
}
+void VanillaPage::loaderRefresh()
+{
+ if(ui->noneFilter->isChecked())
+ return;
+ ui->loaderVersionList->loadList();
+}
+
void VanillaPage::filterChanged()
{
QStringList out;
@@ -99,6 +116,52 @@ void VanillaPage::filterChanged()
ui->versionList->setFilter(BaseVersionList::TypeRole, new RegexpFilter(regexp, false));
}
+void VanillaPage::loaderFilterChanged()
+{
+ auto minecraftVersion = m_selectedVersion->descriptor();
+ if(ui->noneFilter->isChecked())
+ {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
+ ui->loaderVersionList->setEmptyString(tr("No mod loader is selected."));
+ ui->loaderVersionList->setEmptyMode(VersionListView::String);
+ return;
+ }
+ else if(ui->forgeFilter->isChecked())
+ {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
+ m_selectedLoader = "net.minecraftforge";
+ }
+ else if(ui->fabricFilter->isChecked())
+ {
+ // FIXME: dirty hack because the launcher is unaware of Fabric's dependencies
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ m_selectedLoader = "net.fabricmc.fabric-loader";
+ }
+ else if(ui->quiltFilter->isChecked())
+ {
+ // FIXME: dirty hack because the launcher is unaware of Quilt's dependencies (same as Fabric)
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ m_selectedLoader = "org.quiltmc.quilt-loader";
+ }
+ else if(ui->liteLoaderFilter->isChecked())
+ {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
+ m_selectedLoader = "com.mumfrey.liteloader";
+ }
+
+ auto vlist = APPLICATION->metadataIndex()->get(m_selectedLoader);
+ ui->loaderVersionList->initialize(vlist.get());
+ ui->loaderVersionList->selectRecommended();
+ suggestCurrent();
+ ui->loaderVersionList->setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
+}
+
VanillaPage::~VanillaPage()
{
delete ui;
@@ -119,6 +182,16 @@ BaseVersionPtr VanillaPage::selectedVersion() const
return m_selectedVersion;
}
+BaseVersionPtr VanillaPage::selectedLoaderVersion() const
+{
+ return m_selectedLoaderVersion;
+}
+
+QString VanillaPage::selectedLoader() const
+{
+ return m_selectedLoader;
+}
+
void VanillaPage::suggestCurrent()
{
if (!isOpened)
@@ -132,7 +205,15 @@ void VanillaPage::suggestCurrent()
return;
}
- dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion));
+ // List is empty if either no mod loader is selected, or no versions are available
+ if(!ui->loaderVersionList->hasVersions())
+ dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion));
+ else
+ {
+ dialog->setSuggestedPack(m_selectedVersion->descriptor(),
+ new InstanceCreationTask(m_selectedVersion, m_selectedLoader,
+ m_selectedLoaderVersion));
+ }
dialog->setSuggestedIcon("default");
}
@@ -140,4 +221,11 @@ void VanillaPage::setSelectedVersion(BaseVersionPtr version)
{
m_selectedVersion = version;
suggestCurrent();
+ loaderFilterChanged();
+}
+
+void VanillaPage::setSelectedLoaderVersion(BaseVersionPtr version)
+{
+ m_selectedLoaderVersion = version;
+ suggestCurrent();
}
diff --git a/launcher/ui/pages/modplatform/VanillaPage.h b/launcher/ui/pages/modplatform/VanillaPage.h
index 4e7479df..7193597d 100644
--- a/launcher/ui/pages/modplatform/VanillaPage.h
+++ b/launcher/ui/pages/modplatform/VanillaPage.h
@@ -77,15 +77,20 @@ public:
void openedImpl() override;
BaseVersionPtr selectedVersion() const;
+ BaseVersionPtr selectedLoaderVersion() const;
+ QString selectedLoader() const;
public slots:
void setSelectedVersion(BaseVersionPtr version);
+ void setSelectedLoaderVersion(BaseVersionPtr version);
private slots:
void filterChanged();
+ void loaderFilterChanged();
private:
void refresh();
+ void loaderRefresh();
void suggestCurrent();
private:
@@ -94,4 +99,6 @@ private:
Ui::VanillaPage *ui = nullptr;
bool m_versionSetByUser = false;
BaseVersionPtr m_selectedVersion;
+ BaseVersionPtr m_selectedLoaderVersion;
+ QString m_selectedLoader;
};
diff --git a/launcher/ui/pages/modplatform/VanillaPage.ui b/launcher/ui/pages/modplatform/VanillaPage.ui
index 870ff161..43110927 100644
--- a/launcher/ui/pages/modplatform/VanillaPage.ui
+++ b/launcher/ui/pages/modplatform/VanillaPage.ui
@@ -33,113 +33,231 @@
- -
-
-
-
-
-
- Filter
-
-
- Qt::AlignCenter
-
-
-
- -
-
-
- Releases
-
-
- true
-
-
- true
-
-
-
- -
-
-
- Snapshots
-
-
- true
-
-
-
- -
-
-
- Old Snapshots
-
-
- true
-
-
-
- -
-
-
- Betas
-
-
- true
-
-
-
- -
-
-
- Alphas
-
-
- true
-
-
-
- -
-
-
- Experiments
-
-
- true
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
-
- Refresh
-
-
-
-
-
- -
-
+
-
+
-
+
0
0
+
+ Qt::Horizontal
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
-
+
+
+ Filter
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Releases
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+ Snapshots
+
+
+ true
+
+
+
+ -
+
+
+ Old Snapshots
+
+
+ true
+
+
+
+ -
+
+
+ Betas
+
+
+ true
+
+
+
+ -
+
+
+ Alphas
+
+
+ true
+
+
+
+ -
+
+
+ Experiments
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Refresh
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
-
+
+
+ Mod Loader
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ None
+
+
+ true
+
+
+ loaderBtnGroup
+
+
+
+ -
+
+
+ Forge
+
+
+ loaderBtnGroup
+
+
+
+ -
+
+
+ Fabric
+
+
+ loaderBtnGroup
+
+
+
+ -
+
+
+ Quilt
+
+
+ loaderBtnGroup
+
+
+
+ -
+
+
+ LiteLoader
+
+
+ loaderBtnGroup
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
+ Refresh
+
+
+
+
+
+
+
@@ -166,4 +284,7 @@
+
+
+
diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp
index 1209f118..cc4fc6a2 100644
--- a/launcher/ui/widgets/VersionSelectWidget.cpp
+++ b/launcher/ui/widgets/VersionSelectWidget.cpp
@@ -4,7 +4,6 @@
#include
#include
-#include "VersionListView.h"
#include "VersionProxyModel.h"
#include "ui/dialogs/CustomMessageBox.h"
@@ -57,6 +56,11 @@ void VersionSelectWidget::setEmptyErrorString(QString emptyErrorString)
listView->setEmptyErrorString(emptyErrorString);
}
+void VersionSelectWidget::setEmptyMode(VersionListView::EmptyMode mode)
+{
+ listView->setEmptyMode(mode);
+}
+
VersionSelectWidget::~VersionSelectWidget()
{
}
diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h
index 0a649408..f56daa8a 100644
--- a/launcher/ui/widgets/VersionSelectWidget.h
+++ b/launcher/ui/widgets/VersionSelectWidget.h
@@ -18,6 +18,7 @@
#include
#include
#include "BaseVersionList.h"
+#include "VersionListView.h"
class VersionProxyModel;
class VersionListView;
@@ -49,6 +50,7 @@ public:
void setFilter(BaseVersionList::ModelRoles role, Filter *filter);
void setEmptyString(QString emptyString);
void setEmptyErrorString(QString emptyErrorString);
+ void setEmptyMode(VersionListView::EmptyMode mode);
void setResizeOn(int column);
signals: