|
Porytiles
|
Parses and writes animation configuration JSON files (anim.json). More...
#include <anim_json_parser.hpp>
Public Member Functions | |
| AnimJsonParser (gsl::not_null< const TextFormatter * > format) | |
| ChainableResult< std::map< DynamicCasedName, AnimParams > > | parse (const std::filesystem::path &json_path) const |
| Parses an anim.json file into a map of animation parameters. | |
| ChainableResult< std::map< DynamicCasedName, std::vector< AnimOverrideEntry > > > | parse_primary_references (const std::filesystem::path &json_path) const |
| Parses the primary_references section from an anim.json file. | |
| ChainableResult< void > | write (const std::filesystem::path &json_path, const std::map< DynamicCasedName, AnimParams > ¶ms, const std::map< DynamicCasedName, std::vector< AnimOverrideEntry > > &primary_references={}) const |
| Writes animation parameters to an anim.json file. | |
Parses and writes animation configuration JSON files (anim.json).
AnimJsonParser handles reading and writing of anim.json files, which define animation parameters for a tileset's Porytiles component. The JSON structure maps animation names to their configuration parameters.
Example anim.json structure:
Fields:
Note: tile_offset and tile_count are NOT stored in anim.json - they are computed during compilation and stored in generated_anim_code.h.
Definition at line 51 of file anim_json_parser.hpp.
|
explicit |
Definition at line 281 of file anim_json_parser.cpp.
| ChainableResult< std::map< DynamicCasedName, AnimParams > > porytiles::AnimJsonParser::parse | ( | const std::filesystem::path & | json_path | ) | const |
Parses an anim.json file into a map of animation parameters.
Reads the JSON file at the specified path and extracts animation parameters for each animation defined. Missing optional fields use default values from AnimParams.
| json_path | Path to the anim.json file |
Definition at line 284 of file anim_json_parser.cpp.
| ChainableResult< std::map< DynamicCasedName, std::vector< AnimOverrideEntry > > > porytiles::AnimJsonParser::parse_primary_references | ( | const std::filesystem::path & | json_path | ) | const |
Parses the primary_references section from an anim.json file.
Reads the JSON file and extracts only the "primary_references" key, which maps primary animation names to override entries. This is used by secondary tilesets to manually link metatile entries to primary animation tile ranges.
| json_path | Path to the anim.json file |
Definition at line 419 of file anim_json_parser.cpp.
| ChainableResult< void > porytiles::AnimJsonParser::write | ( | const std::filesystem::path & | json_path, |
| const std::map< DynamicCasedName, AnimParams > & | params, | ||
| const std::map< DynamicCasedName, std::vector< AnimOverrideEntry > > & | primary_references = {} |
||
| ) | const |
Writes animation parameters to an anim.json file.
Serializes the provided animation parameters map to JSON format and writes to the specified path. Overwrites any existing file at that location. Optionally includes a primary_references section for secondary tilesets.
| json_path | Path to write the anim.json file |
| params | Map of animation name to AnimParams to serialize |
| primary_references | Map of primary animation name to override entries (optional, omitted when empty) |
Definition at line 520 of file anim_json_parser.cpp.