diff options
| author | 3gg <3gg@shellblade.net> | 2025-09-02 18:41:59 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-09-02 18:41:59 -0700 |
| commit | e6bf7e77797103ee7ab0eda57c360c38f1b2089c (patch) | |
| tree | b0cb40caf98c18e490b81feb59f9f26d47593670 /tools | |
| parent | 5278a117ee31c911106346e60018e13c8f3e79fc (diff) | |
Add map orientation.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/mkasset.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/mkasset.py b/tools/mkasset.py index 62d1d88..f21a2f9 100644 --- a/tools/mkasset.py +++ b/tools/mkasset.py | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | import argparse | 13 | import argparse |
| 14 | import ctypes | 14 | import ctypes |
| 15 | import sys | 15 | import sys |
| 16 | from enum import IntEnum | ||
| 16 | from typing import Generator | 17 | from typing import Generator |
| 17 | from xml.etree import ElementTree | 18 | from xml.etree import ElementTree |
| 18 | 19 | ||
| @@ -23,6 +24,12 @@ from PIL import Image | |||
| 23 | MAX_PATH_LENGTH = 128 | 24 | MAX_PATH_LENGTH = 128 |
| 24 | 25 | ||
| 25 | 26 | ||
| 27 | class Orientation(IntEnum): | ||
| 28 | """Map orientation. Must match Tm_Orientation in asset.h""" | ||
| 29 | Orthogonal = 0 | ||
| 30 | Isometric = 1 | ||
| 31 | |||
| 32 | |||
| 26 | def drop_extension(filepath): | 33 | def drop_extension(filepath): |
| 27 | return filepath[:filepath.rfind('.')] | 34 | return filepath[:filepath.rfind('.')] |
| 28 | 35 | ||
| @@ -178,11 +185,13 @@ def convert_tmx(input_filepath, output_filepath): | |||
| 178 | base_tile_width = int(root.attrib["tilewidth"]) | 185 | base_tile_width = int(root.attrib["tilewidth"]) |
| 179 | base_tile_height = int(root.attrib["tileheight"]) | 186 | base_tile_height = int(root.attrib["tileheight"]) |
| 180 | num_layers = 1 | 187 | num_layers = 1 |
| 188 | flags = Orientation.Isometric if (root.attrib["orientation"] == "isometric") else Orientation.Orthogonal | ||
| 181 | 189 | ||
| 182 | print(f"Map width: {map_width}") | 190 | print(f"Map width: {map_width}") |
| 183 | print(f"Map height: {map_height}") | 191 | print(f"Map height: {map_height}") |
| 184 | print(f"Tile width: {base_tile_width}") | 192 | print(f"Tile width: {base_tile_width}") |
| 185 | print(f"Tile height: {base_tile_height}") | 193 | print(f"Tile height: {base_tile_height}") |
| 194 | print(f"Orientation: {flags}") | ||
| 186 | 195 | ||
| 187 | tileset_path = None | 196 | tileset_path = None |
| 188 | 197 | ||
| @@ -205,6 +214,7 @@ def convert_tmx(input_filepath, output_filepath): | |||
| 205 | output.write(ctypes.c_uint16(base_tile_width)) | 214 | output.write(ctypes.c_uint16(base_tile_width)) |
| 206 | output.write(ctypes.c_uint16(base_tile_height)) | 215 | output.write(ctypes.c_uint16(base_tile_height)) |
| 207 | output.write(ctypes.c_uint16(num_layers)) | 216 | output.write(ctypes.c_uint16(num_layers)) |
| 217 | output.write(ctypes.c_uint16(flags)) | ||
| 208 | elif child.tag == "layer": | 218 | elif child.tag == "layer": |
| 209 | layer = child | 219 | layer = child |
| 210 | layer_id = int(layer.attrib["id"]) | 220 | layer_id = int(layer.attrib["id"]) |
