Porytiles
Loading...
Searching...
No Matches
porytiles2::ProjectTilesetArtifactKeyProvider Class Referencefinal

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

#include <project_tileset_artifact_key_provider.hpp>

Inheritance diagram for porytiles2::ProjectTilesetArtifactKeyProvider:
[legend]
Collaboration diagram for porytiles2::ProjectTilesetArtifactKeyProvider:
[legend]

Public Member Functions

 ProjectTilesetArtifactKeyProvider (std::filesystem::path project_root)
 
ArtifactKey key_for (const std::string &tileset_name, const TilesetArtifact &artifact) const override
 Constructs a key for a given tileset artifact.
 
bool artifact_exists (const ArtifactKey &key) const override
 Checks whether an artifact exists in the backing store for the given key.
 
bool tileset_exists (const std::string &tileset_name) const override
 Checks whether a tileset exists in the backing store for the given tileset name.
 
std::set< std::string > discover_porytiles_anims (const std::string &tileset_name) const override
 Discovers the names of all Porytiles animations available for a tileset.
 
std::set< int > discover_porytiles_anim_frames (const std::string &tileset_name, const std::string &anim_name) const override
 Discovers the frame indices for a specific Porytiles animation.
 
std::set< std::string > discover_porymap_anims (const std::string &tileset_name) const override
 Discovers the names of all Porymap animations available for a tileset.
 
std::set< int > discover_porymap_anim_frames (const std::string &tileset_name, const std::string &anim_name) const override
 Discovers the frame indices for a specific Porymap animation.
 
std::filesystem::path tileset_root (const std::string &tileset_name) const
 Returns the filesystem path to the root directory of a tileset.
 
- Public Member Functions inherited from porytiles2::TilesetArtifactKeyProvider
virtual ~TilesetArtifactKeyProvider ()=default
 
virtual std::vector< ArtifactKeyget_porytiles_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all Porytiles artifacts present in the given Tileset.
 
virtual std::vector< ArtifactKeyget_porymap_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all Porymap artifacts present in the given Tileset.
 
virtual std::vector< ArtifactKeyget_all_artifact_keys (const std::string &tileset_name) const
 Gets the keys for all tileset artifacts (both Porytiles and Porymap) present in the given Tileset.
 

Detailed Description

Provides a pokeemerald project filesystem-based implementation for TilesetArtifactKeyProvider.

This class implements the TilesetArtifactKeyProvider interface to provide filesystem paths as keys for various tileset artifacts. It operates within the context of a Pokémon Gen III decompilation project, discovering and managing paths for animations, tiles, and other tileset components based on the project's directory structure.

Class precondition: the tileset_name parameter in each method below (except tileset_exists) must refer to an existing tileset on-disk. If no tileset corresponds to the given tileset_name, ProjectTilesetKeyProvider will panic.

Definition at line 24 of file project_tileset_artifact_key_provider.hpp.

Constructor & Destructor Documentation

◆ ProjectTilesetArtifactKeyProvider()

porytiles2::ProjectTilesetArtifactKeyProvider::ProjectTilesetArtifactKeyProvider ( std::filesystem::path  project_root)
inlineexplicit

Definition at line 26 of file project_tileset_artifact_key_provider.hpp.

Member Function Documentation

◆ artifact_exists()

bool porytiles2::ProjectTilesetArtifactKeyProvider::artifact_exists ( const ArtifactKey key) const
overridevirtual

Checks whether an artifact exists in the backing store for the given key.

This method should perform the actual existence check against the backing store using the provided key. This may involve filesystem operations, database queries, or other I/O depending on the implementation.

Parameters
keyThe key identifying the artifact to check (generated by key_for)
Returns
True if the artifact exists in the backing store, false otherwise

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 119 of file project_tileset_artifact_key_provider.cpp.

◆ discover_porymap_anim_frames()

std::set< int > porytiles2::ProjectTilesetArtifactKeyProvider::discover_porymap_anim_frames ( const std::string &  tileset_name,
const std::string &  anim_name 
) const
overridevirtual

