diff --git a/lime/system/System.hx b/lime/system/System.hx index 51b86c597..73eafa0df 100644 --- a/lime/system/System.hx +++ b/lime/system/System.hx @@ -10,7 +10,6 @@ import flash.Lib; #end #if (js && html5) -import js.html.Element; import js.Browser; #end @@ -43,69 +42,6 @@ class System { @:noCompletion private static var __directories = new Map (); - #if (js && html5) - @:keep @:expose("lime.embed") - public static function embed (element:Dynamic, width:Null = null, height:Null = null, background:String = null, assetsPrefix:String = null) { - - var htmlElement:Element = null; - - if (Std.is (element, String)) { - - htmlElement = cast Browser.document.getElementById (cast (element, String)); - - } else if (element == null) { - - htmlElement = cast 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; - - } - - #if tools - ApplicationMain.config.windows[0].background = color; - ApplicationMain.config.windows[0].element = htmlElement; - ApplicationMain.config.windows[0].width = width; - ApplicationMain.config.windows[0].height = height; - ApplicationMain.config.assetsPrefix = assetsPrefix; - ApplicationMain.create (); - #end - - } - #end - - public static function exit (code:Int):Void { #if android diff --git a/templates/haxe/ApplicationMain.hx b/templates/haxe/ApplicationMain.hx index 9a29b9f01..9f6b3e1a3 100644 --- a/templates/haxe/ApplicationMain.hx +++ b/templates/haxe/ApplicationMain.hx @@ -14,6 +14,53 @@ class ApplicationMain { private static var app:lime.app.Application; + public static function main () { + + config = { + + build: "::meta.buildNumber::", + company: "::meta.company::", + file: "::APP_FILE::", + fps: ::WIN_FPS::, + name: "::meta.title::", + orientation: "::WIN_ORIENTATION::", + packageName: "::meta.packageName::", + version: "::meta.version::", + windows: [ + ::foreach windows:: + { + allowHighDPI: ::allowHighDPI::, + antialiasing: ::antialiasing::, + background: ::background::, + borderless: ::borderless::, + depthBuffer: ::depthBuffer::, + display: ::display::, + fullscreen: ::fullscreen::, + hardware: ::hardware::, + height: ::height::, + hidden: #if munit true #else ::hidden:: #end, + maximized: ::maximized::, + minimized: ::minimized::, + parameters: "::parameters::", + resizable: ::resizable::, + stencilBuffer: ::stencilBuffer::, + title: "::title::", + vsync: ::vsync::, + width: ::width::, + x: ::x::, + y: ::y:: + },::end:: + ] + + }; + + #if (!html5 || munit) + create (); + #end + + } + + public static function create ():Void { preloader = new ::if (PRELOADER_NAME != "")::::PRELOADER_NAME::::else::lime.app.Preloader::end:: (); @@ -62,51 +109,66 @@ class ApplicationMain { } - public static function main () { + #if (js && html5) + @:keep @:expose("lime.embed") + public static function embed (element:Dynamic, width:Null = null, height:Null = null, background:String = null, assetsPrefix:String = null) { - config = { - - build: "::meta.buildNumber::", - company: "::meta.company::", - file: "::APP_FILE::", - fps: ::WIN_FPS::, - name: "::meta.title::", - orientation: "::WIN_ORIENTATION::", - packageName: "::meta.packageName::", - version: "::meta.version::", - windows: [ - ::foreach windows:: - { - allowHighDPI: ::allowHighDPI::, - antialiasing: ::antialiasing::, - background: ::background::, - borderless: ::borderless::, - depthBuffer: ::depthBuffer::, - display: ::display::, - fullscreen: ::fullscreen::, - hardware: ::hardware::, - height: ::height::, - hidden: #if munit true #else ::hidden:: #end, - maximized: ::maximized::, - minimized: ::minimized::, - parameters: "::parameters::", - resizable: ::resizable::, - stencilBuffer: ::stencilBuffer::, - title: "::title::", - vsync: ::vsync::, - width: ::width::, - x: ::x::, - y: ::y:: - },::end:: - ] - - }; + 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; - #if (!html5 || munit) create (); - #end } + #end public static function start ():Void { @@ -160,4 +222,4 @@ class ApplicationMain { #end -} +} \ No newline at end of file