Removed old plugin system and implemented some version list stuff.
This commit is contained in:
@ -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;
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <minecraftversionlist.h>
|
||||
|
||||
NewInstanceDialog::NewInstanceDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewInstanceDialog)
|
||||
@ -41,7 +43,14 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) :
|
||||
resize(minimumSizeHint());
|
||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
loadTypeList();
|
||||
if (!MinecraftVersionList::getMainList().isLoaded())
|
||||
{
|
||||
TaskDialog *taskDlg = new TaskDialog(this);
|
||||
Task *loadTask = MinecraftVersionList::getMainList().getLoadTask();
|
||||
loadTask->setParent(taskDlg);
|
||||
taskDlg->exec(loadTask);
|
||||
}
|
||||
setSelectedVersion(MinecraftVersionList::getMainList().getLatestStable());
|
||||
}
|
||||
|
||||
NewInstanceDialog::~NewInstanceDialog()
|
||||
@ -49,40 +58,10 @@ NewInstanceDialog::~NewInstanceDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NewInstanceDialog::loadTypeList()
|
||||
{
|
||||
InstTypeList typeList = InstanceLoader::get().typeList();
|
||||
|
||||
for (int i = 0; i < typeList.length(); i++)
|
||||
{
|
||||
ui->instTypeComboBox->addItem(typeList.at(i)->displayName(), typeList.at(i)->typeID());
|
||||
}
|
||||
|
||||
updateSelectedType();
|
||||
}
|
||||
|
||||
void NewInstanceDialog::updateSelectedType()
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>220</width>
|
||||
<height>230</height>
|
||||
<height>234</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -75,27 +75,6 @@
|
||||
</property>
|
||||
</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">
|
||||
@ -128,6 +107,19 @@
|
||||
</item>
|
||||
</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">
|
||||
|
Reference in New Issue
Block a user