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

Pre-assigned palette with wildcard support for palette packing. More...

#include <prefilled_palette.hpp>

Public Member Functions

bool operator== (const PrefilledPalette &other) const
 
std::strong_ordering operator<=> (const PrefilledPalette &other) const
 
std::size_t hardware_index () const
 
const ColorSetfixed_colors () const
 
std::size_t fixed_color_count () const
 
std::size_t occupied_slots () const
 
std::size_t available_capacity () const
 
bool is_fully_locked () const
 
bool can_accommodate (const ColorSet &tile_colors) const
 Checks if a tile's colors can be accommodated by this palette.
 

Static Public Member Functions

static PrefilledPalette fully_locked (std::size_t hardware_index, ColorSet color_set, std::size_t occupied_slots)
 Creates a fully locked PrefilledPalette.
 
static PrefilledPalette partially_locked (std::size_t hardware_index, ColorSet fixed_colors, std::size_t occupied_slots, std::size_t total_capacity=pal::max_size - 1)
 Creates a partially locked palette with available capacity.
 

Detailed Description

Pre-assigned palette with wildcard support for palette packing.

PrefilledPalette represents a hardware palette that has some or all of its slots pre-assigned. This is used for:

  • Primary palette reuse: Fixed colors from primary tileset; secondary tiles can use the palette if their colors are subsets
  • Partial override: User locks some colors (e.g., DNS window colors) but allows the packer to fill remaining slots
  • Fully locked: Override specifies entire palette, no room for additional colors

Use the static factory methods to construct instances.

Definition at line 25 of file prefilled_palette.hpp.

Member Function Documentation

◆ available_capacity()

std::size_t porytiles::PrefilledPalette::available_capacity ( ) const
inline

Definition at line 91 of file prefilled_palette.hpp.

◆ can_accommodate()

bool porytiles::PrefilledPalette::can_accommodate ( const ColorSet tile_colors) const

Checks if a tile's colors can be accommodated by this palette.

A tile can be accommodated if:

  • Its colors are a subset of the fixed colors (always works), OR
  • The new colors (colors not already fixed) fit in the available capacity
Parameters
tile_colorsThe tile's colors to check
Returns
true if the tile can use this palette, false otherwise

Definition at line 35 of file prefilled_palette.cpp.

◆ fixed_color_count()

std::size_t porytiles::PrefilledPalette::fixed_color_count ( ) const

Definition at line 30 of file prefilled_palette.cpp.

◆ fixed_colors()

const ColorSet & porytiles::PrefilledPalette::fixed_colors ( ) const
inline

Definition at line 79 of file prefilled_palette.hpp.

◆ fully_locked()

PrefilledPalette porytiles::PrefilledPalette::fully_locked ( std::size_t  hardware_index,
ColorSet  color_set,
std::size_t  occupied_slots 
)
static

Creates a fully locked PrefilledPalette.

A fully locked palette has all its color slots occupied. The packer cannot add any new colors to this palette. Tiles can only use this palette if their colors are already a subset of the fixed colors.

Parameters
hardware_indexThe hardware palette index
color_setThe fixed colors occupying all slots
occupied_slotsThe number of physical slots occupied in the palette (may differ from unique color count if palette contains duplicate colors)
Returns
A fully locked PrefilledPalette

Definition at line 15 of file prefilled_palette.cpp.

◆ hardware_index()

std::size_t porytiles::PrefilledPalette::hardware_index ( ) const
inline

Definition at line 74 of file prefilled_palette.hpp.

◆ is_fully_locked()

bool porytiles::PrefilledPalette::is_fully_locked ( ) const
inline

Definition at line 96 of file prefilled_palette.hpp.

◆ occupied_slots()

std::size_t porytiles::PrefilledPalette::occupied_slots ( ) const
inline

Definition at line 86 of file prefilled_palette.hpp.

◆ operator<=>()

std::strong_ordering porytiles::PrefilledPalette::operator<=> ( const PrefilledPalette other) const
inline

Definition at line 69 of file prefilled_palette.hpp.

◆ operator==()

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

Definition at line 64 of file prefilled_palette.hpp.

◆ partially_locked()

PrefilledPalette porytiles::PrefilledPalette::partially_locked ( std::size_t  hardware_index,
ColorSet  fixed_colors,
std::size_t  occupied_slots,
std::size_t  total_capacity = pal::max_size - 1 
)
static

Creates a partially locked palette with available capacity.

A partially locked palette has some colors fixed but still has room for the packer to add more colors. The available capacity is computed as total_capacity - occupied_slots.

Parameters
hardware_indexThe hardware palette index
fixed_colorsThe colors that are already locked in this palette
occupied_slotsThe number of physical slots occupied in the palette (may differ from unique color count if palette contains duplicate colors)
total_capacityThe total number of color slots (default pal::max_size - 1)
Returns
A partially locked PrefilledPalette
Precondition
occupied_slots <= total_capacity

Definition at line 20 of file prefilled_palette.cpp.


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