diff --git a/tools/scripts/convert_sprite_json.py b/tools/scripts/convert_sprite_json.py new file mode 100644 index 0000000..f45bb84 --- /dev/null +++ b/tools/scripts/convert_sprite_json.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import sys + + +TEMPLATE = r""" + + + + + +""" + + +def main(args): + this_dir = os.path.dirname(os.path.realpath(__file__)) + sneak_root = os.path.join(this_dir, '..', '..', '..') + os.chdir(sneak_root) + + json_files = sorted(glob.glob('Content/sprites/**/*.json', recursive=True)) + for json_file in json_files: + with open(json_file) as json: + outfile_name = re.sub(r'.json$', '_json.xml', json_file) + result = TEMPLATE % json.read() + with open(outfile_name, 'w') as out: + out.write(result) + + return 0 + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:]))