Basic window.

This commit is contained in:
2025-02-20 22:09:21 -06:00
commit 11806510c0
47 changed files with 7696 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
find_package(Python3 REQUIRED COMPONENTS Interpreter)
add_custom_target(duskassets
COMMAND
${Python3_EXECUTABLE}
${DUSK_TOOLS_DIR}/assetstool/assetstool.py
--input=${DUSK_ASSETS_BUILD_DIR}
--output=${DUSK_BUILD_DIR}/dusk.tar
COMMENT "Bundling assets..."
USES_TERMINAL
DEPENDS ${DUSK_ASSETS}
)
add_dependencies(${DUSK_TARGET_NAME} duskassets)

67
tools/assetstool/assetstool.py Executable file
View File

@ -0,0 +1,67 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
import os
import tarfile
import argparse
# Args
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()
# Ensure the directory for the output path exists
if not os.path.exists(os.path.dirname(args.output)):
os.makedirs(os.path.dirname(args.output))
# Create a ZIP archive and add the specified directory
# archive = tarfile.open(args.output, 'w:bz2') # BZ2 Compression
# Does the archive already exist?
filesInArchive = []
if os.path.exists(args.output) and False:
# if os.path.exists(args.output):
# Yes, open it
archive = tarfile.open(args.output, 'a:')
# Get all the files in the archive
for member in archive.getmembers():
filesInArchive.append(member.name)
archive.close()
# Open archive for appending.
archive = tarfile.open(args.output, 'a:')
else:
# No, create it
archive = tarfile.open(args.output, 'w:')
# Add all files in the input directory
for foldername, subfolders, filenames in os.walk(args.input):
for filename in filenames:
# Is the file already in the archive?
absolute_path = os.path.join(foldername, filename)
relative_path = os.path.relpath(absolute_path, args.input)
if relative_path in filesInArchive:
if relative_path.endswith('.texture'):
print(f"Skipping {filename}...")
continue
else:
print(f"Overwriting {filename}...")
# Does not work in python, throw error
exit (1)
else:
print(f"Archiving asset {filename}...")
archive.add(absolute_path, arcname=relative_path)
# Close the archive
archive.close()