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

Namespaces

namespace  attr
 
namespace  detail
 
namespace  details
 
namespace  di
 
namespace  metatile
 
namespace  pal
 
namespace  tile
 
namespace  tileset
 

Classes

class  AnsiStyledTextFormatter
 TextFormatter implementation that applies ANSI escape codes for terminal styling. More...
 
class  AppConfig
 Interface that defines a complete app layer configuration. More...
 
class  ArtifactChecksumProvider
 Abstract service for managing artifact checksums. More...
 
class  ArtifactKey
 A type-safe wrapper for artifact keys. More...
 
class  AsciiTilePrinter
 A TilePrinter implementation that generates ASCII art tiles with formatting based on the provided TextFormatter. More...
 
class  AssetGenerator
 
class  Bin
 
class  BufferedUserDiagnostics
 Testing implementation of UserDiagnostics that buffers all diagnostic output. More...
 
class  CanonicalPixelTile
 A PixelTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants. More...
 
class  CanonicalShapeTile
 A ShapeTile representation that stores the canonical (lexicographically minimal) orientation among all flipped variants. More...
 
class  ChainableResult
 A result type that maintains a chainable sequence of errors for debugging and error reporting. More...
 
class  ChainableResult< void, E >
 Template specialization of ChainableResult for void success type. More...
 
class  ColorIndex
 Represents a color index value for palette operations. More...
 
class  ColorIndexMap
 A bidirectional mapping between pixel color values and sequential integer indices. More...
 
class  ColorSet
 A set of colors represented as a bitset. More...
 
class  ColorSetBuilder
 Service that builds a ColorSet from a NormalizedPal using a pre-defined color index map. More...
 
class  CompilePrimaryTileset
 Use case for compiling a primary Tileset. More...
 
class  ConfigProvider
 An interface which config implementations can use to load config values. More...
 
class  ConfigValue
 A container that wraps a configuration value with its name and source information. More...
 
class  CreatePrimaryTileset
 Use case for creating a primary Tileset. More...
 
class  DefaultProvider
 A default implementation of ConfigProvider that provides sensible default values. More...
 
class  DomainConfig
 Interface that defines a complete domain layer configuration. More...
 
class  Error
 Abstract interface for all error types used in ChainableResult error chains. More...
 
class  FilePalLoader
 A service interface that loads a Palette from a given file. More...
 
class  FilePalSaver
 A service interface that saves a Palette to a given file. More...
 
class  FormatParam
 A text parameter with associated styling for formatted output. More...
 
class  FormattableError
 General-purpose error implementation with formatted message support. More...
 
class  Image
 A template for two-dimensional images with arbitrarily typed pixel values. More...
 
class  ImageLoadError
 
class  ImageTileizer
 Service for converting images into collections of 8x8 tiles. More...
 
class  ImportPrimaryTileset
 Use case for importing a primary Tileset. More...
 
class  IndexPixel
 Represents an indexed color pixel. More...
 
class  InfraConfig
 Interface that defines a complete infra layer configuration. More...
 
class  JascPalLoader
 An implementation of FilePalLoader that loads palettes from JASC-PAL (Paintshop Pro) pal files. More...
 
class  JascPalSaver
 An implementation of FilePalSaver that saves palettes to JASC-PAL (Paintshop Pro) pal files. More...
 
class  LayerImageMetatileizer
 Service for converting layer images into collections of metatiles. More...
 
class  LayerModeConverter
 
struct  LayerValue
 A small container that holds an optional-wrapped value, validation state, and metadata about the value source. More...
 
class  LazyLayeredConfig
 A Config implementation that lazily pulls a config value by consulting multiple priority-ordered backing ConfigProviders . More...
 
class  Metatile
 The core tileset entity - a 2x2 grid of PixelTile objects arranged into three layers. More...
 
class  MetatileAttribute
 
class  MetatileDecompiler
 
class  NoopArtifactChecksumProvider
 An implementation of ArtifactChecksumProvider that just does nothing. More...
 
class  OperandBundle
 A type-erased container for orchestration operands with runtime type checking. More...
 
class  OperandDeclaration
 A specification for operands required or produced by orchestration operations. More...
 
class  Operation
 Abstract base class for operations in a processing pipeline. More...
 
class  PackBin
 
class  PackSet
 
class  PackSetGenerator
 
class  Palette
 A palette container for colors that support transparency checking. More...
 
struct  PaletteMatchResult
 Result type for palette matching operations. More...
 
class  PalettePrinter
 A collection of printer functions for the Palette type. More...
 
class  Pipeline
 Manages and executes a collection of operations in dependency order. More...
 
class  PixelTile
 An 8x8 tile backed by literal-array-based per-pixel storage of an arbitrary pixel type. More...
 
class  PlainTextFormatter
 TextFormatter implementation that strips all styling from text. More...
 
class  PngIndexedImageLoader
 An image loader that reads PNG files to create an Image with an index pixel type. More...
 
class  PngIndexedImageSaver
 An image saver that saves PNG files from an Image with an index pixel type. More...
 
class  PngRgbaImageLoader
 An image loader that reads PNG files to create an Image with an Rgba32 pixel type. More...
 
class  PngRgbaImageSaver
 An image saver that saves PNG files from an Image with an Rgba32 pixel type. More...
 
class  PorymapLayoutComponent
 
class  PorymapTilesetComponent
 
class  PorytilesLayoutComponent
 
class  PorytilesTilesetComponent
 
