|
Porytiles
|
Manages Porytiles-owned tilesets via TilesetManifest JSON files. More...
#include <project_porytiles_tileset_manager.hpp>
Public Member Functions | |
| ProjectPorytilesTilesetManager (std::filesystem::path project_root, const ProjectTilesetMetadataProvider *metadata_provider, const ProjectTilesetMetadataWriter *metadata_writer, const InfraConfig *infra_config, gsl::not_null< const UserDiagnostics * > diag, const IncbinDeclarationAppender *incbin_appender, const ProjectTilesetAnimsModifier *tileset_anims_modifier) | |
| Constructs a ProjectPorytilesTilesetManager with required dependencies. | |
| ChainableResult< TilesetManifest > | read (const std::string &tileset_name) const |
| Reads an TilesetManifest object from the porytiles utility directory. | |
| void | write (const std::string &tileset_name, const TilesetManifest &artifacts) const |
| Writes an TilesetManifest object to the porytiles utility directory. | |
| bool | is_porytiles_managed (const std::string &tileset_name) const override |
| Checks whether a tileset has an tileset-manifest.json file. | |
| ChainableResult< void > | persist_managed_existing (const std::string &tileset_name) const override |
| Persists managed state for an existing tileset. | |
| ChainableResult< void > | persist_managed_new (const std::string &tileset_name, bool is_secondary=false) const override |
| Persists managed state for a new tileset. | |
| ChainableResult< void > | wire_anim_code (const std::string &tileset_name, bool is_secondary) const override |
| Wires animation code for a tileset that already has its manifest persisted. | |
| ChainableResult< void > | remove_wired_anim_code (const std::string &tileset_name, bool is_secondary) const override |
| Removes wired animation code for a tileset from the project. | |
Public Member Functions inherited from porytiles::PorytilesTilesetManager | |
| virtual | ~PorytilesTilesetManager ()=default |
Manages Porytiles-owned tilesets via TilesetManifest JSON files.
This class serializes and deserializes tileset-manifest.json files in the porytiles/tilesets/{tileset_name}/ directory. The presence of this file indicates that a tileset is Porytiles-managed.
The JSON format varies based on whether the tileset was imported from vanilla pokeemerald:
Definition at line 31 of file project_porytiles_tileset_manager.hpp.
|
inline |
Constructs a ProjectPorytilesTilesetManager with required dependencies.
| project_root | Path to the pokeemerald project root directory |
| metadata_provider | Provider for reading headers.h fields |
| metadata_writer | Writer for updating headers.h fields |
| infra_config | Configuration provider for tileset paths and animation settings |
| diag | Diagnostics interface for warnings/notes |
| incbin_appender | Service for appending INCBIN declarations to header files |
| tileset_anims_modifier | Service for modifying tileset_anims.c includes |
Definition at line 44 of file project_porytiles_tileset_manager.hpp.
|
overridevirtual |
Checks whether a tileset has an tileset-manifest.json file.
This is the canonical way to check if a tileset is Porytiles-managed.
| tileset_name | The name of the tileset (e.g., "gTileset_General") |
Implements porytiles::PorytilesTilesetManager.
Definition at line 109 of file project_porytiles_tileset_manager.cpp.
|
overridevirtual |
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.
| tileset_name | The name of the tileset (e.g., "gTileset_General") |
Implements porytiles::PorytilesTilesetManager.
Definition at line 114 of file project_porytiles_tileset_manager.cpp.
|
overridevirtual |
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.
| tileset_name | The name of the tileset (e.g., "gTileset_MyNewTileset") |
Implements porytiles::PorytilesTilesetManager.
Definition at line 170 of file project_porytiles_tileset_manager.cpp.
| ChainableResult< TilesetManifest > porytiles::ProjectPorytilesTilesetManager::read | ( | const std::string & | tileset_name | ) | const |
Reads an TilesetManifest object from the porytiles utility directory.
Looks for tileset-manifest.json at {project_root}/porytiles/tilesets/{tileset_name}/. Returns an error if the file doesn't exist or contains invalid JSON.
| tileset_name | The name of the tileset (e.g., "gTileset_General") |
Definition at line 59 of file project_porytiles_tileset_manager.cpp.
|
overridevirtual |
Removes wired animation code for a tileset from the project.
Performs the inverse of wire_anim_code(). This method:
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.
| tileset_name | Name of the tileset to remove wiring for |
| is_secondary | True if this is a secondary tileset |
Implements porytiles::PorytilesTilesetManager.
Definition at line 254 of file project_porytiles_tileset_manager.cpp.
|
overridevirtual |
Wires animation code for a tileset that already has its manifest persisted.
Called after compilation when a tileset has animations. Performs:
Idempotent - safe to call multiple times.
| tileset_name | The tileset name (e.g., "gTileset_MyTileset") |
| is_secondary | True for secondary tilesets, false for primary |
Implements porytiles::PorytilesTilesetManager.
Definition at line 213 of file project_porytiles_tileset_manager.cpp.
| void porytiles::ProjectPorytilesTilesetManager::write | ( | const std::string & | tileset_name, |
| const TilesetManifest & | artifacts | ||
| ) | const |
Writes an TilesetManifest object to the porytiles utility directory.
Creates the directory structure porytiles/tilesets/{tileset_name}/ if it doesn't exist, then writes tileset-manifest.json with 2-space indented JSON formatting.
| tileset_name | The name of the tileset (e.g., "gTileset_General") |
| artifacts | The TilesetManifest data to serialize |
tileset-manifest.json exists at {project_root}/porytiles/tilesets/{tileset_name}/ Definition at line 87 of file project_porytiles_tileset_manager.cpp.