summaryrefslogtreecommitdiff
path: root/tools/vbatch2c.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/vbatch2c.py')
-rw-r--r--tools/vbatch2c.py36
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')