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

Wraps a ColorSet with a tile ID for tracking during palette packing. More...

#include <packable_tile.hpp>

Classes

struct  AnimId
 Identifies a tile created from an animation. More...
 
struct  HintId
 Identifies a tile created from a palette hint. More...
 
class  PrefilledPaletteId
 Identifies a tile created from a prefilled palette. More...
 
struct  PrimaryTileId
 Identifies a tile reconstructed from a compiled primary tileset. More...
 
struct  RegularId
 Identifies a regular input tile. More...
 

Public Types

using Id = std::variant< HintId, PrefilledPaletteId, RegularId, AnimId, PrimaryTileId >
 Variant type for tile identification.
 

Public Member Functions

 PackableTile (HintId id, ColorSet color_set)
 Constructs a PackableTile from a palette hint.
 
 PackableTile (PrefilledPaletteId id, ColorSet color_set)
 Constructs a PackableTile from a prefilled palette.
 
 PackableTile (RegularId id, ColorSet color_set)
 Constructs a PackableTile from a regular input tile.
 
 PackableTile (AnimId id, ColorSet color_set)
 Constructs a PackableTile from an animation.
 
 PackableTile (PrimaryTileId id, ColorSet color_set)
 Constructs a PackableTile from a reconstructed primary tile.
 
 PackableTile (Id id, ColorSet color_set)
 Constructs a PackableTile from an Id variant.
 
const Idid () const
 
const std::string & hint_name () const
 
std::size_t prefilled_index () const
 
std::size_t regular_index () const
 
bool is_hint () const
 
bool is_prefilled_palette () const
 
bool is_regular () const
 
const ColorSetcolor_set () const
 
std::size_t color_count () const
 
auto operator<=> (const PackableTile &other) const
 Three-way comparison operator.
 
bool operator== (const PackableTile &other) const
 Equality comparison operator.
 

Detailed Description

Wraps a ColorSet with a tile ID for tracking during palette packing.

PackableTile represents a tile that needs to be assigned to a hardware palette. It associates a unique tile ID with the set of colors present in that tile, enabling the palette packer to track which tiles have been assigned to which palettes.

Several types of tiles are supported:

  • HintId: Tiles created from PaletteHints, identified by a string name
  • PrefilledPaletteId: Tiles created from PrefilledPalettes, identified by palette index
  • RegularId: Regular input tiles, identified by tile index
  • AnimId: Tiles created from animations, identified by name and subtile index
  • PrimaryTileId: Tiles reconstructed from a compiled primary tileset for cross-tileset shape group analysis, identified by tile index and known palette assignment

PackableTiles are sortable with the following order:

  1. Hint tiles (lexicographic by name)
  2. Prefilled palette tiles (ascending by index)
  3. Regular tiles (ascending by index)

Definition at line 35 of file packable_tile.hpp.

Member Typedef Documentation

◆ Id

Variant type for tile identification.

The order of alternatives determines sorting: HintId < PrefilledPaletteId < RegularId < AnimId < PrimaryTileId.

Definition at line 115 of file packable_tile.hpp.

Constructor & Destructor Documentation

◆ PackableTile() [1/6]

porytiles::PackableTile::PackableTile ( HintId  id,
ColorSet  color_set 
)

Constructs a PackableTile from a palette hint.

Parameters
idThe hint identifier
color_setThe set of colors present in this tile

Definition at line 10 of file packable_tile.cpp.

◆ PackableTile() [2/6]

porytiles::PackableTile::PackableTile ( PrefilledPaletteId  id,
ColorSet  color_set 
)

Constructs a PackableTile from a prefilled palette.

Parameters
idThe prefilled palette identifier
color_setThe set of colors present in this tile

Definition at line 12 of file packable_tile.cpp.

◆ PackableTile() [3/6]

porytiles::PackableTile::PackableTile ( RegularId  id,
ColorSet  color_set 
)

Constructs a PackableTile from a regular input tile.

Parameters
idThe regular tile identifier
color_setThe set of colors present in this tile

Definition at line 14 of file packable_tile.cpp.

◆ PackableTile() [4/6]

porytiles::PackableTile::PackableTile ( AnimId  id,
ColorSet  color_set 
)

Constructs a PackableTile from an animation.

Parameters
idThe anim identifier
color_setThe set of colors present in this tile

Definition at line 16 of file packable_tile.cpp.

◆ PackableTile() [5/6]

porytiles::PackableTile::PackableTile ( PrimaryTileId  id,
ColorSet  color_set 
)

Constructs a PackableTile from a reconstructed primary tile.

Parameters
idThe primary tile identifier
color_setThe set of colors present in this tile

Definition at line 18 of file packable_tile.cpp.

◆ PackableTile() [6/6]

porytiles::PackableTile::PackableTile ( Id  id,
ColorSet  color_set 
)

Constructs a PackableTile from an Id variant.

This constructor allows direct construction from a type-erased Id variant, useful when the specific ID type is not known at compile time (e.g., when reconstructing tiles from stored IDs).

Parameters
idThe tile identifier variant
color_setThe set of colors present in this tile

Definition at line 20 of file packable_tile.cpp.

Member Function Documentation

◆ color_count()

std::size_t porytiles::PackableTile::color_count ( ) const

Definition at line 37 of file packable_tile.cpp.

◆ color_set()

const ColorSet & porytiles::PackableTile::color_set ( ) const
inline

Definition at line 198 of file packable_tile.hpp.

◆ hint_name()

const std::string & porytiles::PackableTile::hint_name ( ) const

Definition at line 22 of file packable_tile.cpp.

◆ id()

const Id & porytiles::PackableTile::id ( ) const
inline

Definition at line 169 of file packable_tile.hpp.

◆ is_hint()

bool porytiles::PackableTile::is_hint ( ) const
inline

Definition at line 183 of file packable_tile.hpp.

◆ is_prefilled_palette()

bool porytiles::PackableTile::is_prefilled_palette ( ) const
inline

Definition at line 188 of file packable_tile.hpp.

◆ is_regular()

bool porytiles::PackableTile::is_regular ( ) const
inline

Definition at line 193 of file packable_tile.hpp.

◆ operator<=>()

auto porytiles::PackableTile::operator<=> ( const PackableTile other) const
inline

Three-way comparison operator.

Compares tiles by their Id only. The variant ordering ensures hint tiles come first, then prefilled palette tiles, then regular tiles.

Parameters
otherThe tile to compare against
Returns
The ordering relationship

Definition at line 215 of file packable_tile.hpp.

◆ operator==()

bool porytiles::PackableTile::operator== ( const PackableTile other) const
inline

Equality comparison operator.

Parameters
otherThe tile to compare against
Returns
true if the tiles have the same Id

Definition at line 226 of file packable_tile.hpp.

◆ prefilled_index()

std::size_t porytiles::PackableTile::prefilled_index ( ) const

Definition at line 27 of file packable_tile.cpp.

◆ regular_index()

std::size_t porytiles::PackableTile::regular_index ( ) const

Definition at line 32 of file packable_tile.cpp.


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