Dawn reset

This commit is contained in:
2024-06-16 07:48:59 -05:00
parent 7d8c104a93
commit fec8771c75
224 changed files with 318 additions and 10140 deletions

View File

@ -31,7 +31,7 @@ function(tool_texture target)
message(FATAL_ERROR "Missing FILE input")
endif()
add_custom_target(${target}
add_custom_target(${target}_texture
COMMAND ${DAWN_TOOLS_DIR}/texturetool/texturetool.py
--input="${FILE}"
--output="${DAWN_ASSETS_BUILD_DIR}/${target}.texture"
@ -46,5 +46,5 @@ function(tool_texture target)
--crop-end-y="${CROP_END_Y}"
COMMENT "Generating texture ${target} from ${FILE}"
)
add_dependencies(dawnassets ${target})
add_dependencies(dawnassets ${target}_texture)
endfunction()

View File

@ -9,7 +9,9 @@ import argparse
import os
# Args
parser = argparse.ArgumentParser(description='Converts image textures to internal game data format.')
parser = argparse.ArgumentParser(
description='Converts image textures to internal game data format.'
)
parser.add_argument('-i', '--input');
parser.add_argument('-o', '--output');
parser.add_argument('-s', '--scale');
@ -33,7 +35,11 @@ if not os.path.exists(args.input):
img = Image.open(args.input)
# Normalize the image
hasAlpha = img.mode == 'RGBA' or img.mode == 'LA'
hasAlpha = (
img.mode == 'RGBA' or img.mode == 'LA' or (
img.mode == 'P' and 'transparency' in img.info
)
)
# Convert the image to RGB or RGBA mode based on alpha channel
if hasAlpha:
@ -67,12 +73,12 @@ if args.scale not in (None, ""):
# Filter
if args.filter_min.lower() == 'NEAREST':
if args.filter_min.lower() == 'nearest':
filterMin = 0
else:
filterMin = 1
if args.filter_mag.lower() == 'NEAREST':
if args.filter_mag.lower() == 'nearest':
filterMag = 0
else:
filterMag = 1
@ -108,6 +114,7 @@ os.makedirs(os.path.dirname(args.output), exist_ok=True)
# Write the image metadata and pixel data to the output file
with open(args.output, 'wb') as f:
header = f"DT_2.00|{img.width}|{img.height}|{4 if hasAlpha else 3}|{wrapX}|{wrapY}|{filterMin}|{filterMag}|"
header = f"DT_2.00|{img.width}|{img.height}|{4 if hasAlpha else 3}|"
header += f"{wrapX}|{wrapY}|{filterMin}|{filterMag}|"
f.write(header.encode())
f.write(buffer)