summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/LegacyModEditDialog.cpp1
-rw-r--r--gui/OneSixModEditDialog.cpp85
-rw-r--r--gui/OneSixModEditDialog.h5
-rw-r--r--gui/OneSixModEditDialog.ui9
4 files changed, 92 insertions, 8 deletions
diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp
index ac7f7f25..1a1198b1 100644
--- a/gui/LegacyModEditDialog.cpp
+++ b/gui/LegacyModEditDialog.cpp
@@ -230,7 +230,6 @@ void LegacyModEditDialog::on_addForgeBtn_clicked()
m_jarmods->installMod(QFileInfo(entry->getFullPath()));
m_jarmods->startWatching();
}
- //m_selectedInstance->setIntendedVersionId(->descriptor());
}
}
void LegacyModEditDialog::on_addJarBtn_clicked()
diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp
index fad9d2e2..7cbb9cbd 100644
--- a/gui/OneSixModEditDialog.cpp
+++ b/gui/OneSixModEditDialog.cpp
@@ -21,9 +21,11 @@
#include "logic/EnabledItemFilter.h"
#include "logic/lists/ForgeVersionList.h"
#include "gui/versionselectdialog.h"
+#include "ProgressDialog.h"
#include <pathutils.h>
#include <QFileDialog>
+#include <QMessageBox>
#include <QDebug>
#include <QEvent>
#include <QKeyEvent>
@@ -38,11 +40,13 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance * inst, QWidget *parent)
{
m_version = m_inst->getFullVersion();
- auto filter = new EnabledItemFilter(this);
- filter->setActive(true);
- filter->setSourceModel(m_version.data());
- ui->libraryTreeView->setModel(filter);
+ main_model = new EnabledItemFilter(this);
+ main_model->setActive(true);
+ main_model->setSourceModel(m_version.data());
+ ui->libraryTreeView->setModel(main_model);
ui->libraryTreeView->installEventFilter( this );
+ ui->mainClassEdit->setText(m_version->mainClass);
+ updateButtons();
}
// Loader mods
{
@@ -69,17 +73,86 @@ OneSixModEditDialog::~OneSixModEditDialog()
delete ui;
}
+void OneSixModEditDialog::updateButtons()
+{
+ bool customVersion = m_inst->versionIsCustom();
+ ui->customizeBtn->setEnabled(!customVersion);
+ ui->revertBtn->setEnabled(customVersion);
+}
+
+
+void OneSixModEditDialog::on_customizeBtn_clicked()
+{
+ if(m_inst->customizeVersion())
+ {
+ m_version = m_inst->getFullVersion();
+ main_model->setSourceModel(m_version.data());
+ updateButtons();
+ }
+}
+
+void OneSixModEditDialog::on_revertBtn_clicked()
+{
+ auto reply = QMessageBox::question(this, tr("Revert?"), tr("Do you want to revert the version of this instance to its original configuration?"),QMessageBox::Yes|QMessageBox::No);
+ if (reply == QMessageBox::Yes)
+ {
+ if(m_inst->revertCustomVersion())
+ {
+ m_version = m_inst->getFullVersion();
+ main_model->setSourceModel(m_version.data());
+ updateButtons();
+ }
+ }
+}
+
+
void OneSixModEditDialog::on_forgeBtn_clicked()
{
VersionSelectDialog vselect(MMC->forgelist(), this);
vselect.setFilter(1, m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
- //m_selectedInstance->setIntendedVersionId(vselect.selectedVersion()->descriptor());
+ if(m_inst->versionIsCustom())
+ {
+ auto reply = QMessageBox::question(this, tr("Revert?"), tr("This will revert any changes you did to the version up to this point. Is that OK?"),QMessageBox::Yes|QMessageBox::No);
+ if (reply == QMessageBox::Yes)
+ {
+ m_inst->revertCustomVersion();
+ m_inst->customizeVersion();
+ {
+ m_version = m_inst->getFullVersion();
+ main_model->setSourceModel(m_version.data());
+ updateButtons();
+ }
+ }
+ else return;
+ }
+ ForgeVersionPtr forge = vselect.selectedVersion().dynamicCast<ForgeVersion>();
+ if(!forge)
+ return;
+ auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
+ if(entry->stale)
+ {
+ DownloadJob * fjob = new DownloadJob("Forge download");
+ fjob->add(forge->universal_url, entry);
+ ProgressDialog dlg(this);
+ dlg.exec(fjob);
+ if(dlg.result() == QDialog::Accepted)
+ {
+ // install
+ }
+ else
+ {
+ // failed to download forge :/
+ }
+ }
+ else
+ {
+ // install
+ }
}
}
-
bool OneSixModEditDialog::loaderListFilter ( QKeyEvent* keyEvent )
{
switch(keyEvent->key())
diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h
index d14c842c..714c911a 100644
--- a/gui/OneSixModEditDialog.h
+++ b/gui/OneSixModEditDialog.h
@@ -18,6 +18,7 @@
#include <logic/OneSixInstance.h>
+class EnabledItemFilter;
namespace Ui {
class OneSixModEditDialog;
}
@@ -41,6 +42,9 @@ private slots:
// Questionable: SettingsDialog doesn't need this for some reason?
void on_buttonBox_rejected();
void on_forgeBtn_clicked();
+ void on_customizeBtn_clicked();
+ void on_revertBtn_clicked();
+ void updateButtons();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool loaderListFilter( QKeyEvent* ev );
@@ -50,5 +54,6 @@ private:
QSharedPointer<OneSixVersion> m_version;
QSharedPointer<ModList> m_mods;
QSharedPointer<ModList> m_resourcepacks;
+ EnabledItemFilter * main_model;
OneSixInstance * m_inst;
};
diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui
index aadaf3ae..527899ca 100644
--- a/gui/OneSixModEditDialog.ui
+++ b/gui/OneSixModEditDialog.ui
@@ -55,7 +55,11 @@
</widget>
</item>
<item>
- <widget class="QLineEdit" name="mainClassEdit"/>
+ <widget class="QLineEdit" name="mainClassEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
</item>
</layout>
</item>
@@ -85,6 +89,9 @@
</item>
<item>
<widget class="QPushButton" name="revertBtn">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="toolTip">
<string>Revert to original base version</string>
</property>