Discovers the frame indices for a specific Porymap animation.

Searches the backing store to find all animation frame files (excluding the key frame and 00.png) for a specific Porymap animation. The returned indices should be consecutive starting from 1. Since frame 0 is required, callers don't need to discover it.

Parameters
tileset_nameThe name of the tileset containing the animation
anim_nameThe name of the animation to search for frames
Returns
Set of frame indices found in the backing store

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 241 of file project_tileset_artifact_key_provider.cpp.

◆ discover_porymap_anims()

std::set< std::string > porytiles2::ProjectTilesetArtifactKeyProvider::discover_porymap_anims ( const std::string &  tileset_name) const
overridevirtual

Discovers the names of all Porymap animations available for a tileset.

Searches the backing store to find all Porymap animation assets for the specified tileset. Porymap animations do not require key frames, only sequential frame files.

Parameters
tileset_nameThe name of the tileset to search for animations
Returns
Set of animation names found in the backing store

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 210 of file project_tileset_artifact_key_provider.cpp.

◆ discover_porytiles_anim_frames()

std::set< int > porytiles2::ProjectTilesetArtifactKeyProvider::discover_porytiles_anim_frames ( const std::string &  tileset_name,
const std::string &  anim_name 
) const
overridevirtual

Discovers the frame indices for a specific Porytiles animation.

Searches the backing store to find all animation frame files (excluding the key frame and 00.png) for a specific Porytiles animation. The returned indices should be consecutive starting from 1. Since frame 0 is required, callers don't need to discover it.

Parameters
tileset_nameThe name of the tileset containing the animation
anim_nameThe name of the animation to search for frames
Returns
Set of frame indices found in the backing store (typically starting from 1)

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 167 of file project_tileset_artifact_key_provider.cpp.

◆ discover_porytiles_anims()

std::set< std::string > porytiles2::ProjectTilesetArtifactKeyProvider::discover_porytiles_anims ( const std::string &  tileset_name) const
overridevirtual

Discovers the names of all Porytiles animations available for a tileset.

Searches the backing store to find all Porytiles animation directories or assets for the specified tileset. Porytiles animations require both a key frame and at least one animation frame (00.png).

Parameters
tileset_nameThe name of the tileset to search for animations
Returns
Set of animation names found in the backing store

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 136 of file project_tileset_artifact_key_provider.cpp.

◆ key_for()

ArtifactKey porytiles2::ProjectTilesetArtifactKeyProvider::key_for ( const std::string &  tileset_name,
const TilesetArtifact artifact 
) const
overridevirtual

Constructs a key for a given tileset artifact.

This method should focus primarily on building keys from the provided parameters, not on searching the filesystem or backing store. The key generation should be fast and deterministic based on the tileset name and artifact specification.

Parameters
tileset_nameThe name of the tileset for the tileset artifact
artifactThe artifact details specifying type, name, and index as applicable
Returns
The key for the given tileset artifact

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 47 of file project_tileset_artifact_key_provider.cpp.

◆ tileset_exists()

bool porytiles2::ProjectTilesetArtifactKeyProvider::tileset_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
Returns
True if the tileset exists in the backing store, false otherwise

Implements porytiles2::TilesetArtifactKeyProvider.

Definition at line 125 of file project_tileset_artifact_key_provider.cpp.

◆ tileset_root()

std::filesystem::path porytiles2::ProjectTilesetArtifactKeyProvider::tileset_root ( const std::string &  tileset_name) const

Returns the filesystem path to the root directory of a tileset.

This method provides the base directory path where all artifacts for a specific tileset are stored within the project's filesystem structure. This is specific to the filesystem-based implementation, as other backing stores may not have a concept of a single root directory for tileset artifacts.

Parameters
tileset_nameThe name of the tileset
Returns
The filesystem path to the tileset's root directory

Definition at line 285 of file project_tileset_artifact_key_provider.cpp.


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