successfully implemented asset handling
This commit is contained in:
@@ -164,6 +164,10 @@ class AssetMacro {
|
||||
* Build manifest JSON files for each library
|
||||
*/
|
||||
private static function buildManifests(manifestDir:String) {
|
||||
// Create an array to hold all assets for the default manifest
|
||||
var allAssets = [];
|
||||
|
||||
// First, process individual library manifests
|
||||
for (library in assetMap.keys()) {
|
||||
var assets = assetMap.get(library);
|
||||
var manifest = {
|
||||
@@ -172,6 +176,16 @@ class AssetMacro {
|
||||
rootPath: "../assets/" + library + "/"
|
||||
};
|
||||
|
||||
// Add assets to combined collection with library prefix
|
||||
for (asset in assets) {
|
||||
allAssets.push({
|
||||
id: library + "/" + asset.id,
|
||||
path: library + "/" + asset.path,
|
||||
size: asset.size,
|
||||
type: asset.type
|
||||
});
|
||||
}
|
||||
|
||||
var manifestPath = manifestDir + "/" + library + ".json";
|
||||
try {
|
||||
var content = Json.stringify(manifest, null, " ");
|
||||
@@ -181,6 +195,23 @@ class AssetMacro {
|
||||
Context.warning('Failed to write manifest: ${manifestPath}. Error: ${e}', Context.currentPos());
|
||||
}
|
||||
}
|
||||
|
||||
// Create the default manifest with all assets
|
||||
var defaultManifest = {
|
||||
name: "default",
|
||||
assets: allAssets,
|
||||
rootPath: "../assets/"
|
||||
};
|
||||
|
||||
// Save the default manifest
|
||||
var defaultManifestPath = manifestDir + "/default.json";
|
||||
try {
|
||||
var content = Json.stringify(defaultManifest, null, " ");
|
||||
File.saveContent(defaultManifestPath, content);
|
||||
Context.info('Built default manifest: ${defaultManifestPath} with ${allAssets.length} assets', Context.currentPos());
|
||||
} catch (e) {
|
||||
Context.warning('Failed to write default manifest: ${defaultManifestPath}. Error: ${e}', Context.currentPos());
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
Reference in New Issue
Block a user