Refresh 3

This commit is contained in:
n64
2019-11-03 14:36:27 -05:00
parent 6b8bc9b9ec
commit a7c423cb43
4603 changed files with 475500 additions and 437701 deletions

View File

@@ -27,6 +27,15 @@ def asset_needs_update(asset, version):
return False
def remove_file(fname):
os.remove(fname)
print("deleting", fname)
try:
os.removedirs(os.path.dirname(fname))
except OSError:
pass
def clean_assets(local_asset_file):
assets = set(read_asset_map().keys())
assets.update(read_local_asset_list(local_asset_file))
@@ -34,7 +43,7 @@ def clean_assets(local_asset_file):
if fname.startswith("@"):
continue
try:
os.remove(fname)
remove_file(fname)
except FileNotFoundError:
pass
@@ -133,10 +142,11 @@ def main():
+ ", expected "
+ expected_sha1
)
sys.exit(1)
# Make sure tools exist
subprocess.check_call(
["make", "-s", "-C", "tools/", "n64graphics", "mio0", "aifc_decode"]
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"]
)
# Go through the assets in roughly alphabetical order (but assets in the same
@@ -191,25 +201,44 @@ def main():
input = image[pos : pos + size]
os.makedirs(os.path.dirname(asset), exist_ok=True)
if asset.endswith(".png"):
w, h = meta
fmt = asset.split(".")[-2]
subprocess.run(
[
"./tools/n64graphics",
"-e",
"/dev/stdin",
"-g",
asset,
"-f",
fmt,
"-w",
str(w),
"-h",
str(h),
],
input=input,
check=True,
)
with tempfile.NamedTemporaryFile(prefix="asset") as png_file:
png_file.write(input)
png_file.flush()
if asset.startswith("textures/skyboxes/") or asset.startswith("levels/ending/cake"):
if asset.startswith("textures/skyboxes/"):
imagetype = "sky"
else:
imagetype = "cake" + ("-eu" if "eu" in asset else "")
subprocess.run(
[
"./tools/skyconv",
"--type",
imagetype,
"--combine",
png_file.name,
asset,
],
check=True,
)
else:
w, h = meta
fmt = asset.split(".")[-2]
subprocess.run(
[
"./tools/n64graphics",
"-e",
png_file.name,
"-g",
asset,
"-f",
fmt,
"-w",
str(w),
"-h",
str(h),
],
check=True,
)
else:
with open(asset, "wb") as f:
f.write(input)
@@ -218,8 +247,7 @@ def main():
for asset in previous_assets:
if asset not in new_assets:
try:
print("deleting", asset)
os.remove(asset)
remove_file(asset)
except FileNotFoundError:
pass