Commit and split gameplay_keep
Many files still unnamed, help wanted
That's a lot of work done already ( :clap: ) and there's a lot to unpack Thoughts on making subfolders of gkeep? For example put together arrow_anims.c (maybe further split into each anim) and arrow_skel.c into an "arrow" folder with a single "arrow.h" ?
I made a little script for renaming gkeep files:
Usage: any of
./rename_gkeepfile.py assets/objects/gameplay_keep/gameplay_keep_0x3A150.h flat_rot_block_model
./rename_gkeepfile.py gameplay_keep_0x3A150.h flat_rot_block_model
./rename_gkeepfile.py gameplay_keep_0x3A150 flat_rot_block_model
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Dragorn421
# SPDX-License-Identifier: CC0-1.0
import argparse
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument("from_name")
parser.add_argument("to_name")
args = parser.parse_args()
from_name = Path(args.from_name).stem
to_name = Path(args.to_name).stem
p = Path("assets/objects/gameplay_keep") / from_name
h_p = p.with_suffix(".h")
lines = h_p.read_text().splitlines(keepends=True)
assert lines[0].startswith("#ifndef ")
assert lines[1].startswith("#define ")
include_guard = "GAMEPLAY_KEEP_" + to_name.upper() + "_H"
h_p.write_text(
"".join(
[
f"#ifndef {include_guard}\n",
f"#define {include_guard}\n",
]
+ lines[2:]
)
)
h_p.rename(p.with_name(f"{to_name}.h"))
p.with_suffix(".c").rename(p.with_name(f"{to_name}.c"))
from_name = from_name.encode()
to_name = to_name.encode()
for root_p in (
Path("src"),
Path("include"),
Path("assets"),
Path("spec"),
):
for dir_p, dirnames, filenames in root_p.walk():
for filename in filenames:
file_p = dir_p / filename
contents = file_p.read_bytes()
if from_name in contents:
contents_new = contents.replace(from_name, to_name)
file_p.write_bytes(contents_new)
if __name__ == "__main__":
main()
I made some commits naming a few more things (feel free to force-push them away if you don't like them)
Limb names are not final, I just needed to rename them in at least one xml to avoid ifdefs, and figured I'd do something at least better than "gameplay_keep_0x..."