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

Provides a pokeemerald project filesystem-based implementation for TilesetMetadataProvider. More...

#include <project_tileset_metadata_provider.hpp>

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

Public Member Functions

 ProjectTilesetMetadataProvider (std::filesystem::path project_root, gsl::not_null< const TextFormatter * > format, gsl::not_null< const UserDiagnostics * > diag)
 
bool exists (const std::string &tileset_name) const override
 Checks whether a tileset exists in the backing store for the given tileset name.
 
ChainableResult< bool > is_secondary (const std::string &tileset_name) const override
 Determines whether a tileset is a secondary tileset.
 
ChainableResult< bool > has_animations (const std::string &tileset_name) const override
 Determines whether a tileset has animation support.
 
ChainableResult< std::set< std::string > > tilesets () const override
 Returns all tileset names known to this provider.
 
ChainableResult< ProjectTilesetMetadatametadata_for (const std::string &tileset_name) const
 Retrieves metadata for a specific tileset from the struct cache.
 
ChainableResult< ProjectTilesetArtifactPathsartifact_paths_for (const std::string &tileset_name) const
 Resolves artifact paths for a tileset by parsing INCBIN declarations.
 
void invalidate_metadata_cache () const
 Invalidates the lazy-loaded metadata and artifact paths caches, forcing a re-parse on next access.
 
- Public Member Functions inherited from porytiles::TilesetMetadataProvider
virtual ~TilesetMetadataProvider ()=default
 

Detailed Description

Provides a pokeemerald project filesystem-based implementation for TilesetMetadataProvider.

This class parses tileset struct declarations from headers.h to extract metadata such as whether a tileset is primary/secondary, what animation callback it uses, and the variable names for tiles, palettes, metatiles, and attributes.

Tileset struct metadata is lazy-loaded and cached for efficiency.

Definition at line 30 of file project_tileset_metadata_provider.hpp.

Constructor & Destructor Documentation

◆ ProjectTilesetMetadataProvider()

porytiles::ProjectTilesetMetadataProvider::ProjectTilesetMetadataProvider ( std::filesystem::path  project_root,
gsl::not_null< const TextFormatter * >  format,
gsl::not_null< const UserDiagnostics * >  diag 
)
inline

Definition at line 32 of file project_tileset_metadata_provider.hpp.

Member Function Documentation

◆ artifact_paths_for()

ChainableResult< ProjectTilesetArtifactPaths > porytiles::ProjectTilesetMetadataProvider::artifact_paths_for ( const std::string &  tileset_name) const

Resolves artifact paths for a tileset by parsing INCBIN declarations.

This method retrieves tileset metadata (which contains INCBIN variable names), then looks up the actual filesystem paths for those variables by parsing graphics.h, metatiles.h, and src/graphics.c.

Parameters
tileset_nameThe name of the tileset (e.g., "gTileset_General")
Precondition
tileset_name must refer to an existing tileset on disk
Returns
The resolved artifact paths for the tileset

Definition at line 260 of file project_tileset_metadata_provider.cpp.

◆ exists()

bool porytiles::ProjectTilesetMetadataProvider::exists ( const std::string &  tileset_name) const
overridevirtual

Checks whether a tileset exists in the backing store for the given tileset name.

Parameters
tileset_nameThe name of the tileset to check (e.g., "gTileset_General")
Returns
True if the tileset exists in the backing store, false otherwise

Implements porytiles::TilesetMetadataProvider.

Definition at line 211 of file project_tileset_metadata_provider.cpp.

◆ has_animations()

ChainableResult< bool > porytiles::ProjectTilesetMetadataProvider::has_animations ( const std::string &  tileset_name) const
overridevirtual

Determines whether a tileset has animation support.

Animated tilesets have a non-null animation callback function that cycles through animation frames. This information is needed to properly handle tile references that may animate at runtime.

Parameters
tileset_nameThe identifier for the tileset (e.g., "gTileset_General")
Returns
ChainableResult containing true if the tileset has animations, false otherwise

Implements porytiles::TilesetMetadataProvider.

Definition at line 223 of file project_tileset_metadata_provider.cpp.

◆ invalidate_metadata_cache()

void porytiles::ProjectTilesetMetadataProvider::invalidate_metadata_cache ( ) const

Invalidates the lazy-loaded metadata and artifact paths caches, forcing a re-parse on next access.

This is needed when the underlying files (e.g. headers.h) have been modified on disk since the cache was populated. For example, after creating a new tileset struct, the cache must be invalidated so subsequent metadata lookups see the newly written struct.

Definition at line 281 of file project_tileset_metadata_provider.cpp.

◆ is_secondary()

ChainableResult< bool > porytiles::ProjectTilesetMetadataProvider::is_secondary ( const std::string &  tileset_name) const
overridevirtual

Determines whether a tileset is a secondary tileset.

In pokeemerald, tilesets are either primary or secondary. Primary tilesets contain shared tiles and palettes, while secondary tilesets contain map-specific content and layer on top of primaries. This distinction affects tile indexing, palette allocation, and metatile attribute encoding.

Parameters
tileset_nameThe identifier for the tileset (e.g., "gTileset_General")
Returns
ChainableResult containing true if the tileset is secondary, false if primary

Implements porytiles::TilesetMetadataProvider.

Definition at line 217 of file project_tileset_metadata_provider.cpp.

◆ metadata_for()

ChainableResult< ProjectTilesetMetadata > porytiles::ProjectTilesetMetadataProvider::metadata_for ( const std::string &  tileset_name) const

Retrieves metadata for a specific tileset from the struct cache.

This method parses tileset struct declarations from headers.h to extract raw field values. The result contains only the fields directly from the struct: name, is_secondary, variable names, and callback.

Parameters
tileset_nameThe name of the tileset (e.g., "gTileset_General")
Precondition
tileset_name must refer to an existing tileset on disk
Returns
The parsed metadata for the tileset

Definition at line 244 of file project_tileset_metadata_provider.cpp.

◆ tilesets()

ChainableResult< std::set< std::string > > porytiles::ProjectTilesetMetadataProvider::tilesets ( ) const
overridevirtual

Returns all tileset names known to this provider.

Enumerates all tilesets available in the backing store. This enables batch operations, validation, and listing without requiring callers to know tileset names in advance.

Returns
ChainableResult containing a set of all tileset names

Implements porytiles::TilesetMetadataProvider.

Definition at line 229 of file project_tileset_metadata_provider.cpp.


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