add convert_sprite_json script
This commit is contained in:
parent
9672fabcfd
commit
bc369fcbc4
36
tools/scripts/convert_sprite_json.py
Normal file
36
tools/scripts/convert_sprite_json.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
TEMPLATE = r"""<?xml version="1.0" encoding="utf-8" ?>
|
||||
<XnaContent>
|
||||
<Asset Type="System.String">
|
||||
<![CDATA[
|
||||
%s
|
||||
]]>
|
||||
</Asset>
|
||||
</XnaContent>
|
||||
"""
|
||||
|
||||
|
||||
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:]))
|
Loading…
Reference in New Issue
Block a user