Asset library fixes/unification for Flash

This commit is contained in:
Joshua Granick
2017-01-23 10:31:59 -08:00
parent 5ea2b4dfce
commit 76e51a2379
4 changed files with 19 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ package lime.tools.platforms;
import haxe.io.Path;
import haxe.Json;
import haxe.Template;
import lime.tools.helpers.AssetHelper;
import lime.tools.helpers.CompatibilityHelper;
import lime.tools.helpers.DeploymentHelper;
import lime.tools.helpers.FileHelper;
@@ -38,7 +39,7 @@ class FlashPlatform extends PlatformTarget {
super (command, _project, targetFlags);
targetDirectory = project.app.path + "/flash/" + buildType;
}
@@ -237,6 +238,11 @@ class FlashPlatform extends PlatformTarget {
var destination = targetDirectory + "/bin/";
PathHelper.mkdir (destination);
project = project.clone ();
AssetHelper.createManifest (project, PathHelper.combine (targetDirectory, "obj/manifest"));
project.haxeflags.push ("-resource " + targetDirectory + "/obj/manifest@__ASSET_MANIFEST__");
embedded = FlashHelper.embedAssets (project, targetDirectory);
var context = generateContext ();
@@ -286,6 +292,8 @@ class FlashPlatform extends PlatformTarget {
}
AssetHelper.createManifest (project, PathHelper.combine (targetDirectory, "obj/manifest"));
}

View File

@@ -104,6 +104,8 @@ class AssetLibrary {
public static function fromManifest (manifest:AssetManifest):AssetLibrary {
if (manifest == null) return null;
var library:AssetLibrary = null;
if (manifest.libraryType == null) {
@@ -486,7 +488,11 @@ class AssetLibrary {
} else if (classTypes.exists (id)) {
#if flash
return Future.withValue (Bytes.ofData (Type.createInstance (classTypes.get (id), [])));
#else
return Future.withValue (Type.createInstance (classTypes.get (id), []));
#end
} else {

View File

@@ -77,6 +77,8 @@ class AssetManifest {
public static function parse (data:String):AssetManifest {
if (data == null || data == "") return null;
#if !macro
var manifestData = Json.parse (data);

View File

@@ -28,13 +28,6 @@ import sys.FileSystem;
super ();
#if flash
::if (assets != null)::::foreach assets::::if (embed)::classTypes.set ("::id::", __ASSET__::flatName::);::else::paths.set ("::id::", "::resourceName::");::end::
types.set ("::id::", AssetType.$$upper(::type::));::end::::end::
#else
if (ApplicationMain.config != null && Reflect.hasField (ApplicationMain.config, "assetsPrefix")) {
rootPath = Reflect.field (ApplicationMain.config, "assetsPrefix");
@@ -53,7 +46,7 @@ import sys.FileSystem;
}
#if (openfl && !display)
#if (openfl && !flash && !display)
::if (assets != null)::::foreach assets::::if (type == "font")::openfl.text.Font.registerFont (__ASSET__OPENFL__::flatName::);
::end::::end::::end::
#end
@@ -68,7 +61,7 @@ import sys.FileSystem;
#end ::else::::if (embed)::
#if html5
preload.set (id, true);
#elseif (desktop || cpp)
#elseif (desktop || cpp || flash)
classTypes.set (id, __ASSET__::flatName::);
types.set (id, AssetType.$$upper(::type::));
#end
@@ -111,8 +104,6 @@ import sys.FileSystem;
}
#end
}