From 476d0cbc6c7277c70e5e369f1239dabeacf97f66 Mon Sep 17 00:00:00 2001 From: grunt-lucas Date: Thu, 10 Aug 2023 13:44:47 -0700 Subject: [PATCH] Copy metadata into norm tile --- include/types.h | 16 +++++++++++----- src/compiler.cpp | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/types.h b/include/types.h index 8c876706..5f8b9003 100644 --- a/include/types.h +++ b/include/types.h @@ -452,11 +452,6 @@ struct NormalizedTile { bool hFlip; bool vFlip; - /* - * TODO : create a way to populate these fields, and then do so at NormTile creation time. We will also need to - * propogate the LayerType forward into assignment field of the compiledTileset, so the metatile attributes emitter - * can use it. - */ /* * Metadata Fields: * These are used by the various components to track metadata around the usage context of a NormalizedTile. Allows @@ -483,6 +478,17 @@ struct NormalizedTile { frames.resize(1); } + void copyMetadataFrom(const RGBATile &tile) + { + this->type = tile.type; + this->tileIndex = tile.tileIndex; + this->layerType = tile.layerType; + this->layer = tile.layer; + this->metatileIndex = tile.metatileIndex; + this->subtile = tile.subtile; + this->anim = tile.anim; + } + [[nodiscard]] bool transparent() const { return palette.size == 1; } void setPixel(std::size_t frame, std::size_t row, std::size_t col, uint8_t value) diff --git a/src/compiler.cpp b/src/compiler.cpp index 2b98dd61..49caaf4b 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -163,6 +163,7 @@ static std::vector normalizeDecompTiles(PtContext &ctx, const D } DecompiledIndex index{}; auto normalizedTile = normalize(ctx, multiFrameTile); + normalizedTile.copyMetadataFrom(multiFrameTile.at(0)); index.animated = true; index.animIndex = animIndex; index.tileIndex = tileIndex; @@ -174,6 +175,7 @@ static std::vector normalizeDecompTiles(PtContext &ctx, const D for (const auto &tile : decompiledTileset.tiles) { std::vector singleFrameTile = {tile}; auto normalizedTile = normalize(ctx, singleFrameTile); + normalizedTile.copyMetadataFrom(tile); DecompiledIndex index{}; index.tileIndex = tileIndex++; normalizedTiles.emplace_back(index, normalizedTile);