NOISSUE bring back instance creation

This commit is contained in:
Petr Mrázek 2017-03-20 00:44:49 +01:00
parent f557c13679
commit 77f27a628f
2 changed files with 35 additions and 7 deletions

View File

@ -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,14 +221,17 @@ 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);
}
}
}
void NewInstanceDialog::on_iconButton_clicked()

View File

@ -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;