Porytiles
Loading...
Searching...
No Matches
porytiles::PorytilesTilesetManager Class Referenceabstract

Abstract interface for querying Porytiles tileset ownership. More...

#include <porytiles_tileset_manager.hpp>

Inheritance diagram for porytiles::PorytilesTilesetManager:
[legend]

Public Member Functions

virtual ~PorytilesTilesetManager ()=default
 
virtual bool is_porytiles_managed (const std::string &tileset_name) const =0
 Checks whether a tileset is managed by Porytiles.
 
virtual ChainableResult< void > persist_managed_existing (const std::string &tileset_name) const =0
 Persists managed state for an existing tileset.
 
virtual ChainableResult< void > persist_managed_new (const std::string &tileset_name, bool is_secondary=false) const =0
 Persists managed state for a new tileset.
 
virtual ChainableResult< void > wire_anim_code (const std::string &tileset_name, bool is_secondary) const =0
 Wires animation code for a tileset that already has its manifest persisted.
 
virtual ChainableResult< void > remove_wired_anim_code (const std::string &tileset_name, bool is_secondary) const =0
 Removes wired animation code for a tileset from the project.
 

Detailed Description

Abstract interface for querying Porytiles tileset ownership.

This interface provides a domain-layer abstraction for determining whether a tileset is managed by Porytiles. A Porytiles-managed tileset is one that was either imported into or created by Porytiles, as opposed to a vanilla pokeemerald tileset that has not been processed.

Implementations may use different strategies to determine ownership (e.g., checking for marker files, querying a database, etc.).

See also
ProjectPorytilesTilesetManager for the pokeemerald project-based implementation

Definition at line 22 of file porytiles_tileset_manager.hpp.

Constructor & Destructor Documentation

◆ ~PorytilesTilesetManager()

virtual porytiles::PorytilesTilesetManager::~PorytilesTilesetManager ( )
virtualdefault

Member Function Documentation

◆ is_porytiles_managed()

virtual bool porytiles::PorytilesTilesetManager::is_porytiles_managed ( const std::string &  tileset_name) const
pure virtual

Checks whether a tileset is managed by Porytiles.

If the tileset does not exist, this function returns false.

Parameters
tileset_nameThe name of the tileset (e.g., "gTileset_General")
Returns
true if the tileset is Porytiles-managed

Implemented in porytiles::ProjectPorytilesTilesetManager.

◆ persist_managed_existing()

virtual ChainableResult< void > porytiles::PorytilesTilesetManager::persist_managed_existing ( const std::string &  tileset_name) const
pure virtual

Persists managed state for an existing tileset.

Used when an existing tileset in headers.h is being converted to Porytiles-managed. The implementation reads original field values from headers.h and stores them in the tileset manifest for potential restoration later.

Parameters
tileset_nameThe name of the tileset (e.g., "gTileset_General")
Precondition
tileset_name must correspond to an existing tileset in headers.h
Returns
a ChainableResult indicating success or containing error details

Implemented in porytiles::ProjectPorytilesTilesetManager.

◆ persist_managed_new()

virtual ChainableResult< void > porytiles::PorytilesTilesetManager::persist_managed_new ( const std::string &  tileset_name,
bool  is_secondary = false 
) const
pure virtual

Persists managed state for a new tileset.

Used when a new tileset is being added from scratch. The implementation creates a new entry in headers.h rather than modifying an existing one.

Parameters
tileset_nameThe name of the tileset (e.g., "gTileset_MyNewTileset")
Precondition
tileset_name must not already exist in headers.h
Returns
a ChainableResult indicating success or containing error details

Implemented in porytiles::ProjectPorytilesTilesetManager.

◆ remove_wired_anim_code()

virtual ChainableResult< void > porytiles::PorytilesTilesetManager::remove_wired_anim_code ( const std::string &  tileset_name,
bool  is_secondary 
) const
pure virtual

Removes wired animation code for a tileset from the project.

Performs the inverse of wire_anim_code(). This method:

  1. Removes the #include directive from tileset_anims.c
  2. Removes the function declaration from tileset_anims.h
  3. Updates the .callback field in headers.h to "NULL" (only if it's a Porytiles-managed callback)

The callback is only cleared if it starts with "InitTilesetAnim_PorytilesManaged_". User-managed callbacks are preserved, allowing users to set wire_anim_code=false while maintaining their own custom animation callbacks.

This method is idempotent - safe to call even if no wiring exists. Should be called after compilation when a tileset has no animations to ensure stale animation references are cleaned up.

Parameters
tileset_nameName of the tileset to remove wiring for
is_secondaryTrue if this is a secondary tileset
Returns
ChainableResult<void> Success or error

Implemented in porytiles::ProjectPorytilesTilesetManager.

◆ wire_anim_code()

virtual ChainableResult< void > porytiles::PorytilesTilesetManager::wire_anim_code ( const std::string &  tileset_name,
bool  is_secondary 
) const
pure virtual

Wires animation code for a tileset that already has its manifest persisted.

Called after compilation when a tileset has animations. Performs:

  1. Adds #include for generated_anim_code.h in tileset_anims.c
  2. Adds function declaration in tileset_anims.h
  3. Updates .callback field in headers.h

Idempotent - safe to call multiple times.

Parameters
tileset_nameThe tileset name (e.g., "gTileset_MyTileset")
is_secondaryTrue for secondary tilesets, false for primary
Precondition
tileset_name must be an existing Porytiles-managed tileset
Returns
ChainableResult indicating success or error details

Implemented in porytiles::ProjectPorytilesTilesetManager.


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