diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2019-03-17 15:30:43 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2019-03-25 09:33:18 +0200 |
commit | 662d78b9a5bebdb98dc178ebd1f8e3384793c104 (patch) | |
tree | ea02633b41bd08957d3490d40553d389b1e78a36 /tools/vbatch2c.py |
Diffstat (limited to 'tools/vbatch2c.py')
-rw-r--r-- | tools/vbatch2c.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/vbatch2c.py b/tools/vbatch2c.py new file mode 100644 index 0000000..fdfbf92 --- /dev/null +++ b/tools/vbatch2c.py @@ -0,0 +1,36 @@ +import sys, os, operator, xml.etree.ElementTree + +zones = [] +d = os.fsencode(sys.argv[1]) +for f in os.listdir(d): + fname = os.fsdecode(f) + if not fname.endswith('.vbatch'): + continue + + e = xml.etree.ElementTree.parse(fname).getroot() + s = e.find('Batchs').find('VStartEventBox') + if s: + name = os.path.splitext(fname)[0] + name = name if name.endswith('TUTORIAL') or name.endswith('GOLDENCITADEL') or name.endswith('STEELGRAVE') else name.split('_', 1)[-1] + zone = { + 'id': s.find('m_ID').get('value')[0:5], + 'name': name, + 'tl': s.find('m_vPosTopLeft').get('value'), + 'br': s.find('m_vPosBottomRight').get('value') + } + zones.append(zone) + +zones = sorted(zones, key=operator.itemgetter('name')) + +print('#pragma once\n') + +print('''static const struct { + float box[2][3]; + const char *name; + uint32_t id; +} ZONES[] = {''') + +for z in zones: + print(' {{ .id = {}, .name = "{}", .box = {{ {{ {} }}, {{ {} }} }} }},'.format(z['id'], z['name'], z['tl'], z['br'])) + +print('};\n') |