2021-11-05 18:23:49 +01:00
|
|
|
#!/usr/bin/env python3
|
2021-11-12 21:22:47 +01:00
|
|
|
import io
|
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
|
2021-11-17 12:08:20 +01:00
|
|
|
BIN_DIR = REPO_DIR / "bin"
|
2021-10-19 16:56:11 +02:00
|
|
|
SRC_DIR = REPO_DIR / "src"
|
2021-11-17 12:08:20 +01:00
|
|
|
CONFIG_DIR = BIN_DIR / "cfg"
|
2021-03-17 12:14:43 +01:00
|
|
|
|
|
|
|
|
2021-12-04 03:15:21 +01:00
|
|
|
BODY_PREFIX = """
|
|
|
|
#include "game/gameflow.h"
|
2022-05-13 00:24:21 +02:00
|
|
|
#include "global/types.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2021-12-04 03:15:21 +01:00
|
|
|
|
|
|
|
// THIS IS AN AUTOGENERATED FILE.
|
2022-05-13 00:56:28 +02:00
|
|
|
// To generate it, run tools/generate_init.
|
2021-12-04 03:15:21 +01:00
|
|
|
|
|
|
|
#ifndef VERSION
|
|
|
|
#define VERSION "T1M (unknown version)"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const char *g_T1MVersion = VERSION;
|
|
|
|
|
2022-01-18 22:40:08 +01:00
|
|
|
GAMEFLOW_DEFAULT_STRING g_GameFlowDefaultStrings[] = {"""
|
2021-12-04 03:15:21 +01:00
|
|
|
|
|
|
|
BODY_SUFFIX = """ { 0, NULL },
|
|
|
|
};
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
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-11-12 21:22:47 +01:00
|
|
|
with io.StringIO() as handle:
|
2021-12-04 03:15:21 +01:00
|
|
|
print(BODY_PREFIX.lstrip(), file=handle)
|
2021-03-17 12:14:43 +01:00
|
|
|
for key, value in gf["strings"].items():
|
2021-12-04 03:15:21 +01:00
|
|
|
print(f" {{ GS_{key}, {json.dumps(value)} }},", file=handle)
|
|
|
|
print(BODY_SUFFIX.rstrip(), file=handle)
|
2021-11-12 21:22:47 +01:00
|
|
|
new_text = handle.getvalue()
|
|
|
|
|
|
|
|
path = SRC_DIR / "init.c"
|
|
|
|
if path.read_text() != new_text:
|
|
|
|
path.write_text(new_text)
|
2021-03-17 12:14:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|