summaryrefslogtreecommitdiff
path: root/gfx.py
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2016-02-17 16:15:18 -0500
committeryenatch <yenatch@gmail.com>2016-02-17 16:18:58 -0500
commit2ae8f65b426dff98d998bece374bea98b1e46dea (patch)
treeb99a59f550698c26fce18876bd8900305f6c7ffb /gfx.py
parent776dd6182347322f16f0d5e677f91b7ee68d112f (diff)
Try to fix pic dimensions.
Diffstat (limited to 'gfx.py')
-rw-r--r--gfx.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/gfx.py b/gfx.py
index ec5bbb9d8..b39d919ef 100644
--- a/gfx.py
+++ b/gfx.py
@@ -12,11 +12,23 @@ pics = [
'gfx/shrink2',
]
+def recursive_read(filename):
+ def recurse(filename_):
+ lines = []
+ for line in open(filename_):
+ if 'include "' in line.lower():
+ lines += recurse(line.split('"')[1])
+ else:
+ lines += [line]
+ return lines
+ lines = recurse(filename)
+ return ''.join(lines)
+
base_stats = None
def get_base_stats():
global base_stats
if not base_stats:
- base_stats = open('data/base_stats.asm').read()
+ base_stats = recursive_read('data/base_stats.asm')
return base_stats
def get_pokemon_dimensions(name):
@@ -25,7 +37,7 @@ def get_pokemon_dimensions(name):
if name.startswith('unown_'):
name = 'unown'
base_stats = get_base_stats()
- start = base_stats.find(name.title() + 'BaseData:')
+ start = base_stats.find('\tdb ' + name.upper())
start = base_stats.find('\tdn ', start)
end = base_stats.find('\n', start)
line = base_stats[start:end].replace(',', ' ')
@@ -37,12 +49,15 @@ def filepath_rules(filepath):
args = {}
filedir, filename = os.path.split(filepath)
+ if filedir.startswith('./'):
+ filedir = filedir[2:]
+
name, ext = os.path.splitext(filename)
pokemon_name = ''
if 'gfx/pics/' in filedir:
- pokemon_name = filedir.split('/')[3]
+ pokemon_name = filedir.split('/')[-1]
if pokemon_name.startswith('unown_'):
index = filedir.find(pokemon_name)
if index != -1: