diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mkasset.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/mkasset.py b/tools/mkasset.py index 3ca8a1d..fd2ead7 100644 --- a/tools/mkasset.py +++ b/tools/mkasset.py | |||
@@ -12,11 +12,11 @@ | |||
12 | # | 12 | # |
13 | import argparse | 13 | import argparse |
14 | import ctypes | 14 | import ctypes |
15 | import os | ||
16 | from PIL import Image | ||
17 | import sys | 15 | import sys |
18 | from xml.etree import ElementTree | 16 | from xml.etree import ElementTree |
19 | 17 | ||
18 | from PIL import Image | ||
19 | |||
20 | # Maximum length of path strings in .TS and .TM files. | 20 | # Maximum length of path strings in .TS and .TM files. |
21 | # Must match the engine's value. | 21 | # Must match the engine's value. |
22 | MAX_PATH_LENGTH = 128 | 22 | MAX_PATH_LENGTH = 128 |
@@ -291,20 +291,24 @@ def convert_sprite_sheet(input_file_paths, sprite_width, sprite_height, | |||
291 | 291 | ||
292 | 292 | ||
293 | def main(): | 293 | def main(): |
294 | # TODO: Use subparser for each type of input file. | ||
294 | parser = argparse.ArgumentParser() | 295 | parser = argparse.ArgumentParser() |
295 | parser.add_argument("input", | 296 | parser.add_argument("input", |
296 | nargs="+", | 297 | nargs="+", |
297 | help="Input file (.tsx, .tmx) or path regex (sprite sheets)") | 298 | help="Input file (.tsx, .tmx) or path regex (sprite sheets)") |
298 | parser.add_argument("--width", type=int, help="Sprite width in pixels") | 299 | parser.add_argument("-W", "--width", type=int, help="Sprite width in pixels") |
299 | parser.add_argument("--height", type=int, help="Sprite height in pixels") | 300 | parser.add_argument("-H", "--height", type=int, help="Sprite height in pixels") |
300 | parser.add_argument("--out", help="Output file (sprite sheets)") | 301 | parser.add_argument("-o", "--out", help="Output file (sprite sheets)") |
301 | args = parser.parse_args() | 302 | args = parser.parse_args() |
302 | 303 | ||
303 | if ".tsx" in args.input: | 304 | # TODO: Add support for TSX files made from a single image. Currently, only collections are supported. |
305 | if ".tsx" in args.input[0]: | ||
306 | args.input = args.input[0] # TODO: Remove this. | ||
304 | output_filepath_no_ext = drop_extension(args.input) | 307 | output_filepath_no_ext = drop_extension(args.input) |
305 | output_filepath = output_filepath_no_ext + ".ts" | 308 | output_filepath = output_filepath_no_ext + ".ts" |
306 | convert_tsx(args.input, output_filepath) | 309 | convert_tsx(args.input, output_filepath) |
307 | elif ".tmx" in args.input: | 310 | elif ".tmx" in args.input[0]: |
311 | args.input = args.input[0] # TODO: Remove this. | ||
308 | output_filepath_no_ext = drop_extension(args.input) | 312 | output_filepath_no_ext = drop_extension(args.input) |
309 | output_filepath = output_filepath_no_ext + ".tm" | 313 | output_filepath = output_filepath_no_ext + ".tm" |
310 | convert_tmx(args.input, output_filepath) | 314 | convert_tmx(args.input, output_filepath) |