summary refs log tree commit diff stats
path: root/src/common/make-te.py
blob: a1da564345755ed6c8995c6ca057fcc93f225039 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3

import sys

inf = open(sys.argv[1])
eventf = open(sys.argv[2], 'w')
enumsf = open(sys.argv[3], 'w')

enumsf.write(\
'''
/* this file is auto generated, edit textevents.in instead! */

enum
{
''')

eventf.write(\
'''
/* this file is auto generated, edit textevents.in instead! */

const struct text_event te[] = {
''')

try:
	while True:
		name = inf.readline().strip()
		event_enum = inf.readline().strip()
		event_help = inf.readline().strip()
		event_str = inf.readline().strip()
		args = inf.readline().strip()
		translate = True

		if args[0] == 'n':
			args = int(args[1]) | 128
			translate = False
		else:
			args = int(args)

		if translate:
			event_str = 'N_("%s")' %event_str
		else:
			event_str = '"%s"' %event_str

		enumsf.write('\t%s,\n' %event_enum)
		eventf.write('\n{"%s", %s, %u,\n%s},\n' %(
			name, event_help, args, event_str,
		))

		inf.readline() # whitespace
except IndexError:
    pass

enumsf.write('\tNUM_XP\n};\n')
eventf.write('};\n')