From 66133189004188c8905afe2ef625a6d12197457b Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 23 Nov 2021 23:53:41 -0500 Subject: [PATCH] Disambiguate tile field names to tileId or metatileId --- include/core/block.h | 4 +- include/core/tile.h | 8 ++-- src/core/block.cpp | 16 ++++---- src/core/map.cpp | 8 ++-- src/editor.cpp | 2 +- src/mainwindow.cpp | 4 +- src/project.cpp | 4 +- src/scripting.cpp | 8 ++-- src/ui/bordermetatilespixmapitem.cpp | 6 +-- src/ui/imageproviders.cpp | 4 +- src/ui/mappixmapitem.cpp | 58 ++++++++++++++-------------- src/ui/metatilelayersitem.cpp | 2 +- src/ui/tileseteditor.cpp | 36 ++++++++--------- 13 files changed, 80 insertions(+), 80 deletions(-) diff --git a/include/core/block.h b/include/core/block.h index 9bb1877f..ad7d210e 100644 --- a/include/core/block.h +++ b/include/core/block.h @@ -9,12 +9,12 @@ class Block public: Block(); Block(uint16_t); - Block(uint16_t tile, uint16_t collision, uint16_t elevation); + Block(uint16_t metatileId, uint16_t collision, uint16_t elevation); Block(const Block &); Block &operator=(const Block &); bool operator ==(Block) const; bool operator !=(Block) const; - uint16_t tile:10; + uint16_t metatileId:10; uint16_t collision:2; uint16_t elevation:4; uint16_t rawValue() const; diff --git a/include/core/tile.h b/include/core/tile.h index dfcb7117..dff5cd58 100644 --- a/include/core/tile.h +++ b/include/core/tile.h @@ -7,21 +7,21 @@ class Tile { public: Tile() : - tile(0), + tileId(0), xflip(false), yflip(false), palette(0) { } - Tile(int tile, bool xflip, bool yflip, int palette) : - tile(tile), + Tile(int tileId, bool xflip, bool yflip, int palette) : + tileId(tileId), xflip(xflip), yflip(yflip), palette(palette) { } public: - int tile; + int tileId; bool xflip; bool yflip; int palette; diff --git a/src/core/block.cpp b/src/core/block.cpp index 680384fd..be1e8b7f 100644 --- a/src/core/block.cpp +++ b/src/core/block.cpp @@ -1,27 +1,27 @@ #include "block.h" -Block::Block() : tile(0), collision(0), elevation(0) { } +Block::Block() : metatileId(0), collision(0), elevation(0) { } -Block::Block(uint16_t tile, uint16_t collision, uint16_t elevation) : - tile(tile), +Block::Block(uint16_t metatileId, uint16_t collision, uint16_t elevation) : + metatileId(metatileId), collision(collision), elevation(elevation) { } Block::Block(uint16_t word) : - tile(word & 0x3ff), + metatileId(word & 0x3ff), collision((word >> 10) & 0x3), elevation((word >> 12) & 0xf) { } Block::Block(const Block &other) : - tile(other.tile), + metatileId(other.metatileId), collision(other.collision), elevation(other.elevation) { } Block &Block::operator=(const Block &other) { - tile = other.tile; + metatileId = other.metatileId; collision = other.collision; elevation = other.elevation; return *this; @@ -29,13 +29,13 @@ Block &Block::operator=(const Block &other) { uint16_t Block::rawValue() const { return static_cast( - (tile & 0x3ff) + + (metatileId & 0x3ff) + ((collision & 0x3) << 10) + ((elevation & 0xf) << 12)); } bool Block::operator ==(Block other) const { - return (tile == other.tile) && (collision == other.collision) && (elevation == other.elevation); + return (metatileId == other.metatileId) && (collision == other.collision) && (elevation == other.elevation); } bool Block::operator !=(Block other) const { diff --git a/src/core/map.cpp b/src/core/map.cpp index da3a5c0a..8b2e56cf 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -133,7 +133,7 @@ QPixmap Map::renderCollision(qreal opacity, bool ignoreCache) { } changed_any = true; Block block = layout->blockdata.at(i); - QImage metatile_image = getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity); + QImage metatile_image = getMetatileImage(block.metatileId, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity); QImage collision_metatile_image = getCollisionMetatileImage(block); int map_y = width_ ? i / width_ : 0; int map_x = width_ ? i % width_ : 0; @@ -174,7 +174,7 @@ QPixmap Map::render(bool ignoreCache = false, MapLayout * fromLayout) { changed_any = true; Block block = layout->blockdata.at(i); QImage metatile_image = getMetatileImage( - block.tile, + block.metatileId, fromLayout ? fromLayout->tileset_primary : layout->tileset_primary, fromLayout ? fromLayout->tileset_secondary : layout->tileset_secondary, metatileLayerOrder, @@ -218,8 +218,8 @@ QPixmap Map::renderBorder(bool ignoreCache) { changed_any = true; Block block = layout->border.at(i); - uint16_t tile = block.tile; - QImage metatile_image = getMetatileImage(tile, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity); + uint16_t metatileId = block.metatileId; + QImage metatile_image = getMetatileImage(metatileId, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity); int map_y = width_ ? i / width_ : 0; int map_x = width_ ? i % width_ : 0; painter.drawImage(QPoint(map_x * 16, map_y * 16), metatile_image); diff --git a/src/editor.cpp b/src/editor.cpp index 4a4d26d4..2362321c 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -991,7 +991,7 @@ void Editor::onHoveredMapMetatileChanged(const QPoint &pos) { if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles && pos.x() >= 0 && pos.x() < map->getWidth() && pos.y() >= 0 && pos.y() < map->getHeight()) { int blockIndex = pos.y() * map->getWidth() + pos.x(); - int metatileId = map->layout->blockdata.at(blockIndex).tile; + int metatileId = map->layout->blockdata.at(blockIndex).metatileId; this->ui->statusBar->showMessage(QString("X: %1, Y: %2, %3, Scale = %4x") .arg(pos.x()) .arg(pos.y()) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d0004cca..bcc1a2b8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1298,9 +1298,9 @@ void MainWindow::on_actionNew_Tileset_triggered() { Tile tile(0, false, false, 0); //Create a checkerboard-style dummy tileset if(((i / 8) % 2) == 0) - tile.tile = ((i % 2) == 0) ? 1 : 2; + tile.tileId = ((i % 2) == 0) ? 1 : 2; else - tile.tile = ((i % 2) == 1) ? 1 : 2; + tile.tileId = ((i % 2) == 1) ? 1 : 2; mt->tiles.append(tile); } mt->behavior = 0; diff --git a/src/project.cpp b/src/project.cpp index 2bf35b8e..7ebe0aa7 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1064,7 +1064,7 @@ void Project::saveTilesetMetatiles(Tileset *tileset) { int numTiles = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8; for (int i = 0; i < numTiles; i++) { Tile tile = metatile->tiles.at(i); - uint16_t value = static_cast((tile.tile & 0x3ff) + uint16_t value = static_cast((tile.tileId & 0x3ff) | ((tile.xflip & 1) << 10) | ((tile.yflip & 1) << 11) | ((tile.palette & 0xf) << 12)); @@ -1574,7 +1574,7 @@ void Project::loadTilesetMetatiles(Tileset* tileset) { uint16_t word = data[index++] & 0xff; word += (data[index++] & 0xff) << 8; Tile tile; - tile.tile = word & 0x3ff; + tile.tileId = word & 0x3ff; tile.xflip = (word >> 10) & 1; tile.yflip = (word >> 11) & 1; tile.palette = (word >> 12) & 0xf; diff --git a/src/scripting.cpp b/src/scripting.cpp index 404bf7cb..7fb41d8f 100644 --- a/src/scripting.cpp +++ b/src/scripting.cpp @@ -142,7 +142,7 @@ void Scripting::cb_MapOpened(QString mapName) { QJSValue Scripting::fromBlock(Block block) { QJSValue obj = instance->engine->newObject(); - obj.setProperty("metatileId", block.tile); + obj.setProperty("metatileId", block.metatileId); obj.setProperty("collision", block.collision); obj.setProperty("elevation", block.elevation); obj.setProperty("rawValue", block.rawValue()); @@ -157,14 +157,14 @@ QJSValue Scripting::dimensions(int width, int height) { } Tile Scripting::toTile(QJSValue obj) { - if (!obj.hasProperty("tile") + if (!obj.hasProperty("tileId") || !obj.hasProperty("xflip") || !obj.hasProperty("yflip") || !obj.hasProperty("palette")) { return Tile(); } Tile tile = Tile(); - tile.tile = obj.property("tile").toInt(); + tile.tileId = obj.property("tileId").toInt(); tile.xflip = obj.property("xflip").toBool(); tile.yflip = obj.property("yflip").toBool(); tile.palette = obj.property("palette").toInt(); @@ -173,7 +173,7 @@ Tile Scripting::toTile(QJSValue obj) { QJSValue Scripting::fromTile(Tile tile) { QJSValue obj = instance->engine->newObject(); - obj.setProperty("tile", tile.tile); + obj.setProperty("tileId", tile.tileId); obj.setProperty("xflip", tile.xflip); obj.setProperty("yflip", tile.yflip); obj.setProperty("palette", tile.palette); diff --git a/src/ui/bordermetatilespixmapitem.cpp b/src/ui/bordermetatilespixmapitem.cpp index 8b3592f2..0f03e2aa 100644 --- a/src/ui/bordermetatilespixmapitem.cpp +++ b/src/ui/bordermetatilespixmapitem.cpp @@ -16,8 +16,8 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) for (int i = 0; i < selectionDimensions.x() && (i + pos.x()) < width; i++) { for (int j = 0; j < selectionDimensions.y() && (j + pos.y()) < height; j++) { int blockIndex = (j + pos.y()) * width + (i + pos.x()); - uint16_t tile = selectedMetatiles->at(j * selectionDimensions.x() + i); - map->layout->border[blockIndex].tile = tile; + uint16_t metatileId = selectedMetatiles->at(j * selectionDimensions.x() + i); + map->layout->border[blockIndex].metatileId = metatileId; } } @@ -42,7 +42,7 @@ void BorderMetatilesPixmapItem::draw() { int y = j * 16; int index = j * width + i; QImage metatile_image = getMetatileImage( - map->layout->border.value(index).tile, + map->layout->border.value(index).metatileId, map->layout->tileset_primary, map->layout->tileset_secondary, map->metatileLayerOrder, diff --git a/src/ui/imageproviders.cpp b/src/ui/imageproviders.cpp index 44a7e4f2..f5a4357a 100644 --- a/src/ui/imageproviders.cpp +++ b/src/ui/imageproviders.cpp @@ -47,7 +47,7 @@ QImage getMetatileImage( int l = layerOrder.size() >= numLayers ? layerOrder[layer] : layer; int bottomLayer = layerOrder.size() >= numLayers ? layerOrder[0] : 0; Tile tile_ = metatile->tiles.value((y * 2) + x + (l * 4)); - QImage tile_image = getTileImage(tile_.tile, primaryTileset, secondaryTileset); + QImage tile_image = getTileImage(tile_.tileId, primaryTileset, secondaryTileset); if (tile_image.isNull()) { // Some metatiles specify tiles that are outside the valid range. // These are treated as completely transparent, so they can be skipped without @@ -66,7 +66,7 @@ QImage getMetatileImage( tile_image.setColor(j, palette.value(j)); } } else { - logWarn(QString("Tile '%1' is referring to invalid palette number: '%2'").arg(tile_.tile).arg(tile_.palette)); + logWarn(QString("Tile '%1' is referring to invalid palette number: '%2'").arg(tile_.tileId).arg(tile_.palette)); } QPoint origin = QPoint(x*8, y*8); diff --git a/src/ui/mappixmapitem.cpp b/src/ui/mappixmapitem.cpp index e7f82bb0..0d22b9b7 100644 --- a/src/ui/mappixmapitem.cpp +++ b/src/ui/mappixmapitem.cpp @@ -126,7 +126,7 @@ void MapPixmapItem::paintNormal(int x, int y, bool fromScriptCall) { Block block; if (map->getBlock(actualX, actualY, &block)) { int index = j * selectionDimensions.x() + i; - block.tile = selectedMetatiles->at(index); + block.metatileId = selectedMetatiles->at(index); if (selectedCollisions && selectedCollisions->length() == selectedMetatiles->length()) { block.collision = selectedCollisions->at(index).first; block.elevation = selectedCollisions->at(index).second; @@ -162,7 +162,7 @@ QList MapPixmapItem::smartPathTable = QList({ 4, // 1111 }); -#define IS_SMART_PATH_TILE(block) (selectedMetatiles->contains(block.tile)) +#define IS_SMART_PATH_TILE(block) (selectedMetatiles->contains(block.metatileId)) void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) { QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions(); @@ -196,7 +196,7 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) { int actualY = j + y; Block block; if (map->getBlock(actualX, actualY, &block)) { - block.tile = openTile; + block.metatileId = openTile; if (setCollisions) { block.collision = openTileCollision; block.elevation = openTileElevation; @@ -240,7 +240,7 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) { if (map->getBlock(actualX - 1, actualY, &left) && IS_SMART_PATH_TILE(left)) id += 8; - block.tile = selectedMetatiles->at(smartPathTable[id]); + block.metatileId = selectedMetatiles->at(smartPathTable[id]); if (setCollisions) { block.collision = selectedCollisions->at(smartPathTable[id]).first; block.elevation = selectedCollisions->at(smartPathTable[id]).second; @@ -305,7 +305,7 @@ void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) { selection.append(QPoint(pos.x(), pos.y())); Block block; if (map->getBlock(pos.x(), pos.y(), &block)) { - this->metatileSelector->selectFromMap(block.tile, block.collision, block.elevation); + this->metatileSelector->selectFromMap(block.metatileId, block.collision, block.elevation); } } else if (event->type() == QEvent::GraphicsSceneMouseMove) { int x1 = selection_origin.x(); @@ -328,7 +328,7 @@ void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) { int y = point.y(); Block block; if (map->getBlock(x, y, &block)) { - metatiles.append(block.tile); + metatiles.append(block.metatileId); } int blockIndex = y * map->getWidth() + x; block = map->layout->blockdata.at(blockIndex); @@ -350,8 +350,8 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) { Block block; QList *selectedMetatiles = this->metatileSelector->getSelectedMetatiles(); QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions(); - int tile = selectedMetatiles->first(); - if (selectedMetatiles->count() > 1 || (map->getBlock(pos.x(), pos.y(), &block) && block.tile != tile)) { + int metatileId = selectedMetatiles->first(); + if (selectedMetatiles->count() > 1 || (map->getBlock(pos.x(), pos.y(), &block) && block.metatileId != metatileId)) { bool smartPathsEnabled = event->modifiers() & Qt::ShiftModifier; if ((this->settings->smartPathsEnabled || smartPathsEnabled) && selectionDimensions.x() == 3 && selectionDimensions.y() == 3) this->floodFillSmartPath(pos.x(), pos.y()); @@ -396,17 +396,17 @@ void MapPixmapItem::magicFill( bool fromScriptCall) { Block block; if (map->getBlock(initialX, initialY, &block)) { - if (selectedMetatiles->length() == 1 && selectedMetatiles->value(0) == block.tile) { + if (selectedMetatiles->length() == 1 && selectedMetatiles->value(0) == block.metatileId) { return; } Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata(); bool setCollisions = selectedCollisions && selectedCollisions->length() == selectedMetatiles->length(); - uint16_t tile = block.tile; + uint16_t metatileId = block.metatileId; for (int y = 0; y < map->getHeight(); y++) { for (int x = 0; x < map->getWidth(); x++) { - if (map->getBlock(x, y, &block) && block.tile == tile) { + if (map->getBlock(x, y, &block) && block.metatileId == metatileId) { int xDiff = x - initialX; int yDiff = y - initialY; int i = xDiff % selectionDimensions.x(); @@ -414,7 +414,7 @@ void MapPixmapItem::magicFill( if (i < 0) i = selectionDimensions.x() + i; if (j < 0) j = selectionDimensions.y() + j; int index = j * selectionDimensions.x() + i; - block.tile = selectedMetatiles->at(index); + block.metatileId = selectedMetatiles->at(index); if (setCollisions) { block.collision = selectedCollisions->at(index).first; block.elevation = selectedCollisions->at(index).second; @@ -474,29 +474,29 @@ void MapPixmapItem::floodFill( if (i < 0) i = selectionDimensions.x() + i; if (j < 0) j = selectionDimensions.y() + j; int index = j * selectionDimensions.x() + i; - uint16_t tile = selectedMetatiles->at(index); - uint16_t old_tile = block.tile; - if (selectedMetatiles->count() != 1 || old_tile != tile) { - block.tile = tile; + uint16_t metatileId = selectedMetatiles->at(index); + uint16_t old_metatileId = block.metatileId; + if (selectedMetatiles->count() != 1 || old_metatileId != metatileId) { + block.metatileId = metatileId; if (setCollisions) { block.collision = selectedCollisions->at(index).first; block.elevation = selectedCollisions->at(index).second; } map->setBlock(x, y, block, !fromScriptCall); } - if (!visited.contains(x + 1 + y * map->getWidth()) && map->getBlock(x + 1, y, &block) && block.tile == old_tile) { + if (!visited.contains(x + 1 + y * map->getWidth()) && map->getBlock(x + 1, y, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x + 1, y)); visited.insert(x + 1 + y * map->getWidth()); } - if (!visited.contains(x - 1 + y * map->getWidth()) && map->getBlock(x - 1, y, &block) && block.tile == old_tile) { + if (!visited.contains(x - 1 + y * map->getWidth()) && map->getBlock(x - 1, y, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x - 1, y)); visited.insert(x - 1 + y * map->getWidth()); } - if (!visited.contains(x + (y + 1) * map->getWidth()) && map->getBlock(x, y + 1, &block) && block.tile == old_tile) { + if (!visited.contains(x + (y + 1) * map->getWidth()) && map->getBlock(x, y + 1, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x, y + 1)); visited.insert(x + (y + 1) * map->getWidth()); } - if (!visited.contains(x + (y - 1) * map->getWidth()) && map->getBlock(x, y - 1, &block) && block.tile == old_tile) { + if (!visited.contains(x + (y - 1) * map->getWidth()) && map->getBlock(x, y - 1, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x, y - 1)); visited.insert(x + (y - 1) * map->getWidth()); } @@ -540,27 +540,27 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri continue; } - uint16_t old_tile = block.tile; - if (old_tile == openTile) { + uint16_t old_metatileId = block.metatileId; + if (old_metatileId == openTile) { continue; } - block.tile = openTile; + block.metatileId = openTile; if (setCollisions) { block.collision = openTileCollision; block.elevation = openTileElevation; } map->setBlock(x, y, block, !fromScriptCall); - if (map->getBlock(x + 1, y, &block) && block.tile == old_tile) { + if (map->getBlock(x + 1, y, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x + 1, y)); } - if (map->getBlock(x - 1, y, &block) && block.tile == old_tile) { + if (map->getBlock(x - 1, y, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x - 1, y)); } - if (map->getBlock(x, y + 1, &block) && block.tile == old_tile) { + if (map->getBlock(x, y + 1, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x, y + 1)); } - if (map->getBlock(x, y - 1, &block) && block.tile == old_tile) { + if (map->getBlock(x, y - 1, &block) && block.metatileId == old_metatileId) { todo.append(QPoint(x, y - 1)); } } @@ -595,7 +595,7 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri if (map->getBlock(x - 1, y, &left) && IS_SMART_PATH_TILE(left)) id += 8; - block.tile = selectedMetatiles->at(smartPathTable[id]); + block.metatileId = selectedMetatiles->at(smartPathTable[id]); if (setCollisions) { block.collision = selectedCollisions->at(smartPathTable[id]).first; block.elevation = selectedCollisions->at(smartPathTable[id]).second; @@ -630,7 +630,7 @@ void MapPixmapItem::pick(QGraphicsSceneMouseEvent *event) { QPoint pos = Metatile::coordFromPixmapCoord(event->pos()); Block block; if (map->getBlock(pos.x(), pos.y(), &block)) { - this->metatileSelector->selectFromMap(block.tile, block.collision, block.elevation); + this->metatileSelector->selectFromMap(block.metatileId, block.collision, block.elevation); } } diff --git a/src/ui/metatilelayersitem.cpp b/src/ui/metatilelayersitem.cpp index 2f5f8b80..26c8c257 100644 --- a/src/ui/metatilelayersitem.cpp +++ b/src/ui/metatilelayersitem.cpp @@ -26,7 +26,7 @@ void MetatileLayersItem::draw() { int numTiles = isTripleLayerMetatile ? 12 : 8; for (int i = 0; i < numTiles; i++) { Tile tile = this->metatile->tiles.at(i); - QImage tileImage = getPalettedTileImage(tile.tile, this->primaryTileset, this->secondaryTileset, tile.palette, true) + QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true) .mirrored(tile.xflip, tile.yflip) .scaled(16, 16); painter.drawImage(tileCoords.at(i), tileImage); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 1364aebf..f2499b8d 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -319,7 +319,7 @@ void TilesetEditor::drawSelectedTiles() { int tileIndex = 0; for (int j = 0; j < dimensions.y(); j++) { for (int i = 0; i < dimensions.x(); i++) { - QImage tileImage = getPalettedTileImage(tiles.at(tileIndex).tile, this->primaryTileset, this->secondaryTileset, tiles.at(tileIndex).palette, true) + QImage tileImage = getPalettedTileImage(tiles.at(tileIndex).tileId, this->primaryTileset, this->secondaryTileset, tiles.at(tileIndex).palette, true) .mirrored(tiles.at(tileIndex).xflip, tiles.at(tileIndex).yflip) .scaled(16, 16); tileIndex++; @@ -406,7 +406,7 @@ void TilesetEditor::onMetatileLayerTileChanged(int x, int y) { && tileCoords.at(tileIndex).x() >= x && tileCoords.at(tileIndex).y() >= y){ Tile &tile = this->metatile->tiles[tileIndex]; - tile.tile = tiles.at(selectedTileIndex).tile; + tile.tileId = tiles.at(selectedTileIndex).tileId; tile.xflip = tiles.at(selectedTileIndex).xflip; tile.yflip = tiles.at(selectedTileIndex).yflip; tile.palette = tiles.at(selectedTileIndex).palette; @@ -442,9 +442,9 @@ void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int } if (width == 1 && height == 1) { - this->tileSelector->highlight(static_cast(tiles[0].tile)); + this->tileSelector->highlight(static_cast(tiles[0].tileId)); ui->spinBox_paletteSelector->setValue(tiles[0].palette); - QPoint pos = tileSelector->getTileCoordsOnWidget(static_cast(tiles[0].tile)); + QPoint pos = tileSelector->getTileCoordsOnWidget(static_cast(tiles[0].tileId)); ui->scrollArea_Tiles->ensureVisible(pos.x(), pos.y()); } this->tileSelector->setExternalSelection(width, height, tiles, tileIdxs); @@ -979,20 +979,20 @@ void TilesetEditor::countMetatileUsage() { // for each block in the layout, mark in the vector that it is used for (int i = 0; i < layout->blockdata.length(); i++) { - uint16_t tile = layout->blockdata.at(i).tile; - if (tile < this->project->getNumMetatilesPrimary()) { - if (usesPrimary) metatileSelector->usedMetatiles[tile]++; + uint16_t metatileId = layout->blockdata.at(i).metatileId; + if (metatileId < this->project->getNumMetatilesPrimary()) { + if (usesPrimary) metatileSelector->usedMetatiles[metatileId]++; } else { - if (usesSecondary) metatileSelector->usedMetatiles[tile]++; + if (usesSecondary) metatileSelector->usedMetatiles[metatileId]++; } } for (int i = 0; i < layout->border.length(); i++) { - uint16_t tile = layout->border.at(i).tile; - if (tile < this->project->getNumMetatilesPrimary()) { - if (usesPrimary) metatileSelector->usedMetatiles[tile]++; + uint16_t metatileId = layout->border.at(i).metatileId; + if (metatileId < this->project->getNumMetatilesPrimary()) { + if (usesPrimary) metatileSelector->usedMetatiles[metatileId]++; } else { - if (usesSecondary) metatileSelector->usedMetatiles[tile]++; + if (usesSecondary) metatileSelector->usedMetatiles[metatileId]++; } } } @@ -1024,8 +1024,8 @@ void TilesetEditor::countTileUsage() { for (Tileset *tileset : primaryTilesets) { for (Metatile *metatile : tileset->metatiles) { for (Tile tile : metatile->tiles) { - if (tile.tile >= Project::getNumTilesPrimary()) - this->tileSelector->usedTiles[tile.tile]++; + if (tile.tileId >= Project::getNumTilesPrimary()) + this->tileSelector->usedTiles[tile.tileId]++; } } } @@ -1034,8 +1034,8 @@ void TilesetEditor::countTileUsage() { for (Tileset *tileset : secondaryTilesets) { for (Metatile *metatile : tileset->metatiles) { for (Tile tile : metatile->tiles) { - if (tile.tile < Project::getNumTilesPrimary()) - this->tileSelector->usedTiles[tile.tile]++; + if (tile.tileId < Project::getNumTilesPrimary()) + this->tileSelector->usedTiles[tile.tileId]++; } } } @@ -1043,14 +1043,14 @@ void TilesetEditor::countTileUsage() { // check this primary tileset metatiles for (Metatile *metatile : this->primaryTileset->metatiles) { for (Tile tile : metatile->tiles) { - this->tileSelector->usedTiles[tile.tile]++; + this->tileSelector->usedTiles[tile.tileId]++; } } // and the secondary metatiles for (Metatile *metatile : this->secondaryTileset->metatiles) { for (Tile tile : metatile->tiles) { - this->tileSelector->usedTiles[tile.tile]++; + this->tileSelector->usedTiles[tile.tileId]++; } } }