Porytiles
Loading...
Searching...
No Matches
porytiles::AnimDecompiler Class Reference

Decompiles indexed animation tiles to RGBA format. More...

#include <anim_decompiler.hpp>

Public Member Functions

 AnimDecompiler (gsl::not_null< const DomainConfig * > config, gsl::not_null< const UserDiagnostics * > diag, gsl::not_null< const TilePrinter * > tile_printer, gsl::not_null< const PalettePrinter * > pal_printer)
 
ChainableResult< Animation< Rgba32 > > decompile_animation (const std::string &tileset_name, const Animation< IndexPixel > &anim, const std::set< PixelTile< IndexPixel > > &inter_anim_canonical_tiles, PorymapTilesetComponent &porymap_component) const
 Decompiles an IndexPixel animation to Rgba32 format.
 

Detailed Description

Decompiles indexed animation tiles to RGBA format.

AnimDecompiler converts Animation<IndexPixel> (from Porymap format) to Animation<Rgba32> (for Porytiles format). This is used during tileset import to extract animation keyframe tiles from tiles.png and convert them to RGBA format suitable for storage in the Porytiles component.

The decompiler uses the tileset's palettes to look up the actual RGBA colors for each palette index. Since animation keyframe tiles may use any palette in the tileset, the decompiler requires access to all palettes.

The correct palette for each animation is determined by the configured AnimPalResolutionStrategy, which drives the behavior from the start (strategy-first). Available strategies include direct palette selection (palette_00 through palette_15), local metatile scanning (scan_local_metatiles), and PNG internal palette matching (internal_png_pal).

Configuration values (extrinsic transparency, palette strategy, key frame strategy) are resolved internally from the provided DomainConfig, including per-animation palette strategy overrides.

Definition at line 43 of file anim_decompiler.hpp.

Constructor & Destructor Documentation

◆ AnimDecompiler()

porytiles::AnimDecompiler::AnimDecompiler ( gsl::not_null< const DomainConfig * >  config,
gsl::not_null< const UserDiagnostics * >  diag,
gsl::not_null< const TilePrinter * >  tile_printer,
gsl::not_null< const PalettePrinter * >  pal_printer 
)
inlineexplicit

Definition at line 45 of file anim_decompiler.hpp.

Member Function Documentation

◆ decompile_animation()

ChainableResult< Animation< Rgba32 > > porytiles::AnimDecompiler::decompile_animation ( const std::string &  tileset_name,
const Animation< IndexPixel > &  anim,
const std::set< PixelTile< IndexPixel > > &  inter_anim_canonical_tiles,
PorymapTilesetComponent porymap_component 
) const

Decompiles an IndexPixel animation to Rgba32 format.

Converts each tile in each frame of the animation from IndexPixel to Rgba32 using the palettes from porymap_component. Configuration values (extrinsic transparency, palette resolution strategy, key frame resolution strategy) are unwrapped internally from the DomainConfig provided at construction. Per-animation palette strategy overrides are resolved automatically.

Key frame tiles are extracted from tiles_png at the animation's tile_offset position, decompiled to RGBA using the resolved palette, and set on the result animation.

If duplicate key frame tiles are detected, the behavior depends on the configured key frame strategy:

  • error: Returns an error with details about which tiles are duplicates.
  • mangle: Modifies duplicate tiles to make them unique and backports changes to tiles.png via porymap_component.
Parameters
tileset_nameThe name of the tileset being decompiled (used for config scoping).
animThe indexed animation to decompile.
inter_anim_canonical_tilesCanonical forms of previously-processed animations' key frame tiles, used to detect inter-animation duplicates. Pass an empty set when processing the first animation.
porymap_componentThe Porymap component to read pals/metatiles/tiles from and backport tile changes to.
Returns
The decompiled RGBA animation with key frame and frames populated, or error.

Definition at line 608 of file anim_decompiler.cpp.


The documentation for this class was generated from the following files: