Put SWF assets in first frame for AIR, add custom HXML template for AIR
This commit is contained in:
@@ -643,7 +643,7 @@ class FlashHelper {
|
|||||||
width : (project.window.width == 0 ? 800 : project.window.width),
|
width : (project.window.width == 0 ? 800 : project.window.width),
|
||||||
height : (project.window.height == 0 ? 500 : project.window.height),
|
height : (project.window.height == 0 ? 500 : project.window.height),
|
||||||
fps : project.window.fps * 256,
|
fps : project.window.fps * 256,
|
||||||
nframes : 2
|
nframes : project.target == AIR ? 1 : 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var tags = new Array<SWFTag> ();
|
var tags = new Array<SWFTag> ();
|
||||||
@@ -651,7 +651,12 @@ class FlashHelper {
|
|||||||
var inserted = false;
|
var inserted = false;
|
||||||
|
|
||||||
tags.push (TBackgroundColor (project.window.background));
|
tags.push (TBackgroundColor (project.window.background));
|
||||||
tags.push (TShowFrame);
|
|
||||||
|
if (project.target != AIR) {
|
||||||
|
|
||||||
|
tags.push (TShowFrame);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Might generate ABC later, so we don't need the @:bind calls in DefaultAssetLibrary?
|
// Might generate ABC later, so we don't need the @:bind calls in DefaultAssetLibrary?
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
package lime.tools.platforms;
|
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.Platform;
|
||||||
import lime.project.PlatformType;
|
import lime.project.PlatformType;
|
||||||
import lime.tools.helpers.AIRHelper;
|
import lime.tools.helpers.AIRHelper;
|
||||||
import lime.tools.helpers.DeploymentHelper;
|
import lime.tools.helpers.DeploymentHelper;
|
||||||
import lime.tools.helpers.FileHelper;
|
import lime.tools.helpers.FileHelper;
|
||||||
|
import lime.tools.helpers.FlashHelper;
|
||||||
import lime.tools.helpers.IconHelper;
|
import lime.tools.helpers.IconHelper;
|
||||||
import lime.tools.helpers.PathHelper;
|
import lime.tools.helpers.PathHelper;
|
||||||
import lime.tools.helpers.PlatformHelper;
|
import lime.tools.helpers.PlatformHelper;
|
||||||
import lime.tools.helpers.LogHelper;
|
import lime.tools.helpers.LogHelper;
|
||||||
import lime.project.HXProject;
|
import sys.io.File;
|
||||||
import lime.project.Icon;
|
|
||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
|
|
||||||
|
|
||||||
@@ -90,13 +94,67 @@ class AIRPlatform extends FlashPlatform {
|
|||||||
|
|
||||||
public override function update ():Void {
|
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);
|
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 sizes = [ 32, 48, 60, 64, 128, 512 ];
|
||||||
//var icons = project.icons;
|
//var icons = project.icons;
|
||||||
//
|
//
|
||||||
|
|||||||
7
templates/air/hxml/debug.hxml
Normal file
7
templates/air/hxml/debug.hxml
Normal 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
|
||||||
7
templates/air/hxml/final.hxml
Normal file
7
templates/air/hxml/final.hxml
Normal 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
|
||||||
6
templates/air/hxml/release.hxml
Normal file
6
templates/air/hxml/release.hxml
Normal 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
|
||||||
Reference in New Issue
Block a user