Cleanup, prep for editor
This commit is contained in:
@@ -1,50 +1,12 @@
|
||||
import os
|
||||
import sys, os
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
# Check if the script is run with the correct arguments
|
||||
parser = argparse.ArgumentParser(description="Generate chunk header files")
|
||||
parser.add_argument('--assets', required=True, help='Dir to output built assets')
|
||||
parser.add_argument('--build-type', choices=['wad', 'header'], default='raw', help='Type of build to perform')
|
||||
parser.add_argument('--output-file', required=True, help='Output file for built assets (required for wad build)')
|
||||
parser.add_argument('--headers-dir', required=True, help='Directory to output individual asset headers (required for header build)')
|
||||
parser.add_argument('--output-headers', help='Output header file for built assets (required for header build)')
|
||||
parser.add_argument('--output-assets', required=True, help='Output directory for built assets')
|
||||
parser.add_argument('--output-file', required=True, help='Output file for built assets (required for wad build)')
|
||||
parser.add_argument('--input', required=True, help='Input assets to process', nargs='+')
|
||||
args = parser.parse_args()
|
||||
|
||||
inputAssets = []
|
||||
for inputArg in args.input:
|
||||
files = inputArg.split('$')
|
||||
for file in files:
|
||||
if str(file).strip() == '':
|
||||
continue
|
||||
|
||||
pieces = file.split('#')
|
||||
|
||||
if len(pieces) < 2:
|
||||
print(f"Error: Invalid input asset format '{file}'. Expected format: type#path[#option1%option2...]")
|
||||
sys.exit(1)
|
||||
|
||||
options = {}
|
||||
if len(pieces) > 2:
|
||||
optionParts = pieces[2].split('%')
|
||||
for part in optionParts:
|
||||
partSplit = part.split('=')
|
||||
|
||||
if len(partSplit) < 1:
|
||||
continue
|
||||
if len(partSplit) == 2:
|
||||
options[partSplit[0]] = partSplit[1]
|
||||
else:
|
||||
options[partSplit[0]] = True
|
||||
|
||||
inputAssets.append({
|
||||
'type': pieces[0],
|
||||
'path': pieces[1],
|
||||
'options': options
|
||||
})
|
||||
|
||||
if not inputAssets:
|
||||
print("Error: No input assets provided.")
|
||||
sys.exit(1)
|
||||
args = parser.parse_args()
|
||||
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
from args import args
|
||||
from assetstool.args import args
|
||||
|
||||
def getAssetRelativePath(fullPath):
|
||||
# Get the relative path to the asset
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
ASSET_FILE_NAME_MAX_LENGTH = 256
|
||||
@@ -1,49 +0,0 @@
|
||||
import sys, os
|
||||
from args import inputAssets, args
|
||||
from processasset import processAsset
|
||||
from processpalette import processPaletteList
|
||||
from processtileset import processTilesetList
|
||||
from processlanguage import processLanguageList
|
||||
from assethelpers import getBuiltAssetsRelativePath
|
||||
import zipfile
|
||||
|
||||
# Setup headers directory.
|
||||
# setOutputDir(args.output)
|
||||
# outputHeaders = []
|
||||
|
||||
# # Create output directory if it doesn't exist
|
||||
# if not os.path.exists(args.output):
|
||||
# os.makedirs(args.output)
|
||||
|
||||
files = []
|
||||
|
||||
for asset in inputAssets:
|
||||
asset = processAsset(asset)
|
||||
files.extend(asset['files'])
|
||||
|
||||
files.extend(processLanguageList()['files'])
|
||||
|
||||
# Take assets and add to a zip archive.
|
||||
outputFileName = args.output_file
|
||||
print(f"Creating output file: {outputFileName}")
|
||||
with zipfile.ZipFile(outputFileName, 'w') as zipf:
|
||||
for file in files:
|
||||
relativeOutputPath = getBuiltAssetsRelativePath(file)
|
||||
zipf.write(file, arcname=relativeOutputPath)
|
||||
|
||||
# Generate additional headers.
|
||||
processPaletteList()
|
||||
processTilesetList()
|
||||
|
||||
# Finalize build
|
||||
if args.build_type == 'header':
|
||||
print("Error: Header build not implemented yet.")
|
||||
sys.exit(1)
|
||||
|
||||
elif args.build_type == 'wad':
|
||||
# Nothing to do, already created above!
|
||||
pass
|
||||
|
||||
else:
|
||||
print("Error: Unknown build type.")
|
||||
sys.exit(1)
|
||||
@@ -1,10 +1,10 @@
|
||||
import sys
|
||||
# from processtileset import processTileset
|
||||
from processimage import processImage
|
||||
from processpalette import processPalette
|
||||
from processtileset import processTileset
|
||||
from processmap import processMap
|
||||
from processlanguage import processLanguage
|
||||
from assetstool.processimage import processImage
|
||||
from assetstool.processpalette import processPalette
|
||||
from assetstool.processtileset import processTileset
|
||||
from assetstool.processmap import processMap
|
||||
from assetstool.processlanguage import processLanguage
|
||||
|
||||
processedAssets = []
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import os
|
||||
import sys
|
||||
from PIL import Image
|
||||
from processpalette import extractPaletteFromImage, palettes
|
||||
from args import args
|
||||
from assethelpers import getAssetRelativePath
|
||||
from assetcache import assetGetCache, assetCache
|
||||
from assetstool.processpalette import extractPaletteFromImage, palettes
|
||||
from assetstool.args import args
|
||||
from assetstool.assethelpers import getAssetRelativePath
|
||||
from assetstool.assetcache import assetGetCache, assetCache
|
||||
|
||||
images = []
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import sys
|
||||
import os
|
||||
from args import args
|
||||
from assetcache import assetCache, assetGetCache
|
||||
from assethelpers import getAssetRelativePath
|
||||
from assetstool.args import args
|
||||
from assetstool.assetcache import assetCache, assetGetCache
|
||||
from assetstool.assethelpers import getAssetRelativePath
|
||||
import polib
|
||||
import re
|
||||
|
||||
|
||||
@@ -2,17 +2,19 @@ import struct
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
from args import args
|
||||
from assetcache import assetCache, assetGetCache
|
||||
from assethelpers import getAssetRelativePath
|
||||
from assetstool.args import args
|
||||
from assetstool.assetcache import assetCache, assetGetCache
|
||||
from assetstool.assethelpers import getAssetRelativePath
|
||||
from dusk.defs import defs
|
||||
|
||||
CHUNK_WIDTH = 16
|
||||
CHUNK_HEIGHT = 16
|
||||
CHUNK_DEPTH = 4
|
||||
CHUNK_WIDTH = int(defs.get('CHUNK_WIDTH'))
|
||||
CHUNK_HEIGHT = int(defs.get('CHUNK_HEIGHT'))
|
||||
CHUNK_DEPTH = int(defs.get('CHUNK_DEPTH'))
|
||||
CHUNK_TILE_COUNT = CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH
|
||||
TILE_WIDTH = 16.0
|
||||
TILE_HEIGHT = 16.0
|
||||
TILE_DEPTH = 11.36
|
||||
|
||||
TILE_WIDTH = float(defs.get('TILE_WIDTH'))
|
||||
TILE_HEIGHT = float(defs.get('TILE_HEIGHT'))
|
||||
TILE_DEPTH = float(defs.get('TILE_DEPTH'))
|
||||
|
||||
def processTile(tileIndex, x=0, y=0, z=0, chunkX=0, chunkY=0, chunkZ=0):
|
||||
vertices = []
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import os
|
||||
from PIL import Image
|
||||
from args import args
|
||||
import sys
|
||||
import datetime
|
||||
from assetcache import assetCache, assetGetCache
|
||||
from assetstool.args import args
|
||||
from assetstool.assetcache import assetCache, assetGetCache
|
||||
|
||||
palettes = []
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import json
|
||||
from processimage import processImage
|
||||
import sys
|
||||
from assethelpers import getAssetRelativePath
|
||||
import os
|
||||
import datetime
|
||||
from args import args
|
||||
from xml.etree import ElementTree
|
||||
from assetcache import assetGetCache, assetCache
|
||||
from assetstool.processimage import processImage
|
||||
from assetstool.assethelpers import getAssetRelativePath
|
||||
from assetstool.args import args
|
||||
from assetstool.assetcache import assetGetCache, assetCache
|
||||
|
||||
tilesets = []
|
||||
|
||||
|
||||
66
tools/assettool.py
Normal file
66
tools/assettool.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import sys, os
|
||||
from assetstool.args import args
|
||||
from assetstool.processasset import processAsset
|
||||
from assetstool.processpalette import processPaletteList
|
||||
from assetstool.processtileset import processTilesetList
|
||||
from assetstool.processlanguage import processLanguageList
|
||||
from assetstool.assethelpers import getBuiltAssetsRelativePath
|
||||
import zipfile
|
||||
|
||||
# Parse input file args.
|
||||
inputAssets = []
|
||||
for inputArg in args.input:
|
||||
files = inputArg.split('$')
|
||||
for file in files:
|
||||
if str(file).strip() == '':
|
||||
continue
|
||||
|
||||
pieces = file.split('#')
|
||||
|
||||
if len(pieces) < 2:
|
||||
print(f"Error: Invalid input asset format '{file}'. Expected format: type#path[#option1%option2...]")
|
||||
sys.exit(1)
|
||||
|
||||
options = {}
|
||||
if len(pieces) > 2:
|
||||
optionParts = pieces[2].split('%')
|
||||
for part in optionParts:
|
||||
partSplit = part.split('=')
|
||||
|
||||
if len(partSplit) < 1:
|
||||
continue
|
||||
if len(partSplit) == 2:
|
||||
options[partSplit[0]] = partSplit[1]
|
||||
else:
|
||||
options[partSplit[0]] = True
|
||||
|
||||
inputAssets.append({
|
||||
'type': pieces[0],
|
||||
'path': pieces[1],
|
||||
'options': options
|
||||
})
|
||||
|
||||
if not inputAssets:
|
||||
print("Error: No input assets provided.")
|
||||
sys.exit(1)
|
||||
|
||||
# Process each asset.
|
||||
files = []
|
||||
for asset in inputAssets:
|
||||
asset = processAsset(asset)
|
||||
files.extend(asset['files'])
|
||||
|
||||
# Generate additional files
|
||||
files.extend(processLanguageList()['files'])
|
||||
|
||||
# Take assets and add to a zip archive.
|
||||
outputFileName = args.output_file
|
||||
print(f"Creating output file: {outputFileName}")
|
||||
with zipfile.ZipFile(outputFileName, 'w') as zipf:
|
||||
for file in files:
|
||||
relativeOutputPath = getBuiltAssetsRelativePath(file)
|
||||
zipf.write(file, arcname=relativeOutputPath)
|
||||
|
||||
# Generate additional headers.
|
||||
processPaletteList()
|
||||
processTilesetList()
|
||||
20
tools/dusk/defs.py
Normal file
20
tools/dusk/defs.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
import sys
|
||||
|
||||
current_file_path = os.path.abspath(__file__)
|
||||
print(current_file_path)
|
||||
|
||||
ASSET_FILE_NAME_MAX_LENGTH = 256
|
||||
|
||||
|
||||
duskDefsPath = os.path.join(os.path.dirname(current_file_path), "..", "..", "src", "duskdefs.env")
|
||||
|
||||
# Ensure the .env file exists
|
||||
if not os.path.isfile(duskDefsPath):
|
||||
print(f"Error: .env file not found at {duskDefsPath}")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(dotenv_path=duskDefsPath)
|
||||
|
||||
defs = {key: os.getenv(key) for key in os.environ.keys()}
|
||||
Reference in New Issue
Block a user