Fix layer flip to work on all incomplete metatile selections
This commit is contained in:
parent
cf9314eaa6
commit
70b8806737
3 changed files with 11 additions and 8 deletions
|
@ -24,7 +24,7 @@ public:
|
||||||
void setPaletteId(int);
|
void setPaletteId(int);
|
||||||
void setTileFlips(bool, bool);
|
void setTileFlips(bool, bool);
|
||||||
QList<Tile> getSelectedTiles();
|
QList<Tile> getSelectedTiles();
|
||||||
void setExternalSelection(int, int, QList<Tile>);
|
void setExternalSelection(int, int, QList<Tile>, QList<int>);
|
||||||
QPoint getTileCoordsOnWidget(uint16_t);
|
QPoint getTileCoordsOnWidget(uint16_t);
|
||||||
QImage buildPrimaryTilesIndexedImage();
|
QImage buildPrimaryTilesIndexedImage();
|
||||||
QImage buildSecondaryTilesIndexedImage();
|
QImage buildSecondaryTilesIndexedImage();
|
||||||
|
@ -41,6 +41,7 @@ private:
|
||||||
int externalSelectionWidth;
|
int externalSelectionWidth;
|
||||||
int externalSelectionHeight;
|
int externalSelectionHeight;
|
||||||
QList<Tile> externalSelectedTiles;
|
QList<Tile> externalSelectedTiles;
|
||||||
|
QList<int> externalSelectedPos;
|
||||||
|
|
||||||
Tileset *primaryTileset;
|
Tileset *primaryTileset;
|
||||||
Tileset *secondaryTileset;
|
Tileset *secondaryTileset;
|
||||||
|
|
|
@ -328,6 +328,7 @@ void TilesetEditor::onMetatileLayerTileChanged(int x, int y) {
|
||||||
|
|
||||||
void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int width, int height) {
|
void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int width, int height) {
|
||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
|
QList<int> tileIdxs;
|
||||||
int x = selectionOrigin.x();
|
int x = selectionOrigin.x();
|
||||||
int y = selectionOrigin.y();
|
int y = selectionOrigin.y();
|
||||||
bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
|
bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
|
||||||
|
@ -337,13 +338,14 @@ void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int
|
||||||
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
|
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
|
||||||
if (tileIndex < maxTileIndex) {
|
if (tileIndex < maxTileIndex) {
|
||||||
tiles.append(this->metatile->tiles->at(tileIndex));
|
tiles.append(this->metatile->tiles->at(tileIndex));
|
||||||
|
tileIdxs.append(tileIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width == 1 && height == 1)
|
if (width == 1 && height == 1)
|
||||||
ui->spinBox_paletteSelector->setValue(tiles[0].palette);
|
ui->spinBox_paletteSelector->setValue(tiles[0].palette);
|
||||||
this->tileSelector->setExternalSelection(width, height, tiles);
|
this->tileSelector->setExternalSelection(width, height, tiles, tileIdxs);
|
||||||
this->metatileLayersItem->clearLastModifiedCoords();
|
this->metatileLayersItem->clearLastModifiedCoords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,8 @@ QList<Tile> TilesetEditorTileSelector::buildSelectedTiles(int width, int height,
|
||||||
|
|
||||||
// If we've completed a layer row, or its the last tile of an incompletely
|
// 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
|
// selected layer, then append the layer row to the full row
|
||||||
if (layerRow.length() == 2 || (width % 2 && i == width - 1)) {
|
// If not an external selection, treat the whole row as 1 "layer"
|
||||||
|
if (i == width - 1 || (this->externalSelection && (this->externalSelectedPos.at(index) % 4) & 1)) {
|
||||||
row.append(layerRow);
|
row.append(layerRow);
|
||||||
layerRow.clear();
|
layerRow.clear();
|
||||||
}
|
}
|
||||||
|
@ -146,16 +147,15 @@ QList<Tile> TilesetEditorTileSelector::buildSelectedTiles(int width, int height,
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditorTileSelector::setExternalSelection(int width, int height, QList<Tile> tiles) {
|
void TilesetEditorTileSelector::setExternalSelection(int width, int height, QList<Tile> tiles, QList<int> tileIdxs) {
|
||||||
this->externalSelection = true;
|
this->externalSelection = true;
|
||||||
this->paletteChanged = false;
|
this->paletteChanged = false;
|
||||||
this->externalSelectionWidth = width;
|
this->externalSelectionWidth = width;
|
||||||
this->externalSelectionHeight = height;
|
this->externalSelectionHeight = height;
|
||||||
this->externalSelectedTiles.clear();
|
this->externalSelectedTiles.clear();
|
||||||
for (int i = 0; i < tiles.length(); i++) {
|
this->externalSelectedTiles.append(tiles);
|
||||||
this->externalSelectedTiles.append(tiles.at(i));
|
this->externalSelectedPos.clear();
|
||||||
}
|
this->externalSelectedPos.append(tileIdxs);
|
||||||
|
|
||||||
this->draw();
|
this->draw();
|
||||||
emit selectedTilesChanged();
|
emit selectedTilesChanged();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue