summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/pages/VersionPage.cpp172
-rw-r--r--application/pages/VersionPage.h29
-rw-r--r--application/pages/VersionPage.ui98
3 files changed, 234 insertions, 65 deletions
diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp
index ab4aecf6..bb310eea 100644
--- a/application/pages/VersionPage.cpp
+++ b/application/pages/VersionPage.cpp
@@ -67,16 +67,14 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
m_version = m_inst->getMinecraftProfile();
if (m_version)
{
- ui->libraryTreeView->setModel(m_version.get());
- ui->libraryTreeView->installEventFilter(this);
- ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
- connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
+ ui->packageView->setModel(m_version.get());
+ ui->packageView->installEventFilter(this);
+ ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
+ connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &VersionPage::versionCurrent);
updateVersionControls();
// select first item.
- auto index = ui->libraryTreeView->model()->index(0,0);
- if(index.isValid())
- ui->libraryTreeView->setCurrentIndex(index);
+ preselect(0);
}
else
{
@@ -95,14 +93,15 @@ void VersionPage::updateVersionControls()
{
ui->forgeBtn->setEnabled(true);
ui->liteloaderBtn->setEnabled(true);
+ updateButtons();
}
void VersionPage::disableVersionControls()
{
ui->forgeBtn->setEnabled(false);
ui->liteloaderBtn->setEnabled(false);
- ui->reloadLibrariesBtn->setEnabled(false);
- ui->removeLibraryBtn->setEnabled(false);
+ ui->reloadBtn->setEnabled(false);
+ updateButtons();
}
bool VersionPage::reloadMinecraftProfile()
@@ -126,21 +125,22 @@ bool VersionPage::reloadMinecraftProfile()
}
}
-void VersionPage::on_reloadLibrariesBtn_clicked()
+void VersionPage::on_reloadBtn_clicked()
{
reloadMinecraftProfile();
}
-void VersionPage::on_removeLibraryBtn_clicked()
+void VersionPage::on_removeBtn_clicked()
{
- if (ui->libraryTreeView->currentIndex().isValid())
+ if (ui->packageView->currentIndex().isValid())
{
// FIXME: use actual model, not reloading.
- if (!m_version->remove(ui->libraryTreeView->currentIndex().row()))
+ if (!m_version->remove(ui->packageView->currentIndex().row()))
{
QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
}
+ updateButtons();
}
void VersionPage::on_jarmodBtn_clicked()
@@ -150,9 +150,10 @@ void VersionPage::on_jarmodBtn_clicked()
{
m_version->installJarMods(list);
}
+ updateButtons();
}
-void VersionPage::on_resetLibraryOrderBtn_clicked()
+void VersionPage::on_resetOrderBtn_clicked()
{
try
{
@@ -162,43 +163,36 @@ void VersionPage::on_resetLibraryOrderBtn_clicked()
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
+ updateButtons();
}
-void VersionPage::on_moveLibraryUpBtn_clicked()
+void VersionPage::on_moveUpBtn_clicked()
{
- if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
- {
- return;
- }
try
{
- const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
- m_version->move(row, MinecraftProfile::MoveUp);
+ m_version->move(currentRow(), MinecraftProfile::MoveUp);
}
catch (MMCError &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
+ updateButtons();
}
-void VersionPage::on_moveLibraryDownBtn_clicked()
+void VersionPage::on_moveDownBtn_clicked()
{
- if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
- {
- return;
- }
try
{
- const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
- m_version->move(row, MinecraftProfile::MoveDown);
+ m_version->move(currentRow(), MinecraftProfile::MoveDown);
}
catch (MMCError &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
+ updateButtons();
}
-void VersionPage::on_changeMCVersionBtn_clicked()
+void VersionPage::on_changeVersionBtn_clicked()
{
VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"),
this);
@@ -239,6 +233,7 @@ void VersionPage::on_changeMCVersionBtn_clicked()
ProgressDialog tDialog(this);
connect(updateTask.get(), SIGNAL(failed(QString)), SLOT(onGameUpdateError(QString)));
tDialog.exec(updateTask.get());
+ updateButtons();
}
void VersionPage::on_forgeBtn_clicked()
@@ -253,6 +248,7 @@ void VersionPage::on_forgeBtn_clicked()
ProgressDialog dialog(this);
dialog.exec(
ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
+ preselect(m_version->rowCount(QModelIndex())-1);
}
}
@@ -269,32 +265,59 @@ void VersionPage::on_liteloaderBtn_clicked()
ProgressDialog dialog(this);
dialog.exec(
LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
+ preselect(m_version->rowCount(QModelIndex())-1);
}
}
void VersionPage::versionCurrent(const QModelIndex &current, const QModelIndex &previous)
{
- if (!current.isValid())
+ currentIdx = current.row();
+ updateButtons(currentIdx);
+}
+
+void VersionPage::preselect(int row)
+{
+ if(row < 0)
{
- ui->removeLibraryBtn->setDisabled(true);
- ui->moveLibraryDownBtn->setDisabled(true);
- ui->moveLibraryUpBtn->setDisabled(true);
+ row = 0;
}
- else
+ if(row >= m_version->rowCount(QModelIndex()))
{
- bool enabled = m_version->canRemove(current.row());
- ui->removeLibraryBtn->setEnabled(enabled);
- ui->moveLibraryDownBtn->setEnabled(enabled);
- ui->moveLibraryUpBtn->setEnabled(enabled);
+ row = m_version->rowCount(QModelIndex()) - 1;
+ }
+ if(row < 0)
+ {
+ return;
}
- QString selectedId = m_version->versionFileId(current.row());
- if (selectedId == "net.minecraft")
+ auto model_index = m_version->index(row);
+ ui->packageView->selectionModel()->select(model_index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ updateButtons(row);
+}
+
+void VersionPage::updateButtons(int row)
+{
+ if(row == -1)
+ row = currentRow();
+ auto patch = m_version->versionPatch(row);
+ if (!patch)
{
- ui->changeMCVersionBtn->setEnabled(true);
+ ui->removeBtn->setDisabled(true);
+ ui->moveDownBtn->setDisabled(true);
+ ui->moveUpBtn->setDisabled(true);
+ ui->changeVersionBtn->setDisabled(true);
+ ui->editBtn->setDisabled(true);
+ ui->customizeBtn->setDisabled(true);
+ ui->revertBtn->setDisabled(true);
}
else
{
- ui->changeMCVersionBtn->setEnabled(false);
+ ui->removeBtn->setEnabled(patch->isRemovable());
+ ui->moveDownBtn->setEnabled(patch->isMoveable());
+ ui->moveUpBtn->setEnabled(patch->isMoveable());
+ ui->changeVersionBtn->setEnabled(patch->isVersionChangeable());
+ ui->editBtn->setEnabled(patch->isEditable());
+ ui->customizeBtn->setEnabled(patch->isCustomizable());
+ ui->revertBtn->setEnabled(patch->isRevertible());
}
}
@@ -303,3 +326,68 @@ void VersionPage::onGameUpdateError(QString error)
CustomMessageBox::selectable(this, tr("Error updating instance"), error,
QMessageBox::Warning)->show();
}
+
+ProfilePatchPtr VersionPage::current()
+{
+ auto row = currentRow();
+ if(row < 0)
+ {
+ return nullptr;
+ }
+ return m_version->versionPatch(row);
+}
+
+int VersionPage::currentRow()
+{
+ if (ui->packageView->selectionModel()->selectedRows().isEmpty())
+ {
+ return -1;
+ }
+ return ui->packageView->selectionModel()->selectedRows().first().row();
+}
+
+void VersionPage::on_customizeBtn_clicked()
+{
+ auto version = currentRow();
+ if(version == -1)
+ {
+ return;
+ }
+ if(!m_version->customize(version))
+ {
+ // TODO: some error box here
+ }
+ updateButtons();
+ preselect(currentIdx);
+}
+
+void VersionPage::on_editBtn_clicked()
+{
+ auto version = current();
+ if(!version)
+ {
+ return;
+ }
+ auto filename = version->getPatchFilename();
+ if(!QFileInfo::exists(filename))
+ {
+ qWarning() << "file" << filename << "can't be opened for editing, doesn't exist!";
+ return;
+ }
+ MMC->openJsonEditor(filename);
+}
+
+void VersionPage::on_revertBtn_clicked()
+{
+ auto version = currentRow();
+ if(version == -1)
+ {
+ return;
+ }
+ if(!m_version->revert(version))
+ {
+ // TODO: some error box here
+ }
+ updateButtons();
+ preselect(currentIdx);
+}
diff --git a/application/pages/VersionPage.h b/application/pages/VersionPage.h
index 0965edeb..45732b25 100644
--- a/application/pages/VersionPage.h
+++ b/application/pages/VersionPage.h
@@ -46,22 +46,29 @@ public:
return "Instance-version";
}
virtual bool shouldDisplay() const;
-private
-slots:
- // version tab
+private slots:
void on_forgeBtn_clicked();
void on_liteloaderBtn_clicked();
- void on_reloadLibrariesBtn_clicked();
- void on_removeLibraryBtn_clicked();
- void on_resetLibraryOrderBtn_clicked();
- void on_moveLibraryUpBtn_clicked();
- void on_moveLibraryDownBtn_clicked();
+ void on_reloadBtn_clicked();
+ void on_removeBtn_clicked();
+ void on_resetOrderBtn_clicked();
+ void on_moveUpBtn_clicked();
+ void on_moveDownBtn_clicked();
void on_jarmodBtn_clicked();
+ void on_revertBtn_clicked();
+ void on_editBtn_clicked();
+ void on_customizeBtn_clicked();
void updateVersionControls();
void disableVersionControls();
- void on_changeMCVersionBtn_clicked();
+ void on_changeVersionBtn_clicked();
+
+private:
+ ProfilePatchPtr current();
+ int currentRow();
+ void updateButtons(int row = -1);
+ void preselect(int row = 0);
protected:
/// FIXME: this shouldn't be necessary!
@@ -71,9 +78,9 @@ private:
Ui::VersionPage *ui;
std::shared_ptr<MinecraftProfile> m_version;
OneSixInstance *m_inst;
+ int currentIdx = 0;
-public
-slots:
+public slots:
void versionCurrent(const QModelIndex &current, const QModelIndex &previous);
private slots:
diff --git a/application/pages/VersionPage.ui b/application/pages/VersionPage.ui
index 67a556c8..1216229f 100644
--- a/application/pages/VersionPage.ui
+++ b/application/pages/VersionPage.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>Version</string>
+ <string>Package Versions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
@@ -37,7 +37,7 @@
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="ModListView" name="libraryTreeView">
+ <widget class="ModListView" name="packageView">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
@@ -65,16 +65,19 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="changeMCVersionBtn">
+ <widget class="QPushButton" name="changeVersionBtn">
+ <property name="toolTip">
+ <string>Change version of the selected package.</string>
+ </property>
<property name="text">
<string>Change version</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="moveLibraryUpBtn">
+ <widget class="QPushButton" name="moveUpBtn">
<property name="toolTip">
- <string>This isn't implemented yet.</string>
+ <string>Make the selected package apply sooner.</string>
</property>
<property name="text">
<string>Move up</string>
@@ -82,9 +85,9 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="moveLibraryDownBtn">
+ <widget class="QPushButton" name="moveDownBtn">
<property name="toolTip">
- <string>This isn't implemented yet.</string>
+ <string>Make the selected package apply later.</string>
</property>
<property name="text">
<string>Move down</string>
@@ -92,13 +95,59 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="removeLibraryBtn">
+ <widget class="QPushButton" name="removeBtn">
+ <property name="toolTip">
+ <string>Remove selected package from the instance.</string>
+ </property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
+ <widget class="LineSeparator" name="separator_4" native="true"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="customizeBtn">
+ <property name="toolTip">
+ <string>Customize selected package.</string>
+ </property>
+ <property name="text">
+ <string>Customize</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="editBtn">
+ <property name="toolTip">
+ <string>Edit selected package.</string>
+ </property>
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="revertBtn">
+ <property name="toolTip">
+ <string>Revert the selected package to default.</string>
+ </property>
+ <property name="text">
+ <string>Revert</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="LineSeparator" name="separator" native="true"/>
</item>
<item>
@@ -114,7 +163,7 @@
<item>
<widget class="QPushButton" name="forgeBtn">
<property name="toolTip">
- <string>Replace any current custom version with Minecraft Forge</string>
+ <string>Install the Minecraft Forge package.</string>
</property>
<property name="text">
<string>Install Forge</string>
@@ -123,6 +172,9 @@
</item>
<item>
<widget class="QPushButton" name="liteloaderBtn">
+ <property name="toolTip">
+ <string>Install the LiteLoader package.</string>
+ </property>
<property name="text">
<string>Install LiteLoader</string>
</property>
@@ -130,6 +182,9 @@
</item>
<item>
<widget class="QPushButton" name="jarmodBtn">
+ <property name="toolTip">
+ <string>Add a mod into the Minecraft jar file.</string>
+ </property>
<property name="text">
<string>Add jar mod</string>
</property>
@@ -149,9 +204,9 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="resetLibraryOrderBtn">
+ <widget class="QPushButton" name="resetOrderBtn">
<property name="toolTip">
- <string>This isn't implemented yet.</string>
+ <string>Reset apply order of packages.</string>
</property>
<property name="text">
<string>Reset order</string>
@@ -159,7 +214,10 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="reloadLibrariesBtn">
+ <widget class="QPushButton" name="reloadBtn">
+ <property name="toolTip">
+ <string>Reload all packages.</string>
+ </property>
<property name="text">
<string>Reload</string>
</property>
@@ -199,6 +257,22 @@
<container>1</container>
</customwidget>
</customwidgets>
+ <tabstops>
+ <tabstop>tabWidget</tabstop>
+ <tabstop>packageView</tabstop>
+ <tabstop>changeVersionBtn</tabstop>
+ <tabstop>moveUpBtn</tabstop>
+ <tabstop>moveDownBtn</tabstop>
+ <tabstop>removeBtn</tabstop>
+ <tabstop>customizeBtn</tabstop>
+ <tabstop>editBtn</tabstop>
+ <tabstop>revertBtn</tabstop>
+ <tabstop>forgeBtn</tabstop>
+ <tabstop>liteloaderBtn</tabstop>
+ <tabstop>jarmodBtn</tabstop>
+ <tabstop>resetOrderBtn</tabstop>
+ <tabstop>reloadBtn</tabstop>
+ </tabstops>
<resources/>
<connections/>
</ui>