diff --git a/include/ui/tileseteditortileselector.h b/include/ui/tileseteditortileselector.h index 3effca8c..a207db08 100644 --- a/include/ui/tileseteditortileselector.h +++ b/include/ui/tileseteditortileselector.h @@ -39,7 +39,7 @@ private: bool externalSelection; int externalSelectionWidth; int externalSelectionHeight; - QList externalSelectedTiles; + QList externalSelectedTiles; Tileset *primaryTileset; Tileset *secondaryTileset; @@ -52,7 +52,7 @@ private: uint16_t getTileId(int x, int y); QPoint getTileCoords(uint16_t); QList getCurPaletteTable(); - QList buildSelectedTiles(int, int, QList); + QList buildSelectedTiles(int, int, QList); signals: void hoveredTileChanged(uint16_t); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index fe769216..d61415c5 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -341,18 +341,9 @@ void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int } } - if (width == 1 && height == 1) { - this->tileSelector->select(static_cast(tiles[0].tile)); + if (width == 1 && height == 1) ui->spinBox_paletteSelector->setValue(tiles[0].palette); - ui->checkBox_xFlip->setChecked(tiles[0].xflip); - ui->checkBox_yFlip->setChecked(tiles[0].yflip); - QPoint pos = tileSelector->getTileCoordsOnWidget(static_cast(tiles[0].tile)); - ui->scrollArea_Tiles->ensureVisible(pos.x(), pos.y()); - } - else { - this->tileSelector->setExternalSelection(width, height, tiles); - } - + this->tileSelector->setExternalSelection(width, height, tiles); this->metatileLayersItem->clearLastModifiedCoords(); } diff --git a/src/ui/tileseteditortileselector.cpp b/src/ui/tileseteditortileselector.cpp index 4be3ccfa..f4fbffa2 100644 --- a/src/ui/tileseteditortileselector.cpp +++ b/src/ui/tileseteditortileselector.cpp @@ -98,22 +98,30 @@ QList TilesetEditorTileSelector::getSelectedTiles() { return buildSelectedTiles(this->externalSelectionWidth, this->externalSelectionHeight, this->externalSelectedTiles); } else { QPoint dimensions = this->getSelectionDimensions(); - return buildSelectedTiles(dimensions.x(), dimensions.y(), this->selectedTiles); + QList tiles; + for (int i = 0; i < this->selectedTiles.length(); i++) { + uint16_t tile = this->selectedTiles.at(i); + tiles.append(Tile(tile, false, false, this->paletteId)); + } + return buildSelectedTiles(dimensions.x(), dimensions.y(), tiles); } } -QList TilesetEditorTileSelector::buildSelectedTiles(int width, int height, QList selected) { +QList TilesetEditorTileSelector::buildSelectedTiles(int width, int height, QList selected) { QList tiles; QList> tileMatrix; 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); + Tile tile = selected.at(index); + tile.xflip ^= this->xFlip; + tile.yflip ^= this->yFlip; + tile.palette = this->paletteId; if (this->xFlip) - row.prepend(Tile(tile, this->xFlip, this->yFlip, this->paletteId)); + row.prepend(tile); else - row.append(Tile(tile, this->xFlip, this->yFlip, this->paletteId)); + row.append(tile); } if (this->yFlip) tileMatrix.prepend(row); @@ -134,7 +142,7 @@ void TilesetEditorTileSelector::setExternalSelection(int width, int height, QLis this->externalSelectionHeight = height; this->externalSelectedTiles.clear(); for (int i = 0; i < tiles.length(); i++) { - this->externalSelectedTiles.append(tiles.at(i).tile); + this->externalSelectedTiles.append(tiles.at(i)); } this->draw();