mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 13:23:45 -07: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
2 changed files with 18 additions and 13 deletions
|
@ -2,12 +2,13 @@ import os, sys, glob
|
|||
|
||||
from rom_info import Z64Rom
|
||||
|
||||
def chooseROM(non_interactive=False):
|
||||
def chooseROM(verbose=False, non_interactive=False):
|
||||
roms = []
|
||||
|
||||
for file in glob.glob("*.z64"):
|
||||
if Z64Rom.isValidRom(file):
|
||||
roms.append(file)
|
||||
rom = Z64Rom(file)
|
||||
if rom.is_valid:
|
||||
roms.append(rom)
|
||||
|
||||
if not (roms):
|
||||
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
|
||||
foundOot = False
|
||||
for rom in roms:
|
||||
isMq = Z64Rom.isMqRom(rom)
|
||||
if isMq and not foundMq:
|
||||
if rom.isMq and not foundMq:
|
||||
romsToExtract.append(rom)
|
||||
foundMq = True
|
||||
elif not isMq and not foundOot:
|
||||
elif not rom.isMq and not foundOot:
|
||||
romsToExtract.append(rom)
|
||||
foundOot = True
|
||||
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)):
|
||||
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):
|
||||
try:
|
||||
selection = int(input())
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
except:
|
||||
print("Bad input. Try again with the number keys.")
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue