summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp120
-rw-r--r--gui/dialogs/OneSixModEditDialog.ui9
2 files changed, 44 insertions, 85 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp
index 78585a05..2d459001 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)
{
@@ -155,34 +145,62 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
{
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
- else
- {
- reloadInstanceVersion();
- }
}
}
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 +208,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);
@@ -200,50 +217,14 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
- ForgeVersionPtr forgeVersion =
- std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion());
- if (!forgeVersion)
- return;
- auto entry = MMC->metacache()->resolveEntry("minecraftforge", forgeVersion->filename);
- if (entry->stale)
- {
- NetJob *fjob = new NetJob("Forge download");
- fjob->addNetAction(CacheDownload::make(forgeVersion->installer_url, entry));
- ProgressDialog dlg(this);
- dlg.exec(fjob);
- if (dlg.result() == QDialog::Accepted)
- {
- // install
- QString forgePath = entry->getFullPath();
- ForgeInstaller forge(forgePath, forgeVersion->universal_url);
- if (!forge.add(m_inst))
- {
- QLOG_ERROR() << "Failure installing forge";
- }
- }
- else
- {
- // failed to download forge :/
- }
- }
- else
- {
- // install
- QString forgePath = entry->getFullPath();
- ForgeInstaller forge(forgePath, forgeVersion->universal_url);
- if (!forge.add(m_inst))
- {
- QLOG_ERROR() << "Failure installing forge";
- }
- }
+ ProgressDialog dialog(this);
+ dialog.exec(ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
}
- reloadInstanceVersion();
}
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 +232,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"),
@@ -261,21 +242,8 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
m_inst->currentVersionId());
if (vselect.exec() && vselect.selectedVersion())
{
- LiteLoaderVersionPtr liteloaderVersion =
- std::dynamic_pointer_cast<LiteLoaderVersion>(vselect.selectedVersion());
- if (!liteloaderVersion)
- return;
- LiteLoaderInstaller liteloader(liteloaderVersion);
- if (!liteloader.add(m_inst))
- {
- QMessageBox::critical(this, tr("LiteLoader"),
- tr("For reasons unknown, the LiteLoader installation failed. "
- "Check your MultiMC log files for details."));
- }
- else
- {
- reloadInstanceVersion();
- }
+ ProgressDialog dialog(this);
+ dialog.exec(LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
}
}
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>