summaryrefslogtreecommitdiffstats
path: root/application/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-20 00:44:49 +0100
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commit77f27a628f33a591f7562ca05c206ac604212443 (patch)
tree08775121922e204c9596efd350d6078b13689e3a /application/dialogs
parentf557c1367994a61935fa0e8d0b1b67688d2692d0 (diff)
downloadMultiMC-77f27a628f33a591f7562ca05c206ac604212443.tar
MultiMC-77f27a628f33a591f7562ca05c206ac604212443.tar.gz
MultiMC-77f27a628f33a591f7562ca05c206ac604212443.tar.lz
MultiMC-77f27a628f33a591f7562ca05c206ac604212443.tar.xz
MultiMC-77f27a628f33a591f7562ca05c206ac604212443.zip
NOISSUE bring back instance creation
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;