summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorwushin <pasekei@gmail.com>2013-07-14 16:39:27 -0500
committerBen Longbons <b.r.longbons@gmail.com>2013-07-15 12:22:58 -0700
commit47a8ea2b46d884ee7683c54f813cd804ca822a1b (patch)
tree8501dacd8d26b254a1412dc8ca71c4d19cc96820 /tools
parent257f4ab0de3bf552cdb1e9012aa27c1c5ec40814 (diff)
downloadserverdata-47a8ea2b46d884ee7683c54f813cd804ca822a1b.tar.gz
serverdata-47a8ea2b46d884ee7683c54f813cd804ca822a1b.tar.bz2
serverdata-47a8ea2b46d884ee7683c54f813cd804ca822a1b.tar.xz
serverdata-47a8ea2b46d884ee7683c54f813cd804ca822a1b.zip
Allow specifying warps in terms of tiles instead of pixels
This interprets properties dest_tile_[xy] instead of dest_[xy]. Accepts both formats, but errors if there is a combination.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/tmx_converter.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/tmx_converter.py b/tools/tmx_converter.py
index 009a1145..379a4f34 100755
--- a/tools/tmx_converter.py
+++ b/tools/tmx_converter.py
@@ -92,6 +92,8 @@ class Warp(Object):
'dest_map',
'dest_x',
'dest_y',
+ 'dest_tile_x',
+ 'dest_tile_y',
) + other_warp_fields
class ContentHandler(xml.sax.ContentHandler):
@@ -264,12 +266,22 @@ class ContentHandler(xml.sax.ContentHandler):
])
)
elif isinstance(obj, Warp):
+ nx = hasattr(obj, 'dest_tile_x')
+ ny = hasattr(obj, 'dest_tile_y')
+ ox = hasattr(obj, 'dest_x')
+ oy = hasattr(obj, 'dest_y')
+ assert nx == ny != ox == oy, 'Error: mixed coordinate properties exist.'
+
+ if ox:
+ obj.dest_tile_x = obj.dest_x / 32;
+ obj.dest_tile_y = obj.dest_y / 32;
+
self.warps.write(
SEPARATOR.join([
'%s.gat,%d,%d' % (self.base, obj.x, obj.y),
'warp',
obj.name,
- '%d,%d,%s.gat,%d,%d\n' % (obj.w, obj.h, obj.dest_map, obj.dest_x / 32, obj.dest_y / 32),
+ '%d,%d,%s.gat,%d,%d\n' % (obj.w, obj.h, obj.dest_map, obj.dest_tile_x, obj.dest_tile_y),
])
)