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

Infra-layer implementation of PrimaryTilesetImporter for pokeemerald project structure. More...

#include <project_primary_tileset_importer.hpp>

Inheritance diagram for porytiles::ProjectPrimaryTilesetImporter:
[legend]
Collaboration diagram for porytiles::ProjectPrimaryTilesetImporter:
[legend]

Public Member Functions

 ProjectPrimaryTilesetImporter (std::filesystem::path project_root, std::size_t metatile_attr_size, gsl::not_null< const DomainConfig * > config, gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag, gsl::not_null< const TilePrinter * > tile_printer, gsl::not_null< const PalettePrinter * > pal_printer, gsl::not_null< const ProjectTilesetMetadataProvider * > metadata_provider, gsl::not_null< const PngIndexedImageLoader * > png_loader, gsl::not_null< const FilePalLoader * > pal_loader)
 Constructs a ProjectPrimaryTilesetImporter with required dependencies.
 
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.
 
- Public Member Functions inherited from porytiles::PrimaryTilesetImporter
virtual ~PrimaryTilesetImporter ()=default
 

Detailed Description

Infra-layer implementation of PrimaryTilesetImporter for pokeemerald project structure.

This class provides the pokeemerald-specific implementation for importing vanilla tilesets. It reads tileset artifacts from the standard pokeemerald project directory structure:

  • src/data/tilesets/headers.h - Tileset struct declarations with INCBIN variable references
  • src/data/tilesets/graphics.h - INCBIN declarations for tiles and palettes
  • src/data/tilesets/metatiles.h - INCBIN declarations for metatiles and attributes
  • src/tileset_anims.c - Animation callback implementations and frame INCBIN declarations
  • data/tilesets/{primary,secondary}/{name}/ - Actual PNG/binary assets

The import process parses C header files to discover asset locations (which may be scattered across different paths due to INCBIN flexibility), then reads and populates a PorymapTilesetComponent with all the data needed for decompilation.

Note
This class handles the "discovery chaos" of vanilla pokeemerald projects where asset paths are not standardized. After import, Porytiles places all assets at deterministic paths.
See also
PrimaryTilesetImporter for the domain-layer base class and import workflow.
ProjectVanillaAnimImporter for the animation import helper used by this class.

Definition at line 37 of file project_primary_tileset_importer.hpp.

Constructor & Destructor Documentation

◆ ProjectPrimaryTilesetImporter()

porytiles::ProjectPrimaryTilesetImporter::ProjectPrimaryTilesetImporter ( std::filesystem::path  project_root,
std::size_t  metatile_attr_size,
gsl::not_null< const DomainConfig * >  config,
gsl::not_null< const TextFormatter * >  format,
gsl::not_null< const UserDiagnostics * >  diag,
gsl::not_null< const TilePrinter * >  tile_printer,
gsl::not_null< const PalettePrinter * >  pal_printer,
gsl::not_null< const ProjectTilesetMetadataProvider * >  metadata_provider,
gsl::not_null< const PngIndexedImageLoader * >  png_loader,
gsl::not_null< const FilePalLoader * >  pal_loader 
)
inlineexplicit

Constructs a ProjectPrimaryTilesetImporter with required dependencies.

Parameters
project_rootPath to the pokeemerald project root directory
metatile_attr_sizeBytes per metatile attribute entry (2 for Emerald-family, 4 for FireRed)
configDomain configuration containing tileset parameters and paths
formatText formatter for error message styling
diagUser diagnostics for warnings and informational messages
tile_printerTile visualization service for diagnostic output
pal_printerPalette visualization service for diagnostic output
metadata_providerProvider for resolving tileset metadata and artifact paths
png_loaderLoader for indexed PNG files (tiles.png)
pal_loaderLoader for palette files

Definition at line 53 of file project_primary_tileset_importer.hpp.

Member Function Documentation

◆ import_porymap_component_from_vanilla()

ChainableResult< std::unique_ptr< PorymapTilesetComponent > > porytiles::ProjectPrimaryTilesetImporter::import_porymap_component_from_vanilla ( const std::string &  tileset_name) const
overridevirtual

Reads vanilla Porymap artifacts from a pokeemerald project into a PorymapTilesetComponent.

This implementation:

  1. Parses src/data/tilesets/headers.h to get tileset metadata (isSecondary, INCBIN variable names)
  2. Parses src/data/tilesets/graphics.h and metatiles.h to resolve INCBIN paths to actual files
  3. Reads tiles.png, palettes, metatiles.bin, and metatile_attributes.bin from discovered paths
  4. Uses ProjectVanillaAnimImporter to read animation frames from tileset_anims.c INCBIN declarations
Parameters
tileset_nameThe name of the tileset to import (e.g., "gTileset_General")
Precondition
Tileset entry must exist in src/data/tilesets/headers.h
All INCBIN-referenced files must exist at their declared paths
Returns
A ChainableResult containing a unique_ptr to the populated PorymapTilesetComponent

Implements porytiles::PrimaryTilesetImporter.

Definition at line 14 of file project_primary_tileset_importer.cpp.


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