diff options
author | Jesusaves <cpntb1@ymail.com> | 2022-11-12 17:59:15 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2022-11-12 17:59:15 -0300 |
commit | cacb8c677523dfb1e992530adbb4819ee6e3c5cc (patch) | |
tree | 0e77dbd59b1493243dd1b16d60f2b60926faa6a8 /tmx_converter.py | |
parent | 58a23ddadfc9afc4573601d9b950a38c1607e1e4 (diff) | |
download | tools-cacb8c677523dfb1e992530adbb4819ee6e3c5cc.tar.gz tools-cacb8c677523dfb1e992530adbb4819ee6e3c5cc.tar.bz2 tools-cacb8c677523dfb1e992530adbb4819ee6e3c5cc.tar.xz tools-cacb8c677523dfb1e992530adbb4819ee6e3c5cc.zip |
Rename dest_tile_* to dest_* for uniformity with Evolved toolset
Diffstat (limited to 'tmx_converter.py')
-rwxr-xr-x | tmx_converter.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tmx_converter.py b/tmx_converter.py index c6b4e52..404d58d 100755 --- a/tmx_converter.py +++ b/tmx_converter.py @@ -97,11 +97,18 @@ class Node(Object): def __init__(self): self.subtype = 0 +class Switch(Object): + __slots__ = ( + 'subtype' + ) + def __init__(self): + self.subtype = 0 + class Warp(Object): __slots__ = ( 'dest_map', - 'dest_tile_x', - 'dest_tile_y', + 'dest_x', + 'dest_y', ) + other_warp_fields class ContentHandler(xml.sax.ContentHandler): @@ -232,6 +239,8 @@ class ContentHandler(xml.sax.ContentHandler): if w == x and h == y: w = 0 h = 0 + elif obj_type == 'switch': + self.object = Switch() else: if obj_type not in other_object_types: print('Unknown object type:', obj_type, file=sys.stderr) @@ -295,7 +304,14 @@ class ContentHandler(xml.sax.ContentHandler): SEPARATOR.join([ '%s,%d,%d' % (self.base, obj.x, obj.y), 'warp', - '%d,%d,%s,%d,%d\n' % (obj.w, obj.h, obj.dest_map, obj.dest_tile_x, obj.dest_tile_y), + '%d,%d,%s,%d,%d\n' % (obj.w, obj.h, obj.dest_map, obj.dest_x, obj.dest_y), + ]) + ) + elif isinstance(obj, Switch): + obj_name = "#%s_%s_%s" % (self.base, obj.x, obj.y) + self.warps.write( + SEPARATOR.join([ + '%s,%d,%d,0|script|%s|422\n{\n\t// REPLACE ME\n}\n' % (self.base, obj.x, obj.y, obj_name), ]) ) elif isinstance(obj, Node): |