Events base.
This commit is contained in:
@ -55,8 +55,8 @@ for jsonFile in jsonFiles:
|
||||
f.write(f"// Generated event header for {jsonFile}\n")
|
||||
f.write(f"// Generated at {now}\n")
|
||||
f.write("#pragma once\n\n")
|
||||
f.write("#include \"event/event.h\"\n\n")
|
||||
f.write(f"static const event_t EVENT_{key.upper()} = {{\n")
|
||||
f.write("#include \"event/eventdata.h\"\n\n")
|
||||
f.write(f"static const eventdata_t EVENT_{key.upper()} = {{\n")
|
||||
f.write(f" .itemCount = {len(data['items'])},\n")
|
||||
f.write(f" .items = {{\n")
|
||||
for i, item in enumerate(data['items']):
|
||||
@ -69,14 +69,11 @@ for jsonFile in jsonFiles:
|
||||
|
||||
# Text(s) Type
|
||||
if itemType == 'text':
|
||||
if 'texts' not in item or not isinstance(item['texts'], list) or len(item['texts']) == 0:
|
||||
print(f"Error: Item {i} in '{jsonFile}' of type 'text' does not contain 'texts' field.")
|
||||
if 'text' not in item:
|
||||
print(f"Error: Item {i} in '{jsonFile}' of type 'text' does not contain 'text' field.")
|
||||
sys.exit(1)
|
||||
f.write(f" .type = EVENT_TYPE_TEXT,\n")
|
||||
f.write(f" .texts = {{\n")
|
||||
for text in item['texts']:
|
||||
f.write(f" \"{text}\",\n")
|
||||
f.write(f" }},\n")
|
||||
f.write(f" .text = \"{item['text']}\",\n")
|
||||
|
||||
|
||||
else:
|
||||
@ -87,4 +84,20 @@ for jsonFile in jsonFiles:
|
||||
f.write(f" }},\n")
|
||||
f.write(f"}};\n\n")
|
||||
|
||||
eventFiles.append(key)
|
||||
eventFiles.append(key)
|
||||
|
||||
# Write the event list header
|
||||
eventListFile = os.path.join(outputDir, "eventlist.h")
|
||||
with open(eventListFile, 'w', encoding='utf-8') as f:
|
||||
f.write(f"// Generated event list header\n")
|
||||
f.write(f"// Generated at {now}\n")
|
||||
f.write("#pragma once\n\n")
|
||||
f.write("#include \"event/event.h\"\n")
|
||||
for event in eventFiles:
|
||||
f.write(f"#include \"event/{event}.h\"\n")
|
||||
f.write("\n")
|
||||
f.write(f"#define EVENT_LIST_COUNT {len(eventFiles)}\n\n")
|
||||
f.write("static const eventdata_t* EVENT_LIST[EVENT_LIST_COUNT] = {\n")
|
||||
for event in eventFiles:
|
||||
f.write(f" &EVENT_{event.upper()},\n")
|
||||
f.write("};\n\n")
|
Reference in New Issue
Block a user