summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petithory <vincent.petithory@gmail.com>2013-02-18 23:11:40 +0100
committerVincent Petithory <vincent.petithory@gmail.com>2013-02-18 23:32:23 +0100
commit2daee52eec6ace68bf49779acba61056aeba11be (patch)
treed03e3d310ffa724eb1c7b912304b18fe08b1bfd2
parent40623c146ac1e5210d20bcb47d313c2659c665f2 (diff)
downloadtools-2daee52eec6ace68bf49779acba61056aeba11be.tar.gz
tools-2daee52eec6ace68bf49779acba61056aeba11be.tar.bz2
tools-2daee52eec6ace68bf49779acba61056aeba11be.tar.xz
tools-2daee52eec6ace68bf49779acba61056aeba11be.zip
Map tools: use new --tilesize option of tmwrasterizer and update some things
-rwxr-xr-xclient/map-diff.py20
-rwxr-xr-xclient/minimap-render.py23
2 files changed, 27 insertions, 16 deletions
diff --git a/client/map-diff.py b/client/map-diff.py
index b872d47..1da5cde 100755
--- a/client/map-diff.py
+++ b/client/map-diff.py
@@ -75,11 +75,13 @@ class MapDiff(object):
def _rastermap(self, tmx):
tmxf, tmxraster = tempfile.mkstemp(suffix='.png')
- subprocess.check_call([self.platform_programs.get('tmxrasterizer'), tmx, tmxraster])
+ subprocess.check_call([
+ self.platform_programs.get('tmxrasterizer'),
+ '--scale', '1.0',
+ tmx, tmxraster
+ ])
if os.stat(tmxraster).st_size == 0:
- # the image couldnt be rendered. The most probable reason is
- # that the map was too big (e.g 024-4, 500x500 tiles)
- raise Exception('Map too large to be rendered.')
+ raise Exception('A problem was encountered when rendering a map')
return tmxraster
@@ -107,10 +109,12 @@ class MapGitRevDiff(MapDiff):
# We have the 2 revs to compare. Let's extract the related tmx file
p1 = self._mktmx_from_rev(c1)
p2 = self._mktmx_from_rev(c2)
- difftmxpath = '%s_%s-%s.png' % (self.map_number, c1, c2)
- self._diffmaps(p1, p2, difftmxpath)
- os.unlink(p1)
- os.unlink(p2)
+ try:
+ difftmxpath = '%s_%s-%s.png' % (self.map_number, c1, c2)
+ self._diffmaps(p1, p2, difftmxpath)
+ finally:
+ os.unlink(p1)
+ os.unlink(p2)
def _mktmx_from_rev(self, rev):
p = subprocess.Popen([self.platform_programs.get('git'), '--no-pager', 'show', '%s:%s' % (rev, self.tmx_path)], stdout=subprocess.PIPE)
diff --git a/client/minimap-render.py b/client/minimap-render.py
index 402630b..6b6b009 100755
--- a/client/minimap-render.py
+++ b/client/minimap-render.py
@@ -22,9 +22,10 @@ class MinimapRenderer(object):
},
}
- def __init__(self, map_name, scale):
+ def __init__(self, map_name, tilesize, useAntiAliasing):
self.map_name = map_name
- self.scale = scale
+ self.tilesize = tilesize
+ self.useAntiAliasing = useAntiAliasing
def render(self):
"""
@@ -58,11 +59,16 @@ class MinimapRenderer(object):
platform_programs = MinimapRenderer.PROGRAMS.get(sys.platform, MinimapRenderer.PROGRAMS.get('default'))
# tmx rasterize
mrf, map_raster = tempfile.mkstemp(suffix='.png')
- subprocess.check_call([platform_programs.get('tmxrasterizer'), '--scale', str(self.scale), tmx_file, map_raster])
+ tmxrasterizer_cmd = [
+ platform_programs.get('tmxrasterizer'),
+ '--tilesize', str(self.tilesize),
+ ]
+ if self.useAntiAliasing:
+ tmxrasterizer_cmd.append('--anti-aliasing')
+ tmxrasterizer_cmd += [tmx_file, map_raster]
+ subprocess.check_call(tmxrasterizer_cmd)
if os.stat(map_raster).st_size == 0:
- # the image couldnt be rendered. The most probable reason is
- # that the map was too big (e.g 024-4, 500x500 tiles)
- raise Exception('Map too large to be rendered.')
+ raise Exception('A problem was encountered when rendering a map')
# add cell-shading to the minimap to improve readability
ebf, edges_bitmap = tempfile.mkstemp(suffix='.png')
subprocess.check_call([
@@ -140,9 +146,10 @@ def main():
status = 0
for map_name in sys.argv[1:]:
- map_renderer = MinimapRenderer(map_name, 0.03125) # this scale renders 1px for a tile of 32px
+ # Render tiles at 1 pixel size
+ map_renderer = MinimapRenderer(map_name, 1, True)
status += map_renderer.render()
return status
if __name__ == '__main__':
- sys.exit(main()) \ No newline at end of file
+ sys.exit(main())