Apply xflip to layers individually, fix palette in selection

This commit is contained in:
GriffinR 2020-07-14 00:47:28 -04:00 committed by huderlem
parent b5b227a6a0
commit 5798ef7fda

View file

@ -112,16 +112,23 @@ QList<Tile> TilesetEditorTileSelector::buildSelectedTiles(int width, int height,
QList<QList<Tile>> tileMatrix; QList<QList<Tile>> tileMatrix;
for (int j = 0; j < height; j++) { for (int j = 0; j < height; j++) {
QList<Tile> row; QList<Tile> row;
QList<Tile> layerRow;
for (int i = 0; i < width; i++) { for (int i = 0; i < width; i++) {
int index = i + j * width; int index = i + j * width;
Tile tile = selected.at(index); Tile tile = selected.at(index);
tile.xflip ^= this->xFlip; tile.xflip ^= this->xFlip;
tile.yflip ^= this->yFlip; tile.yflip ^= this->yFlip;
tile.palette = this->paletteId;
if (this->xFlip) if (this->xFlip)
row.prepend(tile); layerRow.prepend(tile);
else else
row.append(tile); layerRow.append(tile);
// If we've completed a layer row, or its the last tile of an incompletely
// selected layer, then append the layer row to the full row
if (layerRow.length() == 2 || (width % 2 && i == width - 1)) {
row.append(layerRow);
layerRow.clear();
}
} }
if (this->yFlip) if (this->yFlip)
tileMatrix.prepend(row); tileMatrix.prepend(row);