summaryrefslogtreecommitdiffstats
path: root/application/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'application/dialogs')
-rw-r--r--application/dialogs/NewInstanceDialog.cpp38
-rw-r--r--application/dialogs/NewInstanceDialog.h4
2 files changed, 35 insertions, 7 deletions
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp
index 2e8e3ff7..8180aa27 100644
--- a/application/dialogs/NewInstanceDialog.cpp
+++ b/application/dialogs/NewInstanceDialog.cpp
@@ -31,6 +31,9 @@
#include <QFileDialog>
#include <QValidator>
+#include <meta/Index.h>
+#include <meta/VersionList.h>
+
class UrlValidator : public QValidator
{
public:
@@ -61,12 +64,25 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare
resize(minimumSizeHint());
layout()->setSizeConstraint(QLayout::SetFixedSize);
- // FIXME: bring this back...
- auto vlist = ENV.getVersionList("net.minecraft");
- if(vlist)
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ if(vlist->isLoaded())
{
setSelectedVersion(vlist->getRecommended());
}
+ else
+ {
+ vlist->load();
+ auto task = vlist->getLoadTask();
+ if(vlist->isLoaded())
+ {
+ setSelectedVersion(vlist->getRecommended());
+ }
+ if(task)
+ {
+ connect(task.get(), &Task::succeeded, this, &NewInstanceDialog::versionListUpdated);
+ }
+ }
+
InstIconKey = "default";
ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey));
@@ -99,6 +115,15 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare
updateDialogState();
}
+void NewInstanceDialog::versionListUpdated()
+{
+ if(!m_versionSetByUser)
+ {
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ setSelectedVersion(vlist->getRecommended());
+ }
+}
+
NewInstanceDialog::~NewInstanceDialog()
{
delete ui;
@@ -138,7 +163,7 @@ void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version)
if (m_selectedVersion)
{
- ui->versionTextBox->setText(version->name());
+ ui->versionTextBox->setText(version->descriptor());
}
else
{
@@ -196,13 +221,16 @@ BaseVersionPtr NewInstanceDialog::selectedVersion() const
void NewInstanceDialog::on_btnChangeVersion_clicked()
{
- VersionSelectDialog vselect(ENV.getVersionList("net.minecraft").get(), tr("Change Minecraft version"), this);
+ VersionSelectDialog vselect(ENV.metadataIndex()->get("net.minecraft").get(), tr("Change Minecraft version"), this);
vselect.exec();
if (vselect.result() == QDialog::Accepted)
{
BaseVersionPtr version = vselect.selectedVersion();
if (version)
+ {
+ m_versionSetByUser = true;
setSelectedVersion(version);
+ }
}
}
diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h
index 1f7fadfb..1741dab8 100644
--- a/application/dialogs/NewInstanceDialog.h
+++ b/application/dialogs/NewInstanceDialog.h
@@ -36,8 +36,6 @@ public:
void setSelectedVersion(BaseVersionPtr version);
- void loadVersionList();
-
QString instName() const;
QString instGroup() const;
QString iconKey() const;
@@ -50,10 +48,12 @@ slots:
void on_iconButton_clicked();
void on_modpackBtn_clicked();
void on_instNameTextBox_textChanged(const QString &arg1);
+ void versionListUpdated();
private:
Ui::NewInstanceDialog *ui;
+ bool m_versionSetByUser = false;
BaseVersionPtr m_selectedVersion;
QString InstIconKey;
QString originalPlaceholderText;