From 81cd43933b8c10c49e56b4a509023b5971fbe1c8 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 20 May 2020 19:21:18 -0500 Subject: [PATCH] Eliminate unnecessary expensive map redraws when saving or changing tilesets --- include/editor.h | 1 - include/mainwindow.h | 1 - src/editor.cpp | 2 -- src/mainwindow.cpp | 19 +++++++++++-------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/editor.h b/include/editor.h index 583678ce..80e57c5a 100644 --- a/include/editor.h +++ b/include/editor.h @@ -194,7 +194,6 @@ signals: void objectsChanged(); void selectedObjectsChanged(); void loadMapRequested(QString, QString); - void tilesetChanged(QString); void wildMonDataChanged(); void warpEventDoubleClicked(QString mapName, QString warpNum); void currentMetatilesSelectionChanged(); diff --git a/include/mainwindow.h b/include/mainwindow.h index 1711645e..4fb4cc87 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -183,7 +183,6 @@ private slots: void onAddNewMapToGroupClick(QAction* triggeredAction); void onAddNewMapToAreaClick(QAction* triggeredAction); void onAddNewMapToLayoutClick(QAction* triggeredAction); - void onTilesetChanged(QString); void currentMetatilesSelectionChanged(); void on_action_Export_Map_Image_triggered(); diff --git a/src/editor.cpp b/src/editor.cpp index b95b1749..4e3be878 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1718,7 +1718,6 @@ void Editor::updatePrimaryTileset(QString tilesetLabel, bool forceLoad) { map->layout->tileset_primary_label = tilesetLabel; map->layout->tileset_primary = project->getTileset(tilesetLabel, forceLoad); - emit tilesetChanged(map->name); } } @@ -1728,7 +1727,6 @@ void Editor::updateSecondaryTileset(QString tilesetLabel, bool forceLoad) { map->layout->tileset_secondary_label = tilesetLabel; map->layout->tileset_secondary = project->getTileset(tilesetLabel, forceLoad); - emit tilesetChanged(map->name); } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6a306892..11090201 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -112,7 +112,6 @@ void MainWindow::initEditor() { connect(this->editor, SIGNAL(objectsChanged()), this, SLOT(updateObjects())); connect(this->editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects())); connect(this->editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString))); - connect(this->editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString))); connect(this->editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString))); connect(this->editor, SIGNAL(currentMetatilesSelectionChanged()), this, SLOT(currentMetatilesSelectionChanged())); connect(this->editor, SIGNAL(wildMonDataChanged()), this, SLOT(onWildMonDataChanged())); @@ -564,13 +563,19 @@ void MainWindow::displayMapProperties() { ui->frame_3->setEnabled(false); return; } + ui->frame_3->setEnabled(true); Map *map = editor->map; - ui->comboBox_Song->setCurrentText(map->song); - ui->comboBox_Location->setCurrentText(map->location); + ui->comboBox_PrimaryTileset->blockSignals(true); + ui->comboBox_SecondaryTileset->blockSignals(true); ui->comboBox_PrimaryTileset->setCurrentText(map->layout->tileset_primary_label); ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label); + ui->comboBox_PrimaryTileset->blockSignals(false); + ui->comboBox_SecondaryTileset->blockSignals(false); + + ui->comboBox_Song->setCurrentText(map->song); + ui->comboBox_Location->setCurrentText(map->location); ui->checkBox_Visibility->setChecked(map->requiresFlash.toInt() > 0 || map->requiresFlash == "TRUE"); ui->comboBox_Weather->setCurrentText(map->weather); ui->comboBox_Type->setCurrentText(map->type); @@ -1117,11 +1122,6 @@ void MainWindow::on_actionNew_Tileset_triggered() { } } -void MainWindow::onTilesetChanged(QString mapName) -{ - setMap(mapName); -} - void MainWindow::updateTilesetEditor() { if (this->tilesetEditor) { this->tilesetEditor->setTilesets(editor->ui->comboBox_PrimaryTileset->currentText(), editor->ui->comboBox_SecondaryTileset->currentText()); @@ -2217,6 +2217,7 @@ void MainWindow::onMapNeedsRedrawing() { void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryTilesetLabel) { this->editor->updatePrimaryTileset(primaryTilesetLabel, true); this->editor->updateSecondaryTileset(secondaryTilesetLabel, true); + redrawMapScene(); } void MainWindow::onWildMonDataChanged() { @@ -2298,6 +2299,7 @@ void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &ti { if (editor->project->tilesetLabels["primary"].contains(tilesetLabel) && editor->map) { editor->updatePrimaryTileset(tilesetLabel); + redrawMapScene(); on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value()); } } @@ -2306,6 +2308,7 @@ void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString & { if (editor->project->tilesetLabels["secondary"].contains(tilesetLabel) && editor->map) { editor->updateSecondaryTileset(tilesetLabel); + redrawMapScene(); on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value()); } }