class  PrimaryTilesetCompiler
 Service that compiles a primary Tileset. More...
 
class  ProjectArtifactChecksumProvider
 TODO: fill in doxygen. More...
 
class  ProjectTilesetArtifactKeyProvider
 Provides a pokeemerald project filesystem-based implementation for TilesetArtifactKeyProvider. More...
 
class  ProjectTilesetArtifactReader
 Provides a filesystem-based implementation for TilesetArtifactReader. More...
 
class  ProjectTilesetArtifactWriter
 Provides a filesystem-based implementation for TilesetArtifactWriter. More...
 
class  Rgba32
 Represents a 32-bit RGBA color. More...
 
class  ShapeMask
 Represents which pixels in an 8x8 tile are non-transparent. More...
 
class  ShapeTile
 An 8x8 tile backed by mask-based storage that maps shape regions to pixel values. More...
 
class  StderrStyledUserDiagnostics
 Concrete implementation of UserDiagnostics that outputs structured messages to stderr, optionally with colored formatting. More...
 
class  StreamDigest
 Computes the MD5 digest of an input stream. More...
 
struct  StringViewSourceLoc
 A wrapper for std::string_view with a taggable std::source_location. More...
 
class  TextFormatter
 Abstract base class for applying text styling with context-aware formatting. More...
 
class  TilemapEntry
 Represents a tilemap entry referencing a tile with palette and flip attributes. More...
 
class  TilePrinter
 A collection of printer functions for various tile types. More...
 
class  Tileset
 A complete tileset containing both Porytiles and Porymap components. More...
 
class  TilesetArtifact
 Represents a Pokémon Generation III decomp tileset artifact with type and optional metadata. More...
 
class  TilesetArtifactKeyProvider
 Abstract interface for generating keys and discovering tileset artifacts in a backing store. More...
 
class  TilesetArtifactReader
 Abstract interface for reading tileset artifacts from a backing store into a Tileset object. More...
 
class  TilesetArtifactWriter
 Abstract interface for writing tileset artifacts from a Tileset object to a backing store. More...
 
class  TilesetRepo
 Repository interface for the Tileset aggregate root. More...
 
class  TilesPngWorkspace
 A workspace for managing canonical IndexPixel tiles destined for tiles.png output. More...
 
class  TileValidator
 A collection of tile validation functions for compilation operations. More...
 
class  UserDiagnostics
 Abstract interface for structured error reporting and diagnostic output. More...
 
class  VerifyPrimaryTileset
 Use case for verifying a primary tileset. More...
 
class  YamlFileProvider
 A ConfigProvider implementation that reads configuration values from multiple YAML files with priority. More...
 

Concepts

concept  SupportsTransparency
 Concept that requires a type to support transparency checks.
 

Typedefs

template<typename T , typename E = std::string>
using Result = std::expected< T, E >
 A result with some type T on success, otherwise an error of type E.
 
using FormattedMessageBuilder = std::function< std::vector< std::string >(const TextFormatter &)>
 Function type for building formatted messages with TextFormatter access.
 

Enumerations

enum class  IncrementalBuildMode { off , keep_unused , remove_unused }
 
enum class  ValidationState { not_provided , valid , invalid }
 Represents the validation state of a configuration value from a ConfigProvider. More...
 
enum class  TilesPalMode { true_color , greyscale }
 
enum class  Style : std::uint32_t {
  none = 0 , bold = 1 << 0 , italic = 1 << 1 , red = 1 << 2 ,
  green = 1 << 3 , blue = 1 << 4 , yellow = 1 << 5 , cyan = 1 << 6 ,
  magenta = 1 << 7
}
 Bitmask flags for text styling options. More...
 

Functions

std::string to_string (const IncrementalBuildMode &value)
 
template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(); }
PaletteMatchResult< ColorType > match_tile_to_palette (const PixelTile< ColorType > &tile, const Palette< ColorType > &palette)
 Matches a PixelTile against a Palette (intrinsic transparency only).
 
template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(c); }
PaletteMatchResult< ColorType > match_tile_to_palette (const PixelTile< ColorType > &tile, const Palette< ColorType > &palette, const ColorType &extrinsic)
 Matches a PixelTile against a Palette (extrinsic transparency).
 
template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(c); }
std::vector< PaletteMatchResult< ColorType > > match_or_best (const PixelTile< ColorType > &tile, const std::vector< Palette< ColorType > > &palettes, const ColorType &extrinsic, std::size_t top_n)
 Finds the best palette match(es) for a tile (extrinsic transparency).
 
template<SupportsTransparency PixelType>
requires requires(const PixelType &p) { p.is_transparent(); }
ShapeTile< ColorIndexfrom_pixel_tile (const PixelTile< PixelType > &pixel_tile, const ColorIndexMap< PixelType > &color_index_map)
 Converts a PixelTile to a ShapeTile<ColorIndex> using a ColorIndexMap (intrinsic transparency).
 
template<SupportsTransparency PixelType>
requires requires(const PixelType &p) { p.is_transparent(p); }
ShapeTile< ColorIndexfrom_pixel_tile (const PixelTile< PixelType > &pixel_tile, const ColorIndexMap< PixelType > &color_index_map, const PixelType &extrinsic)
 Converts a PixelTile to a ShapeTile<ColorIndex> using a ColorIndexMap (extrinsic transparency).
 
