load map first pass
This commit is contained in:
@@ -8,6 +8,8 @@ from args import args
|
||||
from xml.etree import ElementTree
|
||||
from assetcache import assetGetCache, assetCache
|
||||
|
||||
tilesets = []
|
||||
|
||||
def loadTilesetFromTSX(asset):
|
||||
# Load the TSX file
|
||||
tree = ElementTree.parse(asset['path'])
|
||||
@@ -138,10 +140,36 @@ def processTileset(asset):
|
||||
os.makedirs(os.path.dirname(outputFile), exist_ok=True)
|
||||
with open(outputFile, 'w') as f:
|
||||
f.write(data)
|
||||
|
||||
return assetCache(asset['path'], {
|
||||
|
||||
|
||||
tileset = {
|
||||
"files": [],
|
||||
"image": tilesetData['image'],
|
||||
"headerFile": outputFile,
|
||||
"headerFile": os.path.relpath(outputFile, args.headers_dir),
|
||||
"tilesetName": tilesetName,
|
||||
"tilesetNameUpper": tilesetNameUpper,
|
||||
"tilesetIndex": len(tilesets),
|
||||
"tilesetData": tilesetData,
|
||||
"files": tilesetData['image']['files'],
|
||||
})
|
||||
}
|
||||
|
||||
tilesets.append(tileset)
|
||||
return assetCache(asset['path'], tileset)
|
||||
|
||||
def processTilesetList():
|
||||
data = f"// Tileset List Generated at {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||
data += f"#pragma once\n"
|
||||
for tileset in tilesets:
|
||||
data += f"#include \"{tileset['headerFile']}\"\n"
|
||||
data += f"\n"
|
||||
data += f"#define TILESET_LIST_COUNT {len(tilesets)}\n\n"
|
||||
data += f"static const tileset_t* TILESET_LIST[TILESET_LIST_COUNT] = {{\n"
|
||||
for tileset in tilesets:
|
||||
data += f" &TILESET_{tileset['tilesetNameUpper']},\n"
|
||||
data += f"}};\n"
|
||||
|
||||
# Write header.
|
||||
outputFile = os.path.join(args.headers_dir, "display", "tileset", f"tilesetlist.h")
|
||||
os.makedirs(os.path.dirname(outputFile), exist_ok=True)
|
||||
with open(outputFile, 'w') as f:
|
||||
f.write(data)
|
Reference in New Issue
Block a user