Put SWF assets in first frame for AIR, add custom HXML template for AIR

This commit is contained in:
Joshua Granick
2017-08-24 16:36:58 -07:00
parent 5854cea2b9
commit 970fc7655f
5 changed files with 90 additions and 7 deletions

View File

@@ -643,7 +643,7 @@ class FlashHelper {
width : (project.window.width == 0 ? 800 : project.window.width),
height : (project.window.height == 0 ? 500 : project.window.height),
fps : project.window.fps * 256,
nframes : 2
nframes : project.target == AIR ? 1 : 2
};
var tags = new Array<SWFTag> ();
@@ -651,8 +651,13 @@ class FlashHelper {
var inserted = false;
tags.push (TBackgroundColor (project.window.background));
if (project.target != AIR) {
tags.push (TShowFrame);
}
// Might generate ABC later, so we don't need the @:bind calls in DefaultAssetLibrary?
/*var abc = new haxe.io.BytesOutput ();

View File

@@ -1,17 +1,21 @@
package lime.tools.platforms;
import haxe.io.Path;
import lime.project.AssetType;
import lime.project.HXProject;
import lime.project.Icon;
import lime.project.Platform;
import lime.project.PlatformType;
import lime.tools.helpers.AIRHelper;
import lime.tools.helpers.DeploymentHelper;
import lime.tools.helpers.FileHelper;
import lime.tools.helpers.FlashHelper;
import lime.tools.helpers.IconHelper;
import lime.tools.helpers.PathHelper;
import lime.tools.helpers.PlatformHelper;
import lime.tools.helpers.LogHelper;
import lime.project.HXProject;
import lime.project.Icon;
import sys.io.File;
import sys.FileSystem;
@@ -90,13 +94,67 @@ class AIRPlatform extends FlashPlatform {
public override function update ():Void {
super.update ();
var destination = targetDirectory + "/bin/";
PathHelper.mkdir (destination);
var context = project.templateContext;
project = project.clone ();
FileHelper.recursiveCopyTemplate (project.templatePaths, "air/hxml", targetDirectory + "/haxe", context, true, false);
embedded = FlashHelper.embedAssets (project, targetDirectory);
var context = generateContext ();
context.OUTPUT_DIR = targetDirectory;
FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context);
FileHelper.recursiveCopyTemplate (project.templatePaths, "air/hxml", targetDirectory + "/haxe", context);
FileHelper.recursiveCopyTemplate (project.templatePaths, "air/template", targetDirectory + "/bin", context);
if (embedded) {
var files = [ "debug.hxml", "release.hxml", "final.hxml" ];
var path, hxml, lines, output;
for (file in files) {
path = targetDirectory + "/haxe/" + file;
hxml = File.getContent (path);
if (hxml.indexOf ("-swf-header") > -1) {
lines = ~/[\r\n]+/g.split (hxml);
output = [];
for (line in lines) {
if (line.indexOf ("-swf-header") > -1) continue;
output.push (line);
}
if (output.length < lines.length) {
File.saveContent (path, output.join ("\n"));
}
}
}
}
for (asset in project.assets) {
if (asset.type == AssetType.TEMPLATE || asset.embed == false /*|| !usesLime*/) {
var path = PathHelper.combine (destination, asset.targetPath);
PathHelper.mkdir (Path.directory (path));
FileHelper.copyAsset (asset, path, context);
}
}
//var sizes = [ 32, 48, 60, 64, 128, 512 ];
//var icons = project.icons;
//

View File

@@ -0,0 +1,7 @@
-main ApplicationMain ::HAXE_FLAGS::
-swf-version ::SWF_VERSION::
-swf ::OUTPUT_DIR::/bin/::APP_FILE::.swf
-swf-header ::if (WIN_WIDTH == "0")::800::else::::WIN_WIDTH::::end:::::if (WIN_HEIGHT == "0")::500::else::::WIN_HEIGHT::::end:::::WIN_FPS:::::WIN_FLASHBACKGROUND::
-cp ::OUTPUT_DIR::/haxe
-debug
-D air

View File

@@ -0,0 +1,7 @@
-main ApplicationMain ::HAXE_FLAGS::
-swf-version ::SWF_VERSION::
-swf ::OUTPUT_DIR::/bin/::APP_FILE::.swf
-swf-header ::if (WIN_WIDTH == "0")::800::else::::WIN_WIDTH::::end:::::if (WIN_HEIGHT == "0")::500::else::::WIN_HEIGHT::::end:::::WIN_FPS:::::WIN_FLASHBACKGROUND::
-cp ::OUTPUT_DIR::/haxe
-D final
-D air

View File

@@ -0,0 +1,6 @@
-main ApplicationMain ::HAXE_FLAGS::
-swf-version ::SWF_VERSION::
-swf ::OUTPUT_DIR::/bin/::APP_FILE::.swf
-swf-header ::if (WIN_WIDTH == "0")::800::else::::WIN_WIDTH::::end:::::if (WIN_HEIGHT == "0")::500::else::::WIN_HEIGHT::::end:::::WIN_FPS:::::WIN_FLASHBACKGROUND::
-cp ::OUTPUT_DIR::/haxe
-D air