Rebuild how lime.embed works, fix multiple embeds, allow passing window config values (resolve #933)
This commit is contained in:
@@ -2,22 +2,17 @@ package;
|
||||
|
||||
|
||||
@:access(lime.app.Application)
|
||||
@:access(lime.utils.AssetLibrary)
|
||||
@:access(lime.system.System)
|
||||
|
||||
|
||||
@:dox(hide) class ApplicationMain {
|
||||
|
||||
|
||||
public static var config:lime.app.Config;
|
||||
public static var preloader:lime.app.Preloader;
|
||||
|
||||
private static var app:lime.app.Application;
|
||||
private static var rootPath:String;
|
||||
|
||||
|
||||
public static function main () {
|
||||
|
||||
config = {
|
||||
var projectName = "::APP_FILE::";
|
||||
|
||||
var config = {
|
||||
|
||||
build: "::meta.buildNumber::",
|
||||
company: "::meta.company::",
|
||||
@@ -42,7 +37,7 @@ package;
|
||||
hidden: #if munit true #else ::hidden:: #end,
|
||||
maximized: ::maximized::,
|
||||
minimized: ::minimized::,
|
||||
parameters: "::parameters::",
|
||||
parameters: ::parameters::,
|
||||
resizable: ::resizable::,
|
||||
stencilBuffer: ::stencilBuffer::,
|
||||
title: "::title::",
|
||||
@@ -55,21 +50,23 @@ package;
|
||||
|
||||
};
|
||||
|
||||
lime.system.System.__registerEntryPoint (projectName, create, config);
|
||||
|
||||
#if (!html5 || munit)
|
||||
create ();
|
||||
create (config);
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function create ():Void {
|
||||
public static function create (config:lime.app.Config):Void {
|
||||
|
||||
ManifestResources.init ();
|
||||
ManifestResources.init (config);
|
||||
|
||||
preloader = new ::if (PRELOADER_NAME != "")::::PRELOADER_NAME::::else::lime.app.Preloader::end:: ();
|
||||
var preloader = new ::if (PRELOADER_NAME != "")::::PRELOADER_NAME::::else::lime.app.Preloader::end:: ();
|
||||
|
||||
#if !munit
|
||||
app = new ::APP_MAIN:: ();
|
||||
var app = new ::APP_MAIN:: ();
|
||||
app.setPreloader (preloader);
|
||||
app.create (config);
|
||||
#end
|
||||
@@ -90,82 +87,12 @@ package;
|
||||
|
||||
preloader.load ();
|
||||
|
||||
start ();
|
||||
start (app);
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if (js && html5)
|
||||
@:keep @:expose("::APP_FILE::.embed")
|
||||
public static function embed (element:Dynamic, width:Null<Int> = null, height:Null<Int> = null, background:String = null, assetsPrefix:String = null) {
|
||||
|
||||
var htmlElement:js.html.Element = null;
|
||||
|
||||
if (Std.is (element, String)) {
|
||||
|
||||
htmlElement = cast js.Browser.document.getElementById (cast (element, String));
|
||||
|
||||
} else if (element == null) {
|
||||
|
||||
htmlElement = cast js.Browser.document.createElement ("div");
|
||||
|
||||
} else {
|
||||
|
||||
htmlElement = cast element;
|
||||
|
||||
}
|
||||
|
||||
var color = null;
|
||||
|
||||
if (background != null && background != "") {
|
||||
|
||||
background = StringTools.replace (background, "#", "");
|
||||
|
||||
if (background.indexOf ("0x") > -1) {
|
||||
|
||||
color = Std.parseInt (background);
|
||||
|
||||
} else {
|
||||
|
||||
color = Std.parseInt ("0x" + background);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (width == null) {
|
||||
|
||||
width = 0;
|
||||
|
||||
}
|
||||
|
||||
if (height == null) {
|
||||
|
||||
height = 0;
|
||||
|
||||
}
|
||||
|
||||
config.windows[0].background = color;
|
||||
config.windows[0].element = htmlElement;
|
||||
config.windows[0].width = width;
|
||||
config.windows[0].height = height;
|
||||
config.assetsPrefix = assetsPrefix;
|
||||
|
||||
create ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@:keep @:expose("lime.embed")
|
||||
public static function _embed (element:Dynamic, width:Null<Int> = null, height:Null<Int> = null, background:String = null, assetsPrefix:String = null) {
|
||||
|
||||
embed (element, width, height, background, assetsPrefix);
|
||||
|
||||
}
|
||||
#end
|
||||
|
||||
|
||||
public static function start ():Void {
|
||||
public static function start (app:lime.app.Application = null):Void {
|
||||
|
||||
#if !munit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user