92 lines
1.5 KiB
Haxe
92 lines
1.5 KiB
Haxe
import ::APP_MAIN::;
|
|
|
|
|
|
class ApplicationMain {
|
|
|
|
|
|
private var app:lime.app.Application;
|
|
|
|
|
|
@:keep @:expose("lime.embed")
|
|
public static function embed (elementName:String, width:Null<Int> = null, height:Null<Int> = null, background:String = null) {
|
|
|
|
var element:js.html.HtmlElement = null;
|
|
|
|
if (elementName != null) {
|
|
|
|
element = cast js.Browser.document.getElementById (elementName);
|
|
|
|
}
|
|
|
|
var color = null;
|
|
|
|
if (background != null) {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
var app = new ::APP_MAIN:: ();
|
|
|
|
var config:lime.app.Config = {
|
|
|
|
antialiasing: Std.int (::WIN_ANTIALIASING::),
|
|
background: color,
|
|
borderless: ::WIN_BORDERLESS::,
|
|
depthBuffer: ::WIN_DEPTH_BUFFER::,
|
|
element: element,
|
|
fps: Std.int (::WIN_FPS::),
|
|
fullscreen: ::WIN_FULLSCREEN::,
|
|
height: height,
|
|
orientation: "::WIN_ORIENTATION::",
|
|
resizable: ::WIN_RESIZABLE::,
|
|
stencilBuffer: ::WIN_STENCIL_BUFFER::,
|
|
title: "::APP_TITLE::",
|
|
vsync: ::WIN_VSYNC::,
|
|
width: width,
|
|
|
|
}
|
|
|
|
app.create (config);
|
|
|
|
var result = app.exec ();
|
|
|
|
//#if sys
|
|
//Sys.exit (result);
|
|
//#end
|
|
|
|
}
|
|
|
|
|
|
public static function main () {
|
|
|
|
#if munit
|
|
embed (null, ::WIN_WIDTH::, ::WIN_HEIGHT::, "::WIN_FLASHBACKGROUND::");
|
|
#end
|
|
|
|
}
|
|
|
|
|
|
} |