1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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')
|