4d95415232
Adds three new pieces of save-file state, all following the same shape: the save file is the single source of truth, not a separate live runtime copy that gets synced in/out. - globalitemstore.h/.c: per-global-entity-ID "collected" flags (savefile_t.globalItemCollected), so a global item entity's init callback can check whether it was already picked up in a prior session without needing to keep the entity itself alive to remember that. - Gamepad deadzone: removed input_t.deadzone entirely. The setting UI and every platform's actual deadzone-applying code (inputGetDeadzoneDolphin/ SDL2, previously hardcoded per-platform literals that the settings menu didn't actually affect) now read savefile_t.deadzone directly via saveGet(SAVE_ACTIVE_SLOT). Default lives in savefile.h (SAVE_DEADZONE_DEFAULT), stamped onto every slot in saveInit(). - Story flags: STORY_FLAG_VALUES (a live, codegen-initialized array) is replaced by savefile_t.storyFlags, read/written via the existing storyFlagGet()/storyFlagSet() call sites (now macros/functions over the active save file instead of a separate array). tools/story.py now generates STORY_FLAG_DEFAULTS (const) instead; storyFlagInitDefaults() stamps those onto a save the first time it's used (file->exists false), called from rpgInit(). Added SAVE_ACTIVE_SLOT (0) to savefile.h as the one shared "which slot is actually being played" constant, replacing three different local/implicit 0s (uigamemenu.c, rpg.c, and now the settings/input call sites). Verified round-trip on Linux (all three together in one save/load cycle); both Linux and PSP build clean.
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
import argparse
|
|
import csv
|
|
import os
|
|
|
|
parser = argparse.ArgumentParser(description="Story CSV to .h defines")
|
|
parser.add_argument("--csv", required=True, help="Path to story CSV file")
|
|
parser.add_argument("--output", required=True, help="Path to output .h file")
|
|
args = parser.parse_args()
|
|
|
|
def flag_enum(name):
|
|
return "STORY_FLAG_" + name.upper().replace(" ", "_")
|
|
|
|
# Load flags
|
|
flags = []
|
|
with open(args.csv, newline="", encoding="utf-8") as f:
|
|
reader = csv.DictReader(f)
|
|
if "id" not in reader.fieldnames:
|
|
raise ValueError("CSV must have an 'id' column")
|
|
for row in reader:
|
|
flags.append({
|
|
"id": row["id"].strip(),
|
|
"initial": (row.get("initial") or "0").strip(),
|
|
})
|
|
|
|
# Build output
|
|
out = [
|
|
"#pragma once",
|
|
'#include "rpg/story/storyflagdefs.h"',
|
|
"",
|
|
"typedef enum {",
|
|
" STORY_FLAG_NULL,",
|
|
"",
|
|
]
|
|
for flag in flags:
|
|
out.append(f" {flag_enum(flag['id'])},")
|
|
out += [
|
|
"",
|
|
" STORY_FLAG_COUNT",
|
|
"} storyflag_t;",
|
|
"",
|
|
"// Stamped onto a save file's storyFlags the first time it's used (see",
|
|
"// storyFlagInitDefaults()) - not a live value array. Live flag state",
|
|
"// lives entirely in the save file (savefile_t.storyFlags), read/written",
|
|
"// via storyFlagGet()/storyFlagSet() - see storyflag.h.",
|
|
"static const storyflagvalue_t STORY_FLAG_DEFAULTS[STORY_FLAG_COUNT] = {",
|
|
]
|
|
for flag in flags:
|
|
out.append(f" [{flag_enum(flag['id'])}] = {flag['initial']},")
|
|
out += [
|
|
"};",
|
|
"",
|
|
"static const char_t *STORY_FLAG_SCRIPT =",
|
|
]
|
|
for i, flag in enumerate(flags):
|
|
out.append(f" \"{flag_enum(flag['id'])} = {i + 1}\\n\"")
|
|
out += [";", ""]
|
|
|
|
os.makedirs(os.path.dirname(args.output), exist_ok=True)
|
|
with open(args.output, "w", encoding="utf-8") as f:
|
|
f.write("\n".join(out))
|