enable loading multiple manifests

This commit is contained in:
Andreas Schaafsma 2025-04-11 23:54:05 +02:00
parent d73b8bb02e
commit e01cc817ef

View File

@ -1,5 +1,6 @@
package;
#if sys
import haxe.io.Path;
import lime.utils.AssetLibrary;
import lime.utils.AssetManifest;
@ -15,13 +16,21 @@ import sys.FileSystem;
public static function init(config:Dynamic):Void {
rootPath = "";
#if sys
var manifestPath = Path.join(["manifest", "data.json"]);
var manifestDirPath = Path.join(["manifest"]);
var manifests = FileSystem.readDirectory(manifestDirPath);
for (manifest in manifests) {
if (StringTools.endsWith(manifest, ".json")) {
var manifestPath = Path.join([manifestDirPath, manifest]);
loadManifest(manifestPath);
}
}
}
public static function loadManifest(manifestPath) {
if (!FileSystem.exists(manifestPath)) {
trace("Manifest file not found: " + manifestPath);
return;
}
#end
try {
var manifest = AssetManifest.fromFile(manifestPath);
@ -38,3 +47,4 @@ import sys.FileSystem;
}
}
}
#end