summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp60
-rw-r--r--gui/dialogs/OneSixModEditDialog.ui9
2 files changed, 40 insertions, 29 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp
index 78585a05..b5a0d5aa 100644
--- a/gui/dialogs/OneSixModEditDialog.cpp
+++ b/gui/dialogs/OneSixModEditDialog.cpp
@@ -42,16 +42,6 @@
#include "logic/LiteLoaderInstaller.h"
#include "logic/OneSixVersionBuilder.h"
-template <typename A, typename B> QMap<A, B> invert(const QMap<B, A> &in)
-{
- QMap<A, B> out;
- for (auto it = in.begin(); it != in.end(); ++it)
- {
- out.insert(it.value(), it.key());
- }
- return out;
-}
-
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
{
@@ -164,25 +154,57 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
{
- // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
+ try
+ {
+ m_version->resetOrder();
+ }
+ catch (MMCError &e)
+ {
+ QMessageBox::critical(this, tr("Error"), e.cause());
+ }
}
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
{
- // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
+ if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
+ {
+ return;
+ }
+ try
+ {
+ const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
+ const int newRow = 0;m_version->move(row, VersionFinal::MoveUp);
+ //ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect);
+ }
+ catch (MMCError &e)
+ {
+ QMessageBox::critical(this, tr("Error"), e.cause());
+ }
}
void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
{
- // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
+ if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
+ {
+ return;
+ }
+ try
+ {
+ const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
+ const int newRow = 0;m_version->move(row, VersionFinal::MoveDown);
+ //ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect);
+ }
+ catch (MMCError &e)
+ {
+ QMessageBox::critical(this, tr("Error"), e.cause());
+ }
}
void OneSixModEditDialog::on_forgeBtn_clicked()
{
// FIXME: use actual model, not reloading. Move logic to model.
- // FIXME: model::isCustom();
- if (QDir(m_inst->instanceRoot()).exists("custom.json"))
+ if (m_version->isCustom())
{
if (QMessageBox::question(this, tr("Revert?"),
tr("This action will remove your custom.json. Continue?")) !=
@@ -190,8 +212,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
{
return;
}
- // FIXME: model::revertToBase();
- QDir(m_inst->instanceRoot()).remove("custom.json");
+ m_version->revertToBase();
reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
@@ -242,8 +263,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
void OneSixModEditDialog::on_liteloaderBtn_clicked()
{
- // FIXME: model...
- if (QDir(m_inst->instanceRoot()).exists("custom.json"))
+ if (m_version->isCustom())
{
if (QMessageBox::question(this, tr("Revert?"),
tr("This action will remove your custom.json. Continue?")) !=
@@ -251,7 +271,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
{
return;
}
- QDir(m_inst->instanceRoot()).remove("custom.json");
+ m_version->revertToBase();
reloadInstanceVersion();
}
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui
index b606dcd2..2c9f70bb 100644
--- a/gui/dialogs/OneSixModEditDialog.ui
+++ b/gui/dialogs/OneSixModEditDialog.ui
@@ -99,9 +99,6 @@
</item>
<item>
<widget class="QPushButton" name="moveLibraryUpBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
@@ -112,9 +109,6 @@
</item>
<item>
<widget class="QPushButton" name="moveLibraryDownBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
@@ -125,9 +119,6 @@
</item>
<item>
<widget class="QPushButton" name="resetLibraryOrderBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>