diff --git a/CHANGELOG.md b/CHANGELOG.md index 91400820..23bfb9b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix default object sprites retaining dimensions and transparency of the previous sprite. - Fix connections not being deleted when the map name text box is cleared. - Fix the map border not updating when a tileset is changed. +- Stop the Tileset Editor from scrolling to the initially selected metatile when saving. ## [5.1.1] - 2023-02-20 ### Added diff --git a/include/ui/tileseteditor.h b/include/ui/tileseteditor.h index b03964b5..09a828c3 100644 --- a/include/ui/tileseteditor.h +++ b/include/ui/tileseteditor.h @@ -164,6 +164,7 @@ private: QGraphicsScene *selectedTileScene = nullptr; QGraphicsPixmapItem *selectedTilePixmapItem = nullptr; QGraphicsScene *metatileLayersScene = nullptr; + bool lockSelection = false; signals: void tilesetsSaved(QString, QString); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index c16aeaf4..9240d0d1 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -68,7 +68,8 @@ void TilesetEditor::updateTilesets(QString primaryTilesetLabel, QString secondar } bool TilesetEditor::selectMetatile(uint16_t metatileId) { - if (!Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset)) return false; + if (!Tileset::metatileIsValid(metatileId, this->primaryTileset, this->secondaryTileset) || this->lockSelection) + return false; this->metatileSelector->select(metatileId); QPoint pos = this->metatileSelector->getMetatileIdCoordsOnWidget(metatileId); this->ui->scrollArea_Metatiles->ensureVisible(pos.x(), pos.y()); @@ -592,18 +593,17 @@ void TilesetEditor::on_comboBox_terrainType_activated(int terrainType) void TilesetEditor::on_actionSave_Tileset_triggered() { - // need this temporary metatile ID to reset selection after saving - // when the tilesetsSaved signal is sent, it will be reset to the current map metatile - uint16_t reselectMetatileID = this->metatileSelector->getSelectedMetatileId(); - + // Need this temporary flag to stop selection resetting after saving. + // This is a workaround; redrawing the map's metatile selector shouldn't emit the same signal as when it's selected. + this->lockSelection = true; this->project->saveTilesets(this->primaryTileset, this->secondaryTileset); emit this->tilesetsSaved(this->primaryTileset->name, this->secondaryTileset->name); - this->metatileSelector->select(reselectMetatileID); if (this->paletteEditor) { this->paletteEditor->setTilesets(this->primaryTileset, this->secondaryTileset); } this->ui->statusbar->showMessage(QString("Saved primary and secondary Tilesets!"), 5000); this->hasUnsavedChanges = false; + this->lockSelection = false; } void TilesetEditor::on_actionImport_Primary_Tiles_triggered()