From ffff2cd3248a574d3d666731580ac7b8c33e1735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 9 Mar 2014 17:38:42 +0100 Subject: Remove version patch reordering. Remove the main class display from onesix edit mods. --- gui/dialogs/OneSixModEditDialog.cpp | 114 +++--------------------------------- 1 file changed, 9 insertions(+), 105 deletions(-) (limited to 'gui/dialogs/OneSixModEditDialog.cpp') diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index 96205d0a..c211d3e1 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -110,7 +110,6 @@ void OneSixModEditDialog::updateVersionControls() { ui->forgeBtn->setEnabled(true); ui->liteloaderBtn->setEnabled(true); - ui->mainClassEdit->setText(m_version->mainClass); } void OneSixModEditDialog::disableVersionControls() @@ -119,7 +118,6 @@ void OneSixModEditDialog::disableVersionControls() ui->liteloaderBtn->setEnabled(false); ui->reloadLibrariesBtn->setEnabled(false); ui->removeLibraryBtn->setEnabled(false); - ui->mainClassEdit->setText(""); } void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() @@ -131,6 +129,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() { if (ui->libraryTreeView->currentIndex().isValid()) { + // FIXME: use actual model, not reloading. if (!m_version->remove(ui->libraryTreeView->currentIndex().row())) { QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file")); @@ -144,97 +143,31 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked() { - QDir(m_inst->instanceRoot()).remove("order.json"); - m_inst->reloadVersion(); + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } + void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() { - - QMap order = getExistingOrder(); - if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) - { - return; - } - const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); - const QString ourId = m_version->versionFileId(ourRow); - const int ourOrder = order[ourId]; - if (ourId.isNull() || ourId.startsWith("org.multimc.")) - { - return; - } - - QMap sortedOrder = invert(order); - - QList sortedOrders = sortedOrder.keys(); - const int ourIndex = sortedOrders.indexOf(ourOrder); - if (ourIndex <= 0) - { - return; - } - const int ourNewOrder = sortedOrders.at(ourIndex - 1); - order[ourId] = ourNewOrder; - order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder; - - // FIXME: why is GUI code doing this in particular? why isn't this part of a model? - if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) - { - QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); - } - else - { - m_inst->reloadVersion(); - ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent); - } + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } -// FIXME: WHY IS THIS DUPLICATED? void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() { - QMap order = getExistingOrder(); - if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) - { - return; - } - const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); - const QString ourId = m_version->versionFileId(ourRow); - const int ourOrder = order[ourId]; - if (ourId.isNull() || ourId.startsWith("org.multimc.")) - { - return; - } - - QMap sortedOrder = invert(order); - - QList sortedOrders = sortedOrder.keys(); - const int ourIndex = sortedOrders.indexOf(ourOrder); - if ((ourIndex + 1) >= sortedOrders.size()) - { - return; - } - const int ourNewOrder = sortedOrders.at(ourIndex + 1); - order[ourId] = ourNewOrder; - order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder; - - // FIXME: why is GUI code doing this in particular? why isn't this part of a model? - if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) - { - QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); - } - else - { - m_inst->reloadVersion(); - ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent); - } + // FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). } 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 (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) { return; } + // FIXME: model::revertToBase(); QDir(m_inst->instanceRoot()).remove("custom.json"); m_inst->reloadVersion(); } @@ -351,35 +284,6 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent) return QDialog::eventFilter(ui->resPackTreeView, keyEvent); } -QMap OneSixModEditDialog::getExistingOrder() const -{ - - QMap order; - // default - { - for (auto & file : m_version->versionFiles) - { - if (file.id.startsWith("org.multimc.")) - { - continue; - } - order.insert(file.id, file.order); - } - } - // overriden - { - QMap overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_inst); - for (auto id : order.keys()) - { - if (overridenOrder.contains(id)) - { - order[id] = overridenOrder[id]; - } - } - } - return order; -} - bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() != QEvent::KeyPress) -- cgit v1.2.3