From 662d78b9a5bebdb98dc178ebd1f8e3384793c104 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 17 Mar 2019 15:30:43 +0200 Subject: Initial commit --- tools/vbatch2c.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/vbatch2c.py (limited to 'tools/vbatch2c.py') 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') -- cgit v1.2.3