13ChainableResult<std::unique_ptr<PorymapTilesetComponent>>
16 auto porymap_component = std::make_unique<PorymapTilesetComponent>();
23 std::unique_ptr<PorymapTilesetComponent>,
24 format_->
format(
"Failed to get artifact paths for tileset '{}'.",
FormatParam{tileset_name, Style::bold}));
30 std::unique_ptr<PorymapTilesetComponent>,
31 "Failed to parse metatiles.bin.");
33 for (
auto &entry : metatile_entries) {
34 porymap_component->push_back_tilemap_entry(std::move(entry));
43 std::unique_ptr<PorymapTilesetComponent>,
44 "Failed to parse metatile_attributes.bin.");
46 for (
auto &attr : attributes) {
47 porymap_component->push_back_attribute(std::move(attr));
52 tiles_png_path +=
".png";
57 std::unique_ptr<PorymapTilesetComponent>,
58 "Failed to load tiles.png.");
60 porymap_component->tiles_png(*tiles_image);
63 const auto &palette_paths = artifact_paths.palette_paths();
64 for (std::size_t i = 0; i < palette_paths.size() && i <
pal::num_pals; ++i) {
72 std::unique_ptr<PorymapTilesetComponent>,
73 format_->
format(
"Failed to load palette {}.",
FormatParam{pal_filename(i), Style::bold}));
75 porymap_component->set_pal(i, std::move(palette));
82 auto anims_result = anim_importer.import_animations(tileset_name);
83 if (!anims_result.has_value()) {
88 for (
auto &anim : anims_result.value() | std::views::values) {
89 porymap_component->add_anim(std::move(anim));
95 return porymap_component;
#define PT_TRY_ASSIGN_CHAIN_ERR(var, expr, return_type,...)
Unwraps a ChainableResult, chaining a new error message on failure.
A result type that maintains a chainable sequence of errors for debugging and error reporting.
ChainableResult< std::unique_ptr< PorymapTilesetComponent > > import_porymap_component_from_vanilla(const std::string &tileset_name) const override
Reads vanilla Porymap artifacts from a pokeemerald project into a PorymapTilesetComponent.
Imports vanilla animation metadata and frame data as IndexPixel tiles.
static const Style bold
Bold text formatting.
virtual std::string format(const std::string &format_str, const std::vector< FormatParam > ¶ms) const
Formats a string with styled parameters using fmtlib syntax.
constexpr std::size_t bytes_per_attr_firered
constexpr std::size_t num_pals
ChainableResult< std::vector< MetatileAttribute > > parse_firered_metatile_attributes(const std::filesystem::path &path)
Parses a metatile_attributes.bin file for FireRed format.
ChainableResult< Palette< Rgba32, pal::max_size > > load_porymap_palette(const std::filesystem::path &path, const FilePalLoader &loader)
Loads a Porymap palette file (e.g., 00.pal).
ChainableResult< std::vector< MetatileAttribute > > parse_emerald_metatile_attributes(const std::filesystem::path &path)
Parses a metatile_attributes.bin file for Emerald format.
ChainableResult< std::vector< TilemapEntry > > parse_metatiles_bin(const std::filesystem::path &path)
Parses a metatiles.bin file into TilemapEntry objects.
std::filesystem::path strip_all_extensions(const std::filesystem::path &path)
Strips all extensions from a path, returning the path with only the stem.
ChainableResult< std::unique_ptr< Image< IndexPixel > > > load_indexed_png(const std::filesystem::path &path, const PngIndexedImageLoader &loader)
Loads an indexed PNG file (e.g., tiles.png).
Utility functions for string manipulation and formatting.