Open traeighsea opened 1 month ago
New tool options to export and import mapgrid data as json.
New tool options to export and import metatiles as json, accessible with the tileset editor open.
Option to load mapgrid data from json instead of bin.
Options to load metatile data from json instead of bin, as well as options to allow data that's different than the global tileset settings.
Description
Motivation
Implementation Details
For layouts, the json should be able to specify if you're using a bin or json file, and if it's a json file, compile it. This will involve updating the mapjson toolImplementation Details - Layout Mapgrid data
The layouts directory has data at:
data/layouts/<map>/(border|map).json
The data gets packed as a 16-bit number in the bin. So we store the size in bits (in case the user wants to change this), masks for each variable for the packed data which makes up the "header" data for the map and border. We then store the mapgrid data which is an array of mapgrid items that consist of a collection of variables needed that should correlate to the masks. Something to note is you can have more variables than is in the mask, this is by design, so only the data in the masks will make it into the packed variable.
Implementation Details - Tileset Metatile Attributes
Similarly to the tileset mapgrid data, we want to store a "header" of higher level information to describe the actual binary data. We store the size of the variable, the number of metatiles in the binary blob, and again the masks for the attribute data. It's important we store the num of metatiles because in FR/LG, RSE they have different num of primary and secondary tiles. This design can support any arbitrary combination of these tile numbers as long as you code it into the c code to deserialize it properly.
Implementation Details - Tileset Metatiles
Metatiles contain additional information in the header that describe the number of palettes in the tileset because you can have differing number of palettes for example in the case of RSE and FRLG. We also store the number of tiles, which correlate to the tiles in the actual "image". As well as the number of metatiles same as in the metatile attributes. The number of tiles in the metatiles are additionally stored because triple layer and any other arbitrary number of layers of these tiles can be added and specified.
Serializer tool
There should be a tool that builds the .bin files from the .json files. This should be called from the makefile to serialize as a step before the .bin files are used. Within the makefile we should add a new variable to enable or disable if you're using json files for the map layout jsons, as well as a variable for if you're using the metatile jsons.
The tool will use nlohmann's json library to pack the data based on the "header" information, using the attributeMasks to pack the data.
Migration tool
Similarly to the work performed in porymap, there should be a tool to export the bin data as a tool within the project.
Supporting Porymap work here: https://github.com/traeighsea/porymap/tree/feature/add-json-support-for-all-bin-files
Discord contact info
@traeighsea