From 0b28a95e9ff3e00fb1be28cd746c3f7173bf5875 Mon Sep 17 00:00:00 2001 From: garak Date: Tue, 21 May 2019 20:34:35 -0400 Subject: [PATCH] flip entire selection contents in tileset editor --- src/ui/tileseteditortileselector.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ui/tileseteditortileselector.cpp b/src/ui/tileseteditortileselector.cpp index 859783cb..e2a52e5e 100644 --- a/src/ui/tileseteditortileselector.cpp +++ b/src/ui/tileseteditortileselector.cpp @@ -98,8 +98,30 @@ QList TilesetEditorTileSelector::getSelectedTiles() { return this->externalSelectedTiles; } else { QList tiles; - for (uint16_t tile : this->selectedTiles) { - tiles.append(Tile(tile, this->xFlip, this->yFlip, this->paletteId)); + QList> tileMatrix; + QList selected = this->selectedTiles; + QPoint dimensions = this->getSelectionDimensions(); + int width = dimensions.x(); + int height = dimensions.y(); + for (int j = 0; j < height; j++) { + QList row; + for (int i = 0; i < width; i++) { + int index = i + j * width; + uint16_t tile = selected.at(index); + if (this->xFlip) + row.prepend(Tile(tile, this->xFlip, this->yFlip, this->paletteId)); + else + row.append(Tile(tile, this->xFlip, this->yFlip, this->paletteId)); + } + if (this->yFlip) + tileMatrix.prepend(row); + else + tileMatrix.append(row); + } + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + tiles.append(tileMatrix.at(j).at(i)); + } } return tiles; }