template<SupportsTransparency PixelType>
PixelTile< PixelType > from_shape_tile (const ShapeTile< ColorIndex > &shape_tile, const ColorIndexMap< PixelType > &color_index_map)
 Converts a ShapeTile<ColorIndex> to a PixelTile using a ColorIndexMap.
 
template<SupportsTransparency PixelType>
ShapeTile< PixelType > shape_tile_to_pixel_colors (const ShapeTile< ColorIndex > &shape_tile, const ColorIndexMap< PixelType > &color_index_map)
 Converts a ShapeTile<ColorIndex> to a ShapeTile<PixelType> using a ColorIndexMap.
 
std::ostream & operator<< (std::ostream &os, const Rgba32 &rgba)
 Stream insertion operator for Rgba32.
 
auto format_as (const Rgba32 &rgba)
 Provides a simple way for fmtlib to format an Rgba32.
 
std::string to_string (const Rgba32 &rgba)
 
std::optional< TilesPalModetiles_pal_mode_from_str (const std::string &str)
 
std::string to_string (const TilesPalMode m)
 
std::ostream & operator<< (std::ostream &os, const TilesPalMode m)
 
template<typename T >
std::expected< T, std::string > parse_int (std::string_view int_string, const int base)
 
template<typename T >
std::expected< T, std::string > parse_int (std::string_view int_string)
 
constexpr uint8_t reverse_bits (uint8_t b)
 Reverses the bits in a byte.
 
std::string extract_function_name (const std::source_location &location=std::source_location::current())
 Extracts the function name from a source location.
 
bool check_full_string_match (const std::string &str, const std::string &pattern)
 Checks if a string fully matches a regular expression pattern.
 
void trim (std::string &string)
 Removes leading and trailing whitespace from a string in-place.
 
std::vector< std::string > split (std::string input, const std::string &delimiter)
 Splits a string into tokens based on a delimiter.
 
std::string & trim_line_ending (std::string &line)
 Removes line ending characters from a string in-place.
 
std::string trim_line_ending (const std::string &line)
 Removes line ending characters from a string.
 
constexpr Style operator| (Style lhs, Style rhs)
 Combines two Style flags using bitwise OR.
 
constexpr Style operator& (Style lhs, Style rhs)
 Masks Style flags using bitwise AND.
 
constexpr Styleoperator|= (Style &lhs, Style rhs)
 Adds Style flags to an existing Style value using bitwise OR.
 
constexpr Styleoperator&= (Style &lhs, Style rhs)
 Masks an existing Style value using bitwise AND.
 
constexpr bool has_style (Style styles, Style flag)
 Checks if a specific style flag is set in a Style value.
 
template<typename T , typename F >
auto transform (const std::vector< T > &input, F &&func) -> std::vector< std::invoke_result_t< F, const T & > >
 Transforms a vector of type T into a vector of type U using a mapping function.
 
template<typename U , typename T >
requires std::constructible_from<U, T>
auto transform (const std::vector< T > &input) -> std::vector< U >
 Transforms a vector of type T into a vector of type U using direct type construction.
 
