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

Modifies tileset_anims.c to include Porytiles-managed animation code headers. More...

#include <project_tileset_anims_modifier.hpp>

Public Member Functions

 ProjectTilesetAnimsModifier (std::filesystem::path project_root, gsl::not_null< const InfraConfig * > config, gsl::not_null< const UserDiagnostics * > diagnostics)
 Constructs a TilesetAnimsModifier with required dependencies.
 
ChainableResult< void > wire_include_for_tileset (const std::string &tileset_name, bool is_secondary) const
 Adds an #include directive for the tileset's generated animation code.
 
ChainableResult< void > remove_include_for_tileset (const std::string &tileset_name, bool is_secondary) const
 Removes the #include directive for the tileset's generated animation code.
 

Detailed Description

Modifies tileset_anims.c to include Porytiles-managed animation code headers.

This service adds and removes #include directives in pokeemerald's src/tileset_anims.c that point to Porytiles-generated animation code headers. The include directive follows the pattern:

// [Porytiles] Auto-generated include. Do not remove.
#include "porytiles_generated/tilesets/{tileset_dir}/generated_anim_code.h"

Note: The "include/" prefix is omitted from the directive because pokeemerald's makefile already adds "include" to the include path. The actual file lives at include/porytiles_generated/tilesets/{tileset_dir}/...

All tilesets (primary and secondary) use the same base path. The tileset_dir is the snake_case version of the tileset shorthand (e.g., "general" for gTileset_General, "battle_frontier" for gTileset_BattleFrontier).

The service appends includes at the bottom of the file with a comment indicating they were auto-generated by Porytiles.

See also
IncbinDeclarationAppender for similar append/removal patterns
ProjectTilesetMetadataWriter for surgical file modification approach

Definition at line 36 of file project_tileset_anims_modifier.hpp.

Constructor & Destructor Documentation

◆ ProjectTilesetAnimsModifier()

porytiles::ProjectTilesetAnimsModifier::ProjectTilesetAnimsModifier ( std::filesystem::path  project_root,
gsl::not_null< const InfraConfig * >  config,
gsl::not_null< const UserDiagnostics * >  diagnostics 
)

Constructs a TilesetAnimsModifier with required dependencies.

Parameters
project_rootPath to the pokeemerald project root directory
configConfiguration interface for tileset paths (non-owning, must outlive this object)
diagnosticsDiagnostics interface for warnings/notes (non-owning, must outlive this object)

Definition at line 213 of file project_tileset_anims_modifier.cpp.

Member Function Documentation

◆ remove_include_for_tileset()

ChainableResult< void > porytiles::ProjectTilesetAnimsModifier::remove_include_for_tileset ( const std::string &  tileset_name,
bool  is_secondary 
) const

Removes the #include directive for the tileset's generated animation code.

Removes the include directive for the specified tileset from tileset_anims.c. Used during restore operations to return the file to its original state.

The operation is idempotent: if the include doesn't exist, a warning is emitted and no changes are made.

Parameters
tileset_nameThe tileset name (e.g., "gTileset_General")
is_secondaryTrue for secondary tilesets, false for primary
Precondition
tileset_name must start with "gTileset_"
Returns
Success or error result with details

Definition at line 317 of file project_tileset_anims_modifier.cpp.

◆ wire_include_for_tileset()

ChainableResult< void > porytiles::ProjectTilesetAnimsModifier::wire_include_for_tileset ( const std::string &  tileset_name,
bool  is_secondary 
) const

Adds an #include directive for the tileset's generated animation code.

Appends an include directive at the bottom of tileset_anims.c, pointing to the generated animation code header at:

porytiles_generated/tilesets/{snake_case_dir}/generated_anim_code.h

The include is preceded by a comment indicating it was auto-generated by Porytiles.

The operation is idempotent: if the include already exists, a warning is emitted and no changes are made.

Parameters
tileset_nameThe tileset name (e.g., "gTileset_General")
is_secondaryTrue for secondary tilesets, false for primary (currently unused but kept for API symmetry)
Precondition
tileset_name must start with "gTileset_"
Returns
Success or error result with details

Definition at line 222 of file project_tileset_anims_modifier.cpp.


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