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

@ -1,22 +1,14 @@
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Tool Level Values
set(
DAWN_TOOL_INCLUDES
${CMAKE_CURRENT_LIST_DIR}
CACHE INTERNAL ${DAWN_CACHE_TARGET}
)
set(
DAWN_TOOL_GENERATED_DEPENDENCIES
CACHE INTERNAL ${DAWN_CACHE_TARGET}
)
# Tools
add_subdirectory(assetstool)
add_subdirectory(copytool)
add_subdirectory(texturetool)
add_subdirectory(truetypetool)
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Tool Level Values
set(
DAWN_TOOL_GENERATED_DEPENDENCIES
CACHE INTERNAL ${DAWN_CACHE_TARGET}
)
# Tools
add_subdirectory(assetstool)
add_subdirectory(texturetool)

View File

@ -6,7 +6,7 @@
add_custom_target(dawnassets
COMMAND ${DAWN_TOOLS_DIR}/assetstool/assetstool.py
--input=${DAWN_ASSETS_BUILD_DIR}
--output=${DAWN_BUILD_DIR}/assets.tar
--output=${DAWN_BUILD_DIR}/dawn.tar
COMMENT "Bundling assets..."
USES_TERMINAL
DEPENDS ${DAWN_ASSETS}

View File

@ -9,7 +9,9 @@ import tarfile
import argparse
# Args
parser = argparse.ArgumentParser(description='Bundles all assets into the internal archive format.')
parser = argparse.ArgumentParser(
description='Bundles all assets into the internal archive format.'
)
parser.add_argument('-i', '--input');
parser.add_argument('-o', '--output');
args = parser.parse_args()
@ -57,4 +59,4 @@ for foldername, subfolders, filenames in os.walk(args.input):
archive.add(absolute_path, arcname=relative_path)
# Close the archive
archive.close()
archive.close()

View File

@ -1,11 +0,0 @@
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
function(tool_copy target input output)
add_custom_target(${target}
COMMAND ${CMAKE_COMMAND} -E copy ${input} ${output}
)
add_dependencies(dawnassets ${target})
endfunction()

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)

View File

@ -1,8 +0,0 @@
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
function(tool_truetype target ttf)
tool_copy(${target} ${ttf} ${DAWN_ASSETS_BUILD_DIR}/${target}.ttf)
endfunction()