mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-30 13:47:59 +03:00
54 lines
1.1 KiB
Python
Executable file
54 lines
1.1 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
import io
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pyjson5
|
|
|
|
REPO_DIR = Path(__file__).parent.parent
|
|
BIN_DIR = REPO_DIR / "bin"
|
|
SRC_DIR = REPO_DIR / "src"
|
|
CONFIG_DIR = BIN_DIR / "cfg"
|
|
|
|
|
|
BODY_PREFIX = """
|
|
#include "game/gameflow.h"
|
|
#include "global/types.h"
|
|
|
|
#include <stddef.h>
|
|
|
|
// THIS IS AN AUTOGENERATED FILE.
|
|
// To generate it, run tools/generate_init.
|
|
|
|
#ifndef VERSION
|
|
#define VERSION "T1M (unknown version)"
|
|
#endif
|
|
|
|
const char *g_T1MVersion = VERSION;
|
|
|
|
GAMEFLOW_DEFAULT_STRING g_GameFlowDefaultStrings[] = {"""
|
|
|
|
BODY_SUFFIX = """ { 0, NULL },
|
|
};
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
gf = pyjson5.loads(
|
|
(CONFIG_DIR / "Tomb1Main_gameflow.json5").read_text(encoding="utf-8")
|
|
)
|
|
|
|
with io.StringIO() as handle:
|
|
print(BODY_PREFIX.lstrip(), file=handle)
|
|
for key, value in gf["strings"].items():
|
|
print(f" {{ GS_{key}, {json.dumps(value)} }},", file=handle)
|
|
print(BODY_SUFFIX.rstrip(), file=handle)
|
|
new_text = handle.getvalue()
|
|
|
|
path = SRC_DIR / "init.c"
|
|
if path.read_text() != new_text:
|
|
path.write_text(new_text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|