2021-11-05 18:23:49 +01:00
|
|
|
#!/usr/bin/env python3
|
2021-03-17 12:14:43 +01:00
|
|
|
import json
|
2021-11-05 18:23:49 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
2021-03-17 12:14:43 +01:00
|
|
|
import pyjson5
|
|
|
|
|
2021-10-19 16:56:11 +02:00
|
|
|
REPO_DIR = Path(__file__).parent.parent
|
|
|
|
CONFIG_DIR = REPO_DIR / "cfg"
|
|
|
|
SRC_DIR = REPO_DIR / "src"
|
2021-03-17 12:14:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
gf = pyjson5.loads(
|
2021-10-19 16:56:11 +02:00
|
|
|
(CONFIG_DIR / "Tomb1Main_gameflow.json5").read_text(encoding="utf-8")
|
2021-03-17 12:14:43 +01:00
|
|
|
)
|
2021-11-05 18:23:49 +01:00
|
|
|
|
2021-10-19 16:56:11 +02:00
|
|
|
with (SRC_DIR / "init.c").open("w") as handle:
|
2021-03-17 12:14:43 +01:00
|
|
|
print('#include "init.h"', file=handle)
|
|
|
|
print(file=handle)
|
2021-03-21 21:17:46 +01:00
|
|
|
print('#include "global/vars.h"', file=handle)
|
2021-03-17 12:14:43 +01:00
|
|
|
print(file=handle)
|
2021-10-19 16:56:11 +02:00
|
|
|
print("// THIS IS AN AUTOGENERATED FILE.", file=handle)
|
|
|
|
print("// To generate it, run scripts/generate_init.", file=handle)
|
|
|
|
print("", file=handle)
|
2021-11-05 18:23:49 +01:00
|
|
|
print("#ifndef VERSION", file=handle)
|
|
|
|
print(' #define VERSION "T1M (unknown version)"', file=handle)
|
|
|
|
print("#endif", file=handle)
|
|
|
|
print("", file=handle)
|
|
|
|
print("const char *T1MVersion = VERSION;", file=handle)
|
|
|
|
print("", file=handle)
|
2021-03-17 12:14:43 +01:00
|
|
|
print("void T1MInit()", file=handle)
|
|
|
|
print("{", file=handle)
|
|
|
|
for key, value in gf["strings"].items():
|
|
|
|
print(
|
|
|
|
f" GF.strings[GS_{key}] = {json.dumps(value)};",
|
|
|
|
file=handle,
|
|
|
|
)
|
|
|
|
print("}", file=handle)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|