From 358732aa009d69cb9a2a53fe3c74abe86f0dd1e8 Mon Sep 17 00:00:00 2001 From: garak Date: Wed, 22 May 2019 20:04:25 -0400 Subject: [PATCH] fix bug in tileset editor where selection is drawn at improper coordinates --- src/ui/tileseteditor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 01ac188f..d6293a01 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -211,6 +211,16 @@ void TilesetEditor::onSelectedTilesChanged() { } void TilesetEditor::onMetatileLayerTileChanged(int x, int y) { + const QList tileCoords = QList{ + QPoint(0, 0), + QPoint(1, 0), + QPoint(0, 1), + QPoint(1, 1), + QPoint(2, 0), + QPoint(3, 0), + QPoint(2, 1), + QPoint(3, 1) + }; Metatile *prevMetatile = this->metatile->copy(); QPoint dimensions = this->tileSelector->getSelectionDimensions(); QList tiles = this->tileSelector->getSelectedTiles(); @@ -218,7 +228,9 @@ void TilesetEditor::onMetatileLayerTileChanged(int x, int y) { for (int j = 0; j < dimensions.y(); j++) { for (int i = 0; i < dimensions.x(); i++) { int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2); - if (tileIndex < 8) { + if (tileIndex < 8 + && tileCoords.at(tileIndex).x() >= x + && tileCoords.at(tileIndex).y() >= y){ Tile *tile = &(*this->metatile->tiles)[tileIndex]; tile->tile = tiles.at(selectedTileIndex).tile; tile->xflip = tiles.at(selectedTileIndex).xflip;