mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-01 22:02:18 -05:00
changes to the asset extraction script (#2068)
- fixes exiting with Ctrl+C on linux - chooseROM returns Z64Rom object in addition to speed - adds simple verbosity for inspecting roms
This commit is contained in:
parent
1fe862515d
commit
ba5d5c25d1
@ -32,17 +32,16 @@ def main():
|
|||||||
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
|
parser.add_argument("-z", "--zapd", help="Path to ZAPD executable", dest="zapd_exe", type=str)
|
||||||
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
|
parser.add_argument("rom", help="Path to the rom", type=str, nargs="?")
|
||||||
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("--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")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
rom_paths = [ args.rom ] if args.rom else rom_chooser.chooseROM(args.non_interactive)
|
roms = [ Z64Rom(args.rom) ] if args.rom else rom_chooser.chooseROM(args.verbose, args.non_interactive)
|
||||||
for rom_path in rom_paths:
|
for rom in roms:
|
||||||
rom = Z64Rom(rom_path)
|
|
||||||
|
|
||||||
if (os.path.exists("Extract")):
|
if (os.path.exists("Extract")):
|
||||||
shutil.rmtree("Extract")
|
shutil.rmtree("Extract")
|
||||||
|
|
||||||
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom_path, zapd_exe=args.zapd_exe)
|
BuildOTR("../soh/assets/xml/" + rom.version.xml_ver + "/", rom.file_path, zapd_exe=args.zapd_exe)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -2,12 +2,13 @@ import os, sys, glob
|
|||||||
|
|
||||||
from rom_info import Z64Rom
|
from rom_info import Z64Rom
|
||||||
|
|
||||||
def chooseROM(non_interactive=False):
|
def chooseROM(verbose=False, non_interactive=False):
|
||||||
roms = []
|
roms = []
|
||||||
|
|
||||||
for file in glob.glob("*.z64"):
|
for file in glob.glob("*.z64"):
|
||||||
if Z64Rom.isValidRom(file):
|
rom = Z64Rom(file)
|
||||||
roms.append(file)
|
if rom.is_valid:
|
||||||
|
roms.append(rom)
|
||||||
|
|
||||||
if not (roms):
|
if not (roms):
|
||||||
print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr)
|
print("Error: No roms located, place one in the OTRExporter directory", file=os.sys.stderr)
|
||||||
@ -21,23 +22,28 @@ def chooseROM(non_interactive=False):
|
|||||||
foundMq = False
|
foundMq = False
|
||||||
foundOot = False
|
foundOot = False
|
||||||
for rom in roms:
|
for rom in roms:
|
||||||
isMq = Z64Rom.isMqRom(rom)
|
if rom.isMq and not foundMq:
|
||||||
if isMq and not foundMq:
|
|
||||||
romsToExtract.append(rom)
|
romsToExtract.append(rom)
|
||||||
foundMq = True
|
foundMq = True
|
||||||
elif not isMq and not foundOot:
|
elif not rom.isMq and not foundOot:
|
||||||
romsToExtract.append(rom)
|
romsToExtract.append(rom)
|
||||||
foundOot = True
|
foundOot = True
|
||||||
return romsToExtract
|
return romsToExtract
|
||||||
|
|
||||||
print(str(len(roms))+ " roms found, please select one by pressing 1-"+str(len(roms)))
|
print(f"{len(roms)} roms found, please select one by pressing 1-{len(roms)}")
|
||||||
|
print()
|
||||||
|
|
||||||
for i in range(len(roms)):
|
for i in range(len(roms)):
|
||||||
print(str(i+1)+ ". " + roms[i])
|
print(f"[{i+1:>2d}] {roms[i].file_path}")
|
||||||
|
if verbose:
|
||||||
|
print(f" Checksum: {roms[i].checksum.value}, Version XML: {roms[i].version.xml_ver}")
|
||||||
|
print()
|
||||||
|
|
||||||
while(1):
|
while(1):
|
||||||
try:
|
try:
|
||||||
selection = int(input())
|
selection = int(input())
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.exit(1)
|
||||||
except:
|
except:
|
||||||
print("Bad input. Try again with the number keys.")
|
print("Bad input. Try again with the number keys.")
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user