Porytiles
Loading...
Searching...
No Matches
porytiles2::details Namespace Reference

Functions

template<SupportsTransparency ColorType, typename TransparencyPredicate >
PaletteMatchResult< ColorType > match_tile_to_palette_impl (const PixelTile< ColorType > &tile, const Palette< ColorType > &palette, TransparencyPredicate is_transparent_pred)
 Helper function implementing the core palette matching logic.
 
template<SupportsTransparency PixelType, typename TransparencyPredicate >
ShapeTile< ColorIndexfrom_pixel_tile_impl (const PixelTile< PixelType > &pixel_tile, const ColorIndexMap< PixelType > &color_index_map, TransparencyPredicate is_transparent_pred)
 Helper function implementing the core PixelTile to ShapeTile conversion logic.
 
template<typename T , typename ConfigInterface , typename FetchFunc , typename Comparator >
ChainableResult< ConfigValue< T > > compare_values (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other, Comparator comp, std::string_view error_message)
 Generic comparison validator that compares the current value against another config value.
 

Function Documentation

◆ compare_values()

template<typename T , typename ConfigInterface , typename FetchFunc , typename Comparator >
ChainableResult< ConfigValue< T > > porytiles2::details::compare_values ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other,
Comparator  comp,
std::string_view  error_message 
)

Generic comparison validator that compares the current value against another config value.

This is the generic implementation for all cross-field comparison validators. It fetches another config value using the provided lambda and performs a comparison using the provided comparator. If the comparison fails, returns a detailed error message showing both values and their sources. This function is used internally by the public comparison validator functions.

Template Parameters
TThe type of the config values being compared (must support the comparator's operation)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
ComparatorCallable type that performs the comparison (e.g., std::greater<>, std::less<>)
Parameters
valThe config value being validated
configThe config interface to fetch other values from
scope_paramThe scope parameter (tileset or layout name)
other_field_nameThe name of the other field to compare against
fetch_otherCallable that fetches the other config value
compComparator that performs the comparison operation
error_messageThe error message to display if validation fails (e.g., "must be greater than")
Returns
ChainableResult containing either the original value or an error

Definition at line 80 of file config_validators.hpp.

◆ from_pixel_tile_impl()

template<SupportsTransparency PixelType, typename TransparencyPredicate >
ShapeTile< ColorIndex > porytiles2::details::from_pixel_tile_impl ( const PixelTile< PixelType > &  pixel_tile,
const ColorIndexMap< PixelType > &  color_index_map,
TransparencyPredicate  is_transparent_pred 
)

Helper function implementing the core PixelTile to ShapeTile conversion logic.

This private helper contains the common conversion logic shared by both from_pixel_tile() overloads. It accepts a transparency predicate (function/lambda) that determines whether a pixel is transparent, allowing the same implementation to work with both intrinsic and extrinsic transparency checking.

Template Parameters
PixelTypeThe pixel type of the input tile
TransparencyPredicateA callable type that takes a PixelType and returns bool
Parameters
pixel_tileThe PixelTile to convert
color_index_mapThe ColorIndexMap providing color-to-index mappings
is_transparent_predA predicate function that returns true if a pixel is transparent
Precondition
All non-transparent pixels in pixel_tile must be present in color_index_map
Returns
A ShapeTile<ColorIndex> with ShapeMasks mapped to color indices

Definition at line 33 of file tile_converters.hpp.

◆ match_tile_to_palette_impl()

template<SupportsTransparency ColorType, typename TransparencyPredicate >
PaletteMatchResult< ColorType > porytiles2::details::match_tile_to_palette_impl ( const PixelTile< ColorType > &  tile,
const Palette< ColorType > &  palette,
TransparencyPredicate  is_transparent_pred 
)

Helper function implementing the core palette matching logic.

This private helper contains the common matching logic shared by both match_tile_to_palette() overloads. It accepts a transparency predicate (function/lambda) that determines whether a pixel is transparent, allowing the same implementation to work with both intrinsic and extrinsic transparency checking.

The algorithm:

  1. Extracts all unique non-transparent colors from the tile
  2. For each color, checks if it exists in the palette
  3. Categorizes colors as either "covered" (found in palette) or "missing" (not in palette)
  4. Sets is_covered to true if no colors are missing
Template Parameters
ColorTypeThe color type of the palette and tile
TransparencyPredicateA callable type that takes a ColorType and returns bool
Parameters
tileThe PixelTile to match against the palette
paletteThe Palette to check for color coverage
is_transparent_predA predicate function that returns true if a color is transparent
Returns
A PaletteMatchResult indicating coverage status and color sets

Definition at line 79 of file palette_matchers.hpp.