From c6dcd9b9be874559d4d3d97f4f2fcb225b492c9b Mon Sep 17 00:00:00 2001 From: yenatch Date: Tue, 21 Apr 2015 09:49:02 -0700 Subject: Fix a modulo by 0 on a default argument to condense_tiles_to_map. --- pokemontools/gfx.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pokemontools/gfx.py') diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py index 066811a..90d6213 100644 --- a/pokemontools/gfx.py +++ b/pokemontools/gfx.py @@ -141,8 +141,9 @@ def condense_tiles_to_map(image, pic=0): new_tiles += [tile] # Match the first frame where possible. - if tile == new_tiles[i % pic]: - tilemap += [i % pic] + this_i = i % pic if pic else i + if tile == new_tiles[this_i]: + tilemap += [this_i] else: tilemap += [new_tiles.index(tile)] -- cgit v1.2.3 From 661004c96962f8d2191f2868bf0bf9734aec6f06 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 6 May 2015 16:50:16 -0700 Subject: remove yaml remove yaml undoes parts of 0182bcaf8f92e66396c17969b0753f2175603ccd --- pokemontools/gfx.py | 41 ++--------------------------------------- 1 file changed, 2 insertions(+), 39 deletions(-) (limited to 'pokemontools/gfx.py') diff --git a/pokemontools/gfx.py b/pokemontools/gfx.py index 90d6213..cb251d3 100644 --- a/pokemontools/gfx.py +++ b/pokemontools/gfx.py @@ -5,7 +5,6 @@ import sys import png from math import sqrt, floor, ceil import argparse -import yaml import operator import configuration @@ -687,50 +686,14 @@ def png_to_rgb(palette): return output -def read_yaml_arguments(filename, yaml_filename = os.path.join(config.path, 'gfx.yaml'), path_arguments = ['pal_file']): - - parsed_arguments = {} - - # Read arguments from gfx.yaml if it exists. - if os.path.exists(yaml_filename): - yargs = yaml.load(open(yaml_filename)) - dirs = os.path.splitext(filename)[0].split('/') - current_path = os.path.dirname(filename) - path = [] - while yargs: - for key, value in yargs.items(): - # Follow directories to the bottom while picking up keys. - # Try not to mistake other files for keys. - parsed_path = os.path.join( * (path + [key]) ) - for guessed_path in map(parsed_path.__add__, ['', '.png']): - if os.path.exists(guessed_path) or '.' in key: - if guessed_path != filename: - continue - if key in path_arguments: - value = os.path.join(current_path, value) - parsed_arguments[key] = value - if not dirs: - break - yargs = yargs.get(dirs[0], {}) - path.append(dirs.pop(0)) - - return parsed_arguments - -def read_filename_arguments(filename, yaml_filename = os.path.join(config.path, 'gfx.yaml'), path_arguments = ['pal_file']): +def read_filename_arguments(filename): """ Infer graphics conversion arguments given a filename. - If it exists, ./gfx.yaml is traversed for arguments. - Then additional arguments within the filename (separated with ".") are grabbed. + Arguments are separated with '.'. """ parsed_arguments = {} - parsed_arguments.update(read_yaml_arguments( - filename, - yaml_filename = yaml_filename, - path_arguments = path_arguments - )) - int_arguments = { 'w': 'width', 'h': 'height', -- cgit v1.2.3