diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/mainwindow.cpp | 8 | ||||
-rw-r--r-- | gui/newinstancedialog.cpp | 81 | ||||
-rw-r--r-- | gui/newinstancedialog.h | 5 | ||||
-rw-r--r-- | gui/newinstancedialog.ui | 36 |
4 files changed, 33 insertions, 97 deletions
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7f05c745..6f99c18b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -155,8 +155,8 @@ void MainWindow::on_actionAddInstance_triggered() QString instDir = PathCombine(globalSettings->get("InstanceDir").toString(), instDirName); - InstanceLoader::InstTypeError error = InstanceLoader::get(). - createInstance(newInstance, newInstDlg->selectedType(), instDir); + InstanceLoader::InstLoaderError error = InstanceLoader::get(). + createInstance(newInstance, instDir); if (error == InstanceLoader::NoError) { @@ -170,10 +170,6 @@ void MainWindow::on_actionAddInstance_triggered() switch (error) { - case InstanceLoader::TypeNotRegistered: - errorMsg += "Instance type not found."; - break; - case InstanceLoader::InstExists: errorMsg += "An instance with the given directory name already exists."; break; diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp index 3cbfabb0..2034664d 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/newinstancedialog.cpp @@ -30,6 +30,8 @@ #include <QLayout> #include <QPushButton> +#include <minecraftversionlist.h> + NewInstanceDialog::NewInstanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::NewInstanceDialog) @@ -41,48 +43,25 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) : resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); - loadTypeList(); -} - -NewInstanceDialog::~NewInstanceDialog() -{ - delete ui; -} - -void NewInstanceDialog::loadTypeList() -{ - InstTypeList typeList = InstanceLoader::get().typeList(); - - for (int i = 0; i < typeList.length(); i++) + if (!MinecraftVersionList::getMainList().isLoaded()) { - ui->instTypeComboBox->addItem(typeList.at(i)->displayName(), typeList.at(i)->typeID()); + TaskDialog *taskDlg = new TaskDialog(this); + Task *loadTask = MinecraftVersionList::getMainList().getLoadTask(); + loadTask->setParent(taskDlg); + taskDlg->exec(loadTask); } - - updateSelectedType(); + setSelectedVersion(MinecraftVersionList::getMainList().getLatestStable()); } -void NewInstanceDialog::updateSelectedType() +NewInstanceDialog::~NewInstanceDialog() { - QString typeID = ui->instTypeComboBox->itemData(ui->instTypeComboBox->currentIndex()).toString(); - - const InstanceTypeInterface *type = InstanceLoader::get().findType(typeID); - m_selectedType = type; - - updateDialogState(); - - if (m_selectedType) - { - if (!m_selectedType->versionList()->isLoaded()) - loadVersionList(); - - setSelectedVersion(m_selectedType->versionList()->getLatestStable()); - } + delete ui; } void NewInstanceDialog::updateDialogState() { - ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_selectedType && m_selectedVersion); - ui->btnChangeVersion->setEnabled(m_selectedType && m_selectedVersion); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled( + !instName().isEmpty() && m_selectedVersion); } void NewInstanceDialog::setSelectedVersion(const InstVersion *version) @@ -101,19 +80,6 @@ void NewInstanceDialog::setSelectedVersion(const InstVersion *version) updateDialogState(); } -void NewInstanceDialog::loadVersionList() -{ - if (!m_selectedType) - return; - - TaskDialog *taskDlg = new TaskDialog(this); - Task *loadTask = m_selectedType->versionList()->getLoadTask(); - loadTask->setParent(taskDlg); - taskDlg->exec(loadTask); - - setSelectedVersion(m_selectedType->versionList()->getLatestStable()); -} - QString NewInstanceDialog::instName() const { return ui->instNameTextBox->text(); @@ -125,11 +91,6 @@ QString NewInstanceDialog::iconKey() const return "default"; } -const InstanceTypeInterface *NewInstanceDialog::selectedType() const -{ - return m_selectedType; -} - const InstVersion *NewInstanceDialog::selectedVersion() const { return m_selectedVersion; @@ -137,19 +98,11 @@ const InstVersion *NewInstanceDialog::selectedVersion() const void NewInstanceDialog::on_btnChangeVersion_clicked() { - if (m_selectedType) + VersionSelectDialog *vselect = new VersionSelectDialog(&MinecraftVersionList::getMainList(), this); + if (vselect->exec()) { - VersionSelectDialog *vselect = new VersionSelectDialog(m_selectedType->versionList(), this); - if (vselect->exec()) - { - const InstVersion *version = vselect->selectedVersion(); - if (version) - setSelectedVersion(version); - } + const InstVersion *version = vselect->selectedVersion(); + if (version) + setSelectedVersion(version); } } - -void NewInstanceDialog::on_instTypeComboBox_activated(int index) -{ - updateSelectedType(); -} diff --git a/gui/newinstancedialog.h b/gui/newinstancedialog.h index 93d94575..ea730b3c 100644 --- a/gui/newinstancedialog.h +++ b/gui/newinstancedialog.h @@ -33,8 +33,6 @@ public: explicit NewInstanceDialog(QWidget *parent = 0); ~NewInstanceDialog(); - void loadTypeList(); - void updateSelectedType(); void updateDialogState(); void setSelectedVersion(const InstVersion *version); @@ -43,14 +41,11 @@ public: QString instName() const; QString iconKey() const; - const InstanceTypeInterface *selectedType() const; const InstVersion *selectedVersion() const; private slots: void on_btnChangeVersion_clicked(); - void on_instTypeComboBox_activated(int index); - private: Ui::NewInstanceDialog *ui; diff --git a/gui/newinstancedialog.ui b/gui/newinstancedialog.ui index 6f96f167..540176d5 100644 --- a/gui/newinstancedialog.ui +++ b/gui/newinstancedialog.ui @@ -10,7 +10,7 @@ <x>0</x> <y>0</y> <width>220</width> - <height>230</height> + <height>234</height> </rect> </property> <property name="windowTitle"> @@ -76,27 +76,6 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="typeLabel"> - <property name="text"> - <string>Type:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="instTypeComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - </layout> - </item> - <item> <widget class="Line" name="line"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -129,6 +108,19 @@ </layout> </item> <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> <widget class="Line" name="line_2"> <property name="orientation"> <enum>Qt::Horizontal</enum> |