summaryrefslogtreecommitdiff
path: root/pokemontools/map_editor.py
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-09-15 15:46:26 -0400
committeryenatch <yenatch@gmail.com>2013-09-15 15:46:26 -0400
commit33c8e4147c9a188b677a0995e8f9ce0760a2d60e (patch)
tree4893d091e06d07e412367ebf05997bfbf340db1e /pokemontools/map_editor.py
parentbd3b6081888e0602432c0328e6f44bfc7d0b7f63 (diff)
map_editor: red: read tileset gfx filenames from source
Diffstat (limited to 'pokemontools/map_editor.py')
-rw-r--r--pokemontools/map_editor.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/pokemontools/map_editor.py b/pokemontools/map_editor.py
index 92e4a63..208cc49 100644
--- a/pokemontools/map_editor.py
+++ b/pokemontools/map_editor.py
@@ -348,11 +348,27 @@ class Tileset:
self.get_blocks()
self.get_tiles()
+ def get_tileset_gfx_filename(self):
+ filename = None
+
+ if version == 'red':
+ tileset_defs = open(os.path.join(conf.path, 'main.asm'), 'r').read()
+ incbin = asm_at_label(tileset_defs, 'Tset%.2X_GFX' % self.id)
+ print incbin
+ filename = read_header_macros(incbin, ['filename'], ['INCBIN'])[0][0].replace('"','').replace('.2bpp','.png')
+ filename = os.path.join(conf.path, filename)
+ print filename
+
+ if not filename:
+ filename = os.path.join(
+ gfx_dir,
+ to_gfx_name(self.id) + '.png'
+ )
+
+ return filename
+
def get_tiles(self):
- filename = os.path.join(
- gfx_dir,
- to_gfx_name(self.id) + '.png'
- )
+ filename = self.get_tileset_gfx_filename()
self.img = Image.open(filename)
self.img.width, self.img.height = self.img.size
self.tiles = []