ChainableResult< ConfigValue< std::size_t > > size_t_val_greater_than_zero (const ConfigValue< std::size_t > &val)
 Validates that a size_t config value is greater than zero.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_greater_than (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is greater than another config value.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_less_than (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is less than another config value.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_greater_equal (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is greater than or equal to another config value.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_less_equal (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is less than or equal to another config value.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_equal (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is equal to another config value.
 
template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > compare_not_equal (const ConfigValue< T > &val, const ConfigInterface &config, const std::string &scope_param, const std::string &other_field_name, FetchFunc fetch_other)
 Validates that the current value is not equal to another config value.
 
void panic (const StringViewSourceLoc &s)
 Unconditionally terminates the program with a panic message.
 
void assert_or_panic (const bool condition, const StringViewSourceLoc &s)
 Conditionally panics if the given condition is false.
 

Variables

constexpr std::size_t colors_per_pal = 16
 
constexpr std::size_t num_pals = 16
 
constexpr std::size_t num_colors = colors_per_pal * num_pals
 
constexpr Rgba32 rgba_black {0, 0, 0, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_white {255, 255, 255, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_grey {128, 128, 128, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_red {255, 0, 0, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_green {0, 255, 0, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_blue {0, 0, 255, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_yellow {255, 255, 0, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_magenta {255, 0, 255, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_cyan {0, 255, 255, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_purple {128, 0, 255, Rgba32::alpha_opaque}
 
constexpr Rgba32 rgba_lime {128, 255, 128, Rgba32::alpha_opaque}
 

Typedef Documentation

◆ FormattedMessageBuilder

using porytiles2::FormattedMessageBuilder = typedef std::function<std::vector<std::string>(const TextFormatter &)>

Function type for building formatted messages with TextFormatter access.

FormattedMessageBuilder is a function type that receives a TextFormatter reference and returns a vector of formatted message lines. This pattern is used in UserDiagnostics to allow diagnostic messages to be generated with appropriate styling based on the output context (TTY vs non-TTY).

The builder function can use the TextFormatter to style text dynamically, enabling conditional formatting that adapts to the output destination.

Example usage:

++
diag.warn("tag", [&name](const TextFormatter &fmt) {
return std::vector{fmt.format("Error in '{}'", FormatParam{name, Style::bold | Style::red})};
});
A text parameter with associated styling for formatted output.
Abstract base class for applying text styling with context-aware formatting.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > &params) const
Formats a string with styled parameters using fmtlib syntax.
@ bold
Bold text formatting.
@ red
Red text color.

Definition at line 329 of file text_formatter.hpp.

◆ Result

template<typename T , typename E = std::string>
using porytiles2::Result = typedef std::expected<T, E>

A result with some type T on success, otherwise an error of type E.

Many Porytiles operations need to return either an expected result or some description of what went wrong during result computation. This type alias is a convenient wrapper for the stdlib std::expected, which provides this exact functionality. The std::string error type will typically be some description of what went wrong. However, the alias supports a custom user type for the error type if a string is not sufficient.

Template Parameters
TThe type of the expected result
EThe error type, defaults to std::string

Definition at line 25 of file result.hpp.

Enumeration Type Documentation

◆ IncrementalBuildMode

Enumerator
off 
keep_unused 
remove_unused 

Definition at line 7 of file incremental_build_mode.hpp.

◆ Style

enum class porytiles2::Style : std::uint32_t
strong

Bitmask flags for text styling options.

Style is a bitmask enum that allows multiple styling attributes to be combined using bitwise operators. Each flag represents a distinct styling attribute that can be applied to text, such as bold formatting or color choices.

Styles can be combined using the bitwise OR operator (|) to apply multiple attributes simultaneously. For example, Style::bold | Style::red creates a style with both bold formatting and red color.

The enum uses an explicit uint32_t underlying type to ensure consistent bitmask behavior across platforms.

Enumerator
none 

No styling applied.

bold 

Bold text formatting.

italic 

Italic text formatting.

red 

Red text color.

green 

Green text color.

blue 

Blue text color.

yellow 

Yellow text color.

cyan 

Cyan text color.

magenta 

Magenta text color.

Definition at line 25 of file text_formatter.hpp.

◆ TilesPalMode

enum class porytiles2::TilesPalMode
strong
Enumerator
true_color 
greyscale 

Definition at line 10 of file tiles_pal_mode.hpp.

◆ ValidationState

enum class porytiles2::ValidationState
strong

Represents the validation state of a configuration value from a ConfigProvider.

This enum distinguishes between three different states when a ConfigProvider attempts to supply a configuration value:

  • not_provided: The provider does not supply this configuration value (try next provider)
  • valid: The provider supplies a valid configuration value (use this value)
  • invalid: The provider attempted to supply a value, but it failed validation (stop and report error)
Enumerator
not_provided 
valid 
invalid 

Definition at line 19 of file layer_value.hpp.

Function Documentation

◆ assert_or_panic()

void porytiles2::assert_or_panic ( const bool  condition,
const StringViewSourceLoc s 
)
inline

Conditionally panics if the given condition is false.

This function checks the provided condition and if it evaluates to false, formats and prints a panic message with source location information, then aborts the program. If the condition is true, the function returns normally.

Parameters
conditionThe condition to check
sThe StringViewSourceLoc containing the panic message and location

Definition at line 70 of file panic.hpp.

◆ check_full_string_match()

bool porytiles2::check_full_string_match ( const std::string &  str,
const std::string &  pattern 
)
inline

Checks if a string fully matches a regular expression pattern.

This function compiles the provided pattern into a regex and performs a full string match against the input string. Panics if the pattern is invalid.

Parameters
strThe string to match against the pattern
patternThe regular expression pattern
Precondition
pattern must be a valid regular expression
Returns
True if the entire string matches the pattern, false otherwise

Definition at line 25 of file string_utils.hpp.

◆ compare_equal()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_equal ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is equal to another config value.

Template Parameters
TThe type of the config values being compared (must support operator==)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 260 of file config_validators.hpp.

◆ compare_greater_equal()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_greater_equal ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is greater than or equal to another config value.

Template Parameters
TThe type of the config values being compared (must support operator>=)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 204 of file config_validators.hpp.

◆ compare_greater_than()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_greater_than ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is greater than another config value.

This cross-field validator compares the current config value against another config value. It fetches the other value using the provided lambda and performs a greater-than comparison. If the comparison fails, returns a detailed error message showing both values and their sources.

Template Parameters
TThe type of the config values being compared (must support operator>)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 154 of file config_validators.hpp.

◆ compare_less_equal()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_less_equal ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is less than or equal to another config value.

Template Parameters
TThe type of the config values being compared (must support operator<=)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 235 of file config_validators.hpp.

◆ compare_less_than()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_less_than ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is less than another config value.

Template Parameters
TThe type of the config values being compared (must support operator<)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 179 of file config_validators.hpp.

◆ compare_not_equal()

template<typename T , typename ConfigInterface , typename FetchFunc >
ChainableResult< ConfigValue< T > > porytiles2::compare_not_equal ( const ConfigValue< T > &  val,
const ConfigInterface &  config,
const std::string &  scope_param,
const std::string &  other_field_name,
FetchFunc  fetch_other 
)

Validates that the current value is not equal to another config value.

Template Parameters
TThe type of the config values being compared (must support operator!=)
ConfigInterfaceThe config interface type (DomainConfig, AppConfig, or InfraConfig)
FetchFuncCallable type that fetches the other config value
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
Returns
ChainableResult containing either the original value or an error

Definition at line 285 of file config_validators.hpp.

◆ extract_function_name()

std::string porytiles2::extract_function_name ( const std::source_location &  location = std::source_location::current())

Extracts the function name from a source location.

This function extracts the function name from a std::source_location and parses it to return just the simple function name without qualifiers, parameters, or return type.

For example, given:

  • GCC: "std::size_t porytiles2::LazyLayeredConfig::num_tiles_primary(const std::string&) const"
  • Clang: "porytiles2::LazyLayeredConfig::num_tiles_primary"

Both would return: "num_tiles_primary"

Parameters
locationThe source location from which to extract the function name (defaults to caller's location)
Returns
The simple function name without qualifiers

Definition at line 8 of file source_locations.cpp.

◆ format_as()

auto porytiles2::format_as ( const Rgba32 rgba)
inline

Provides a simple way for fmtlib to format an Rgba32.

https://fmt.dev/11.1/api/#formatting-user-defined-types

Definition at line 104 of file rgba32.hpp.

◆ from_pixel_tile() [1/2]

template<SupportsTransparency PixelType>
requires requires(const PixelType &p) { p.is_transparent(); }
ShapeTile< ColorIndex > porytiles2::from_pixel_tile ( const PixelTile< PixelType > &  pixel_tile,
const ColorIndexMap< PixelType > &  color_index_map 
)

Converts a PixelTile to a ShapeTile<ColorIndex> using a ColorIndexMap (intrinsic transparency).

This function creates a ShapeTile<ColorIndex> from a PixelTile by mapping each unique non-transparent color to its corresponding color index from the ColorIndexMap. For each color index, a ShapeMask is constructed that marks all pixel positions containing that color.

This overload is only available for pixel types that support intrinsic transparency (e.g., IndexPixel).

The conversion process:

  1. Iterates through all 64 pixels in the PixelTile
  2. Skips intrinsically transparent pixels
  3. For each non-transparent pixel, looks up its color index in the ColorIndexMap
  4. Panics if a non-transparent pixel is not found in the ColorIndexMap
  5. Builds ShapeMasks for each unique color index
  6. Returns a ShapeTile<ColorIndex> mapping ShapeMasks to color indices
Template Parameters
PixelTypeThe pixel type of the input tile, must support intrinsic transparency
Parameters
pixel_tileThe PixelTile to convert
color_index_mapThe ColorIndexMap providing color-to-index mappings
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 106 of file tile_converters.hpp.

◆ from_pixel_tile() [2/2]

template<SupportsTransparency PixelType>
requires requires(const PixelType &p) { p.is_transparent(p); }
ShapeTile< ColorIndex > porytiles2::from_pixel_tile ( const PixelTile< PixelType > &  pixel_tile,
const ColorIndexMap< PixelType > &  color_index_map,
const PixelType &  extrinsic 
)

Converts a PixelTile to a ShapeTile<ColorIndex> using a ColorIndexMap (extrinsic transparency).

This function creates a ShapeTile<ColorIndex> from a PixelTile by mapping each unique non-transparent color to its corresponding color index from the ColorIndexMap. For each color index, a ShapeMask is constructed that marks all pixel positions containing that color.

This overload is only available for pixel types that support extrinsic transparency (e.g., Rgba32). Transparency is determined using both intrinsic (alpha=0) and extrinsic (matching the provided value) checks.

The conversion process:

  1. Iterates through all 64 pixels in the PixelTile
  2. Skips pixels that are either intrinsically or extrinsically transparent
  3. For each non-transparent pixel, looks up its color index in the ColorIndexMap
  4. Panics if a non-transparent pixel is not found in the ColorIndexMap
  5. Builds ShapeMasks for each unique color index
  6. Returns a ShapeTile<ColorIndex> mapping ShapeMasks to color indices
Template Parameters
PixelTypeThe pixel type of the input tile, must support extrinsic transparency
Parameters
pixel_tileThe PixelTile to convert
color_index_mapThe ColorIndexMap providing color-to-index mappings
extrinsicThe extrinsic transparency value to check pixels against
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 140 of file tile_converters.hpp.

◆ from_shape_tile()

template<SupportsTransparency PixelType>
PixelTile< PixelType > porytiles2::from_shape_tile ( const ShapeTile< ColorIndex > &  shape_tile,
const ColorIndexMap< PixelType > &  color_index_map 
)

Converts a ShapeTile<ColorIndex> to a PixelTile using a ColorIndexMap.

This function creates a PixelTile<InputPixelType> from a ShapeTile<ColorIndex> by looking up the actual color for each ColorIndex in the ColorIndexMap and setting the corresponding pixels in the result tile.

The conversion process:

  1. Creates a default PixelTile<InputPixelType> (all pixels transparent)
  2. Iterates through each (ShapeMask, ColorIndex) pair in the ShapeTile
  3. Looks up the actual color from the ColorIndexMap using the ColorIndex
  4. Panics if a ColorIndex is not found in the ColorIndexMap
  5. For each bit set in the ShapeMask, sets the corresponding pixel in the PixelTile to that color
  6. Panics if masks overlap (indicates programmer error in ShapeTile construction)
  7. Returns the completed PixelTile
Template Parameters
PixelTypeThe pixel type of the output tile, must support transparency
Parameters
shape_tileThe ShapeTile<ColorIndex> to convert
color_index_mapThe ColorIndexMap providing index-to-color mappings
Precondition
All ColorIndex values in shape_tile must be present in color_index_map
ShapeMasks in shape_tile must not overlap
Returns
A PixelTile<PixelType> with pixels set according to the ShapeTile's masks and colors

Definition at line 173 of file tile_converters.hpp.

◆ has_style()

constexpr bool porytiles2::has_style ( Style  styles,
Style  flag 
)
constexpr

Checks if a specific style flag is set in a Style value.

Helper function that tests whether a particular style flag is present in a Style value. This is more readable than using the bitwise operators directly for boolean checks.

Parameters
stylesThe Style value to check
flagThe specific flag to test for
Returns
True if the flag is set, false otherwise

Definition at line 112 of file text_formatter.hpp.

◆ match_or_best()

template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(c); }
std::vector< PaletteMatchResult< ColorType > > porytiles2::match_or_best ( const PixelTile< ColorType > &  tile,
const std::vector< Palette< ColorType > > &  palettes,
const ColorType &  extrinsic,
std::size_t  top_n 
)

Finds the best palette match(es) for a tile (extrinsic transparency).

This function matches a tile against a vector of palettes and returns the best match(es):

  • If any palettes completely cover the tile, returns ALL complete matches (ignoring top_n)
  • If no palettes completely cover the tile, returns up to top_n best matches sorted by quality

Quality is determined by the number of missing_colors (fewer is better). If multiple palettes have the same number of missing colors, they maintain their original order in the palettes vector.

This overload supports both intrinsic (alpha=0) and extrinsic transparency checking. This overload is only available for color types that support extrinsic transparency.

Template Parameters
ColorTypeThe color type of the palette and tile, must support extrinsic transparency
Parameters
tileThe PixelTile to match against the palettes
palettesThe vector of Palettes to check for color coverage
extrinsicThe extrinsic transparency value to check pixels against
top_nMaximum number of results to return when no complete match exists (ignored if complete matches found)
Precondition
palettes is not empty
top_n > 0
All palettes are not empty
All palettes have extrinsic color in slot 0
Returns
A vector of PaletteMatchResult, either all complete matches or top_n best non-matches
Postcondition
The returned vector is non-empty and exhibits coverage homogeneity: all PaletteMatchResult elements possess identical is_covered values. This property enables deterministic match classification via examination of any single element, conventionally the first: results.at(0).is_covered. The function partitions the result space into two mutually exclusive sets—complete matches (is_covered = true) or partial matches (is_covered = false)—never returning a heterogeneous mixture.

Definition at line 220 of file palette_matchers.hpp.

◆ match_tile_to_palette() [1/2]

template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(); }
PaletteMatchResult< ColorType > porytiles2::match_tile_to_palette ( const PixelTile< ColorType > &  tile,
const Palette< ColorType > &  palette 
)

Matches a PixelTile against a Palette (intrinsic transparency only).

This function determines whether the provided palette contains all non-transparent colors present in the tile. Only intrinsically transparent pixels (those reporting true from parameterless is_transparent()) are treated as transparent.

This overload is only available for color types that support intrinsic transparency.

The matching process:

  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" or "missing"
  4. Returns a result indicating coverage status and the color sets
Template Parameters
ColorTypeThe color type of the palette and tile, must support intrinsic transparency
Parameters
tileThe PixelTile to match against the palette
paletteThe Palette to check for color coverage
Returns
A PaletteMatchResult indicating whether the palette covers the tile and which colors are covered/missing

Definition at line 143 of file palette_matchers.hpp.

◆ match_tile_to_palette() [2/2]

template<SupportsTransparency ColorType>
requires requires(const ColorType &c) { c.is_transparent(c); }
PaletteMatchResult< ColorType > porytiles2::match_tile_to_palette ( const PixelTile< ColorType > &  tile,
const Palette< ColorType > &  palette,
const ColorType &  extrinsic 
)

Matches a PixelTile against a Palette (extrinsic transparency).

This function determines whether the provided palette contains all non-transparent colors present in the tile. Both intrinsically transparent pixels (alpha=0) and extrinsically transparent pixels (matching the extrinsic parameter) are treated as transparent.

This overload is only available for color types that support extrinsic transparency.

Template Parameters
ColorTypeThe color type of the palette and tile, must support extrinsic transparency
Parameters
tileThe PixelTile to match against the palette
paletteThe Palette to check for color coverage
extrinsicThe extrinsic transparency value to check pixels against
Precondition
The Palette is not empty
The extrinsic transparency must match the color in slot 0 of the Palette
Returns
A PaletteMatchResult indicating whether the palette covers the tile and which colors are covered/missing

Definition at line 169 of file palette_matchers.hpp.

◆ operator&()

constexpr Style porytiles2::operator& ( Style  lhs,
Style  rhs 
)
constexpr

Masks Style flags using bitwise AND.

Performs a bitwise AND operation on Style values, typically used to check if specific flags are set or to mask out certain style attributes.

Parameters
lhsThe left-hand Style value
rhsThe right-hand Style value
Returns
A Style value containing only the flags present in both inputs

Definition at line 64 of file text_formatter.hpp.

◆ operator&=()

constexpr Style & porytiles2::operator&= ( Style lhs,
Style  rhs 
)
constexpr

Masks an existing Style value using bitwise AND.

In-place bitwise AND assignment operator that masks an existing Style value, typically used to remove certain flags.

Parameters
lhsThe Style value to modify
rhsThe Style mask to apply
Returns
Reference to the modified lhs value

Definition at line 95 of file text_formatter.hpp.

◆ operator<<() [1/2]

std::ostream & porytiles2::operator<< ( std::ostream &  os,
const Rgba32 rgba 
)
inline

Stream insertion operator for Rgba32.

Allows Rgba32 objects to be written to output streams using the << operator. Uses the JASC string representation.

Parameters
osThe output stream
rgbaThe Rgba32 color to output
Returns
Reference to the output stream

Definition at line 92 of file rgba32.hpp.

◆ operator<<() [2/2]

std::ostream & porytiles2::operator<< ( std::ostream &  os,
const TilesPalMode  m 
)
inline

Definition at line 34 of file tiles_pal_mode.hpp.

◆ operator|()

constexpr Style porytiles2::operator| ( Style  lhs,
Style  rhs 
)
constexpr

Combines two Style flags using bitwise OR.

Allows multiple styling attributes to be combined into a single Style value. This operator enables natural syntax for combining styles, such as Style::bold | Style::red.

Parameters
lhsThe left-hand Style value
rhsThe right-hand Style value
Returns
A Style value with both input flags set

Definition at line 48 of file text_formatter.hpp.

◆ operator|=()

constexpr Style & porytiles2::operator|= ( Style lhs,
Style  rhs 
)
constexpr

Adds Style flags to an existing Style value using bitwise OR.

In-place bitwise OR assignment operator that adds additional style flags to an existing Style value.

Parameters
lhsThe Style value to modify
rhsThe Style flags to add
Returns
Reference to the modified lhs value

Definition at line 79 of file text_formatter.hpp.

◆ panic()

void porytiles2::panic ( const StringViewSourceLoc s)
inline

Unconditionally terminates the program with a panic message.

This function formats and prints a panic message containing the source location and user message, then aborts the program. The function never returns.

Parameters
sThe StringViewSourceLoc containing the panic message and location

Definition at line 53 of file panic.hpp.

◆ parse_int() [1/2]

template<typename T >
std::expected< T, std::string > porytiles2::parse_int ( std::string_view  int_string)

Definition at line 31 of file parse_int.hpp.

◆ parse_int() [2/2]

template<typename T >
std::expected< T, std::string > porytiles2::parse_int ( std::string_view  int_string,
const int  base 
)

Definition at line 10 of file parse_int.hpp.

◆ reverse_bits()

constexpr uint8_t porytiles2::reverse_bits ( uint8_t  b)
constexpr

Reverses the bits in a byte.

This function reverses the order of all 8 bits in a byte. For example, the byte 0b10110010 would be reversed to 0b01001101.

Parameters
bThe byte to reverse
Returns
The byte with its bits reversed

Definition at line 17 of file reverse_bits.hpp.

◆ shape_tile_to_pixel_colors()

template<SupportsTransparency PixelType>
ShapeTile< PixelType > porytiles2::shape_tile_to_pixel_colors ( const ShapeTile< ColorIndex > &  shape_tile,
const ColorIndexMap< PixelType > &  color_index_map 
)

Converts a ShapeTile<ColorIndex> to a ShapeTile<PixelType> using a ColorIndexMap.

This function creates a ShapeTile<PixelType> from a ShapeTile<ColorIndex> by looking up the actual color for each ColorIndex in the ColorIndexMap. The ShapeMasks remain the same, but the color values change from indices to actual pixel colors.

The conversion process:

  1. Creates an empty ShapeTile<PixelType> result
  2. Iterates through each (ShapeMask, ColorIndex) pair in the input ShapeTile
  3. Looks up the actual color from the ColorIndexMap using the ColorIndex
  4. Panics if a ColorIndex is not found in the ColorIndexMap
  5. Sets the ShapeMask with the pixel color in the result ShapeTile
  6. Returns the completed ShapeTile<PixelType>
Template Parameters
PixelTypeThe pixel type of the output tile, must support transparency
Parameters
shape_tileThe ShapeTile<ColorIndex> to convert
color_index_mapThe ColorIndexMap providing index-to-color mappings
Precondition
All ColorIndex values in shape_tile must be present in color_index_map
Returns
A ShapeTile<PixelType> with the same masks but pixel colors instead of color indices

Definition at line 236 of file tile_converters.hpp.

◆ size_t_val_greater_than_zero()

ChainableResult< ConfigValue< std::size_t > > porytiles2::size_t_val_greater_than_zero ( const ConfigValue< std::size_t > &  val)
inline

Validates that a size_t config value is greater than zero.

This validator checks that the provided size_t config value is non-zero. If the value is zero, it returns a detailed error message showing the field name and the invalid value along with its configuration source information.

Parameters
valThe config value to validate
Returns
ChainableResult containing either the original value or a FormattableError if validation fails
Postcondition
If successful, the returned value is guaranteed to be greater than zero

Definition at line 31 of file config_validators.hpp.

◆ split()

std::vector< std::string > porytiles2::split ( std::string  input,
const std::string &  delimiter 
)
inline

Splits a string into tokens based on a delimiter.

This function splits the input string into a vector of substrings using the specified delimiter. The delimiter itself is not included in the resulting tokens. Empty tokens are preserved if consecutive delimiters are found.

Parameters
inputThe string to split
delimiterThe delimiter string to split on
Returns
A vector containing the split tokens

Definition at line 70 of file string_utils.hpp.

◆ tiles_pal_mode_from_str()

std::optional< TilesPalMode > porytiles2::tiles_pal_mode_from_str ( const std::string &  str)
inline

Definition at line 12 of file tiles_pal_mode.hpp.

◆ to_string() [1/3]

std::string porytiles2::to_string ( const IncrementalBuildMode value)
inline

Definition at line 9 of file incremental_build_mode.hpp.

◆ to_string() [2/3]

std::string porytiles2::to_string ( const Rgba32 rgba)
inline

Definition at line 109 of file rgba32.hpp.

◆ to_string() [3/3]

std::string porytiles2::to_string ( const TilesPalMode  m)
inline

Definition at line 23 of file tiles_pal_mode.hpp.

◆ transform() [1/2]

template<typename U , typename T >
requires std::constructible_from<U, T>
auto porytiles2::transform ( const std::vector< T > &  input) -> std::vector<U>

Transforms a vector of type T into a vector of type U using direct type construction.

This convenience overload allows direct type conversion when U is constructible from T. The transformation is performed using C++23 ranges for optimal performance. This is particularly useful for converting between related types like PixelTile and CanonicalPixelTile.

Template Parameters
UThe target type for the output vector elements
TThe type of elements in the input vector (typically deduced)
Parameters
inputThe input vector to transform
Returns
A new vector containing the converted elements

Definition at line 44 of file transform.hpp.

◆ transform() [2/2]

template<typename T , typename F >
auto porytiles2::transform ( const std::vector< T > &  input,
F &&  func 
) -> std::vector<std::invoke_result_t<F, const T &>>

Transforms a vector of type T into a vector of type U using a mapping function.

This function applies a transformation function to each element of the input vector, producing a new vector containing the transformed elements. The transformation is performed using C++23 ranges for optimal performance. The function uses lazy evaluation via std::views::transform and efficiently materializes the result with std::ranges::to.

Template Parameters
TThe type of elements in the input vector
FThe type of the transformation function
Parameters
inputThe input vector to transform
funcThe transformation function that maps T to U
Returns
A new vector containing the transformed elements

Definition at line 24 of file transform.hpp.

◆ trim()

void porytiles2::trim ( std::string &  string)
inline

Removes leading and trailing whitespace from a string in-place.

This function modifies the input string by removing all whitespace characters from the beginning and end of the string. The string is modified directly.

Parameters
stringThe string to trim (modified in-place)

Definition at line 45 of file string_utils.hpp.

◆ trim_line_ending() [1/2]

std::string porytiles2::trim_line_ending ( const std::string &  line)
inline

Removes line ending characters from a string.

This function creates a copy of the input string and removes all trailing carriage return (\r) and newline (
) characters from the end. The original string is not modified.

Parameters
lineThe string to trim
Returns
A new string with line endings removed

Definition at line 112 of file string_utils.hpp.

◆ trim_line_ending() [2/2]

std::string & porytiles2::trim_line_ending ( std::string &  line)
inline

Removes line ending characters from a string in-place.

This function removes all trailing carriage return (\r) and newline (
) characters from the end of the string. The string is modified directly.

Parameters
lineThe string to trim (modified in-place)
Returns
Reference to the modified string

Definition at line 93 of file string_utils.hpp.

Variable Documentation

◆ colors_per_pal

constexpr std::size_t porytiles2::colors_per_pal = 16
inlineconstexpr

Definition at line 12 of file color_index.hpp.

◆ num_colors

constexpr std::size_t porytiles2::num_colors = colors_per_pal * num_pals
inlineconstexpr

Definition at line 14 of file color_index.hpp.

◆ num_pals

constexpr std::size_t porytiles2::num_pals = 16
inlineconstexpr

Definition at line 13 of file color_index.hpp.

◆ rgba_black

constexpr Rgba32 porytiles2::rgba_black {0, 0, 0, Rgba32::alpha_opaque}
constexpr

Definition at line 114 of file rgba32.hpp.

◆ rgba_blue

constexpr Rgba32 porytiles2::rgba_blue {0, 0, 255, Rgba32::alpha_opaque}
constexpr

Definition at line 119 of file rgba32.hpp.

◆ rgba_cyan

constexpr Rgba32 porytiles2::rgba_cyan {0, 255, 255, Rgba32::alpha_opaque}
constexpr

Definition at line 122 of file rgba32.hpp.

◆ rgba_green

constexpr Rgba32 porytiles2::rgba_green {0, 255, 0, Rgba32::alpha_opaque}
constexpr

Definition at line 118 of file rgba32.hpp.

◆ rgba_grey

constexpr Rgba32 porytiles2::rgba_grey {128, 128, 128, Rgba32::alpha_opaque}
constexpr

Definition at line 116 of file rgba32.hpp.

◆ rgba_lime

constexpr Rgba32 porytiles2::rgba_lime {128, 255, 128, Rgba32::alpha_opaque}
constexpr

Definition at line 124 of file rgba32.hpp.

◆ rgba_magenta

constexpr Rgba32 porytiles2::rgba_magenta {255, 0, 255, Rgba32::alpha_opaque}
constexpr

Definition at line 121 of file rgba32.hpp.

◆ rgba_purple

constexpr Rgba32 porytiles2::rgba_purple {128, 0, 255, Rgba32::alpha_opaque}
constexpr

Definition at line 123 of file rgba32.hpp.

◆ rgba_red

constexpr Rgba32 porytiles2::rgba_red {255, 0, 0, Rgba32::alpha_opaque}
constexpr

Definition at line 117 of file rgba32.hpp.

◆ rgba_white

constexpr Rgba32 porytiles2::rgba_white {255, 255, 255, Rgba32::alpha_opaque}
constexpr

Definition at line 115 of file rgba32.hpp.

◆ rgba_yellow

constexpr Rgba32 porytiles2::rgba_yellow {255, 255, 0, Rgba32::alpha_opaque}
constexpr

Definition at line 120 of file rgba32.hpp.