From c3eece55350d4dc5e3bd56ac7b464f43836ad4b0 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Sun, 20 Oct 2019 12:55:40 -0500 Subject: [PATCH] compose: handle multiple entries in a single `tile_entry.json` file Fixes #34884 Adjust compose so it can handle multiple tile_entry objects in a single file. --- doc/TILESET.md | 11 +++++++++++ tools/gfx_tools/compose.py | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/TILESET.md b/doc/TILESET.md index 431ca2d5bec68..51dc6136ed09e 100644 --- a/doc/TILESET.md +++ b/doc/TILESET.md @@ -69,6 +69,17 @@ The special prefixes `overlay_wielded_`, `overlay_female_wielded_`, `overlay_mal `"multitle"` is an *optional* field. If it is present and `true`, there must be an `additional_tiles` list with 1 or more dictionaries for entities and sprites associated with this tile, such as broken versions of an item or wall connections. Each dictionary in the list has an `"id`" field, as above, and a `"fg"` field, which can be a single filename, a list of filenames, or a list of dictionaries as above. +Each `tile_entry.json` file can have a single object in it, or a list of 1 or more objects like so: +```C++ +[ + { "id": "mon_zombie", "fg": "mon_zombie", "bg": "mon_zombie_bg", "rotates": false }, + { "id": "corpse_mon_zombie", "fg": "mon_zombie_corpse", "bg": "mon_zombie_bg", "rotates": false }, + { "id": "overlay_wielding_corse_mon_zombie", "fg": "wielded_mon_zombie_corpse", "bg": [], "rotates": false } +] +``` + +Having a list of tile entries in a file may be useful for organization, but completely unrelated entries may all exist in the same file without any complications. + #### expansion `tile_entry` JSON Tilesheets can have expansion tilesheets, which are tilesheets from mods. Each expansion tilesheet is a single `"id"` value, `"rotates": false"`, and `"fg": 0`. Expansion `tile_entry` JSON are the only `tile_entry` JSONs that use an integer value for `"fg"` and that value must be 0. Expansion `tile_entry` JSONs must be located at the top layer of each image directory. diff --git a/tools/gfx_tools/compose.py b/tools/gfx_tools/compose.py index 5e2f94e80a578..bf5b243d3a33a 100644 --- a/tools/gfx_tools/compose.py +++ b/tools/gfx_tools/compose.py @@ -278,7 +278,9 @@ def walk_dirs(self, refs): print("error loading {}".format(filepath)) raise - self.tile_entries.append(tile_entry) + if not isinstance(tile_entry, list): + tile_entry = [tile_entry] + self.tile_entries += tile_entry if self.row_pngs: merged = self.merge_row(refs) tmp_merged_pngs += merged