diff options
| author | Adam Bird <Archez@users.noreply.github.com> | 2023-10-24 20:20:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-24 23:20:34 -0400 |
| commit | f1bc0a726813d7e70ad471fdebd080e6fd77996a (patch) | |
| tree | 52d38c0de7f3a811aa85a6b6999df259203ab119 /extract_assets.py | |
| parent | 89de1472606b101a25d489d3e01f1769d3bc186c (diff) | |
remove hardcoded soh assets and allow custom assets to be passed in (#9)
Diffstat (limited to 'extract_assets.py')
| -rwxr-xr-x | extract_assets.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/extract_assets.py b/extract_assets.py index c6d5282..6700410 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -8,9 +8,7 @@ import struct import subprocess import argparse -def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None): - shutil.copytree("assets", "Extract/assets") - +def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None, customAssetsPath=None, customOtrFile=None): if not zapd_exe: zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" @@ -22,7 +20,8 @@ def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None): exec_cmd.extend(["-gsf", "1"]) else: # generate otrs, but not headers - exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--otrfile", + exec_cmd.extend(["-gsf", "0", "-se", "OTR", "--customAssetsPath", customAssetsPath, + "--customOtrFile", customOtrFile, "--otrfile", "oot-mq.otr" if Z64Rom.isMqRom(rom) else "oot.otr"]) print(exec_cmd) @@ -33,19 +32,23 @@ def BuildOTR(xmlPath, rom, zapd_exe=None, genHeaders=None): print("Aborting...", file=os.sys.stderr) print("\n") -def BuildSohOtr(zapd_exe=None): - shutil.copytree("assets", "Extract/assets") - +def BuildCustomOtr(zapd_exe=None, assets_path=None, otrfile=None): if not zapd_exe: zapd_exe = "x64\\Release\\ZAPD.exe" if sys.platform == "win32" else "../ZAPDTR/ZAPD.out" - exec_cmd = [zapd_exe, "botr", "-se", "OTR", "--norom"] + if not assets_path or not otrfile: + print("\n") + print("Assets path or otrfile name not provided. Exiting...", file=os.sys.stderr) + print("\n") + return + + exec_cmd = [zapd_exe, "botr", "-se", "OTR", "--norom", "--customAssetsPath", assets_path, "--customOtrFile", otrfile] print(exec_cmd) exitValue = subprocess.call(exec_cmd) if exitValue != 0: print("\n") - print("Error when building soh.otr file...", file=os.sys.stderr) + print("Error when building custom otr file...", file=os.sys.stderr) print("Aborting...", file=os.sys.stderr) print("\n") @@ -56,23 +59,21 @@ def main(): parser.add_argument("--non-interactive", help="Runs the script non-interactively for use in build scripts.", dest="non_interactive", action="store_true") parser.add_argument("-v", "--verbose", help="Display rom's header checksums and their corresponding xml folder", dest="verbose", action="store_true") parser.add_argument("--gen-headers", help="Generate source headers to be checked in", dest="gen_headers", action="store_true") - parser.add_argument("--norom", help="Generate only soh.otr to be bundled to the game", dest="norom", action="store_true") + parser.add_argument("--norom", help="Generate only custom otr to be bundled to the game", dest="norom", action="store_true") + parser.add_argument("--xml-root", help="Root path for the rom xmls", dest="xml_root", type=str) + parser.add_argument("--custom-assets-path", help="Path to custom assets for the custom otr file", dest="custom_assets_path", type=str) + parser.add_argument("--custom-otr-file", help="Name for custom otr file", dest="custom_otr_file", type=str) args = parser.parse_args() if args.norom: - if (os.path.exists("Extract")): - shutil.rmtree("Extract") - - BuildSohOtr(args.zapd_exe) + BuildCustomOtr(args.zapd_exe, args.custom_assets_path, args.custom_otr_file) return roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive) for rom in roms: - if (os.path.exists("Extract")): - shutil.rmtree("Extract") - - BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom.file_path, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers) + BuildOTR(os.path.join(args.xml_root, rom.version.xml_ver), rom.file_path, zapd_exe=args.zapd_exe, genHeaders=args.gen_headers, + customAssetsPath=args.custom_assets_path, customOtrFile=args.custom_otr_file) if __name__ == "__main__": main() |
