diff --git a/src/lime/_internal/backend/flash/FlashApplication.hx b/src/lime/_internal/backend/flash/FlashApplication.hx index 896bb2fa2..ba4958681 100644 --- a/src/lime/_internal/backend/flash/FlashApplication.hx +++ b/src/lime/_internal/backend/flash/FlashApplication.hx @@ -23,8 +23,7 @@ class FlashApplication { AudioManager.init (); #if (flash && !air) - var window = new Window (); - parent.addWindow (window); + parent.createWindow ({}); #end } diff --git a/src/lime/_internal/backend/flash/FlashWindow.hx b/src/lime/_internal/backend/flash/FlashWindow.hx index ac561e3d4..98947a868 100644 --- a/src/lime/_internal/backend/flash/FlashWindow.hx +++ b/src/lime/_internal/backend/flash/FlashWindow.hx @@ -16,6 +16,7 @@ import flash.Lib; import lime.app.Application; import lime.graphics.Image; import lime.graphics.RenderContext; +import lime.graphics.RenderContextAttributes; import lime.math.Rectangle; import lime.ui.KeyCode; import lime.ui.KeyModifier; @@ -53,7 +54,75 @@ class FlashWindow { cacheMouseX = 0; cacheMouseY = 0; - frameRate = 60; + + var attributes = parent.__attributes; + + parent.id = windowID++; + + if (stage == null) stage = Lib.current.stage; + + stage.align = StageAlign.TOP_LEFT; + stage.scaleMode = StageScaleMode.NO_SCALE; + + stage.addEventListener (KeyboardEvent.KEY_DOWN, handleKeyEvent); + stage.addEventListener (KeyboardEvent.KEY_UP, handleKeyEvent); + + var events = [ "mouseDown", "mouseMove", "mouseUp", "mouseWheel", "middleMouseDown", "middleMouseMove", "middleMouseUp" #if ((!openfl && !disable_flash_right_click) || enable_flash_right_click) , "rightMouseDown", "rightMouseMove", "rightMouseUp" #end ]; + + for (event in events) { + + stage.addEventListener (event, handleMouseEvent); + + } + + stage.addEventListener (TouchEvent.TOUCH_BEGIN, handleTouchEvent); + stage.addEventListener (TouchEvent.TOUCH_MOVE, handleTouchEvent); + stage.addEventListener (TouchEvent.TOUCH_END, handleTouchEvent); + stage.addEventListener (Event.ACTIVATE, handleWindowEvent); + stage.addEventListener (Event.DEACTIVATE, handleWindowEvent); + stage.addEventListener (FocusEvent.FOCUS_IN, handleWindowEvent); + stage.addEventListener (FocusEvent.FOCUS_OUT, handleWindowEvent); + stage.addEventListener (Event.MOUSE_LEAVE, handleWindowEvent); + stage.addEventListener (Event.RESIZE, handleWindowEvent); + + var context = new RenderContext (); + context.flash = Lib.current; + context.type = FLASH; + context.version = Capabilities.version; + context.window = parent; + + var contextAttributes:RenderContextAttributes = { + + antialiasing: 0, + background: null, + colorDepth: 32, + depth: false, + hardware: false, + stencil: false, + type: FLASH, + version: Capabilities.version, + vsync: false, + + }; + + if (Reflect.hasField (attributes, "context") && Reflect.hasField (attributes.context, "background")) { + + stage.color = attributes.context.background; + contextAttributes.background = stage.color; + + } + + setFrameRate (Reflect.hasField (attributes, "frameRate") ? attributes.frameRate : 60); + + context.attributes = contextAttributes; + parent.context = context; + + // TODO: Wait for application.exec? + + cacheTime = Lib.getTimer (); + // handleApplicationEvent (null); + + stage.addEventListener (Event.ENTER_FRAME, handleApplicationEvent); } @@ -67,7 +136,7 @@ class FlashWindow { public function close ():Void { - parent.application.removeWindow (parent); + parent.application.__removeWindow (parent); } @@ -149,51 +218,6 @@ class FlashWindow { public function create (application:Application):Void { - parent.id = windowID++; - - if (stage == null) stage = Lib.current.stage; - - stage.align = StageAlign.TOP_LEFT; - stage.scaleMode = StageScaleMode.NO_SCALE; - - stage.addEventListener (KeyboardEvent.KEY_DOWN, handleKeyEvent); - stage.addEventListener (KeyboardEvent.KEY_UP, handleKeyEvent); - - var events = [ "mouseDown", "mouseMove", "mouseUp", "mouseWheel", "middleMouseDown", "middleMouseMove", "middleMouseUp" #if ((!openfl && !disable_flash_right_click) || enable_flash_right_click) , "rightMouseDown", "rightMouseMove", "rightMouseUp" #end ]; - - for (event in events) { - - stage.addEventListener (event, handleMouseEvent); - - } - - stage.addEventListener (TouchEvent.TOUCH_BEGIN, handleTouchEvent); - stage.addEventListener (TouchEvent.TOUCH_MOVE, handleTouchEvent); - stage.addEventListener (TouchEvent.TOUCH_END, handleTouchEvent); - stage.addEventListener (Event.ACTIVATE, handleWindowEvent); - stage.addEventListener (Event.DEACTIVATE, handleWindowEvent); - stage.addEventListener (FocusEvent.FOCUS_IN, handleWindowEvent); - stage.addEventListener (FocusEvent.FOCUS_OUT, handleWindowEvent); - stage.addEventListener (Event.MOUSE_LEAVE, handleWindowEvent); - stage.addEventListener (Event.RESIZE, handleWindowEvent); - - var context = new RenderContext (); - context.flash = Lib.current; - context.type = FLASH; - context.version = Capabilities.version; - context.window = parent; - context.attributes = parent.__contextAttributes; - - parent.context = context; - - // TODO: Wait for application.exec? - - cacheTime = Lib.getTimer (); - // handleApplicationEvent (null); - - stage.addEventListener (Event.ENTER_FRAME, handleApplicationEvent); - - setFrameRate (frameRate); } @@ -225,7 +249,7 @@ class FlashWindow { var deltaTime = currentTime - cacheTime; cacheTime = currentTime; - parent.onUpdate.dispatch (deltaTime); + parent.application.onUpdate.dispatch (deltaTime); parent.onRender.dispatch (parent.context); } diff --git a/src/lime/_internal/backend/html5/HTML5Application.hx b/src/lime/_internal/backend/html5/HTML5Application.hx index 8be259d2f..d405f9138 100644 --- a/src/lime/_internal/backend/html5/HTML5Application.hx +++ b/src/lime/_internal/backend/html5/HTML5Application.hx @@ -238,7 +238,7 @@ class HTML5Application { for (window in parent.__windows) { - parent.window.onUpdate.dispatch (Std.int (deltaTime)); + parent.onUpdate.dispatch (Std.int (deltaTime)); if (window.context != null) window.onRender.dispatch (window.context); } diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 1375c25d7..dddb7f011 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -21,6 +21,7 @@ import lime.graphics.opengl.GL; import lime.graphics.Image; import lime.graphics.OpenGLRenderContext; import lime.graphics.RenderContext; +import lime.graphics.RenderContextType; import lime.math.Rectangle; import lime.system.Display; import lime.system.DisplayMode; @@ -66,7 +67,7 @@ class HTML5Window { private var isFullscreen:Bool; private var parent:Window; private var primaryTouch:Touch; - private var renderType:String; + private var renderType:RenderContextType; private var requestedFullscreen:Bool; private var resizeElement:Bool; private var scale = 1.0; @@ -82,30 +83,8 @@ class HTML5Window { cacheMouseX = 0; cacheMouseY = 0; - } - - - public function alert (message:String, title:String):Void { - - if (message != null) { - - Browser.alert (message); - - } - - } - - - public function close ():Void { - - parent.application.removeWindow (parent); - - } - - - public function create (application:Application):Void { - - var attributes = parent.__contextAttributes; + var attributes = parent.__attributes; + if (!Reflect.hasField (attributes, "context")) attributes.context = {}; if (Reflect.hasField (attributes, "element")) { @@ -113,18 +92,12 @@ class HTML5Window { } - if (Reflect.hasField (attributes, "type")) { - - renderType = attributes.type; - // TODO: Support WebGL1, WebGL2? - - } - #if dom - renderType = "dom"; + attributes.context.type = DOM; + attributes.context.version = ""; #end - if (parent.allowHighDPI && renderType != "dom") { + if (Reflect.hasField (attributes, "allowHighDPI") && attributes.allowHighDPI && renderType != DOM) { scale = Browser.window.devicePixelRatio; @@ -132,8 +105,10 @@ class HTML5Window { parent.__scale = scale; - setWidth = parent.width; - setHeight = parent.height; + setWidth = Reflect.hasField (attributes, "width") ? attributes.width : 0; + setHeight = Reflect.hasField (attributes, "height") ? attributes.height : 0; + parent.width = setWidth; + parent.height = setHeight; parent.id = windowID++; @@ -143,7 +118,7 @@ class HTML5Window { } else { - if (renderType == "dom") { + if (renderType == DOM) { div = cast Browser.document.createElement ("div"); @@ -272,13 +247,31 @@ class HTML5Window { } + public function alert (message:String, title:String):Void { + + if (message != null) { + + Browser.alert (message); + + } + + } + + + public function close ():Void { + + parent.application.__removeWindow (parent); + + } + + private function createContext ():Void { var context = new RenderContext (); - var attributes = parent.__contextAttributes; + var contextAttributes = parent.__attributes.context; context.window = parent; - context.attributes = attributes; + context.attributes = contextAttributes; if (div != null) { @@ -290,23 +283,23 @@ class HTML5Window { var webgl:HTML5WebGL2RenderContext = null; - var forceCanvas = #if (canvas || munit) true #else (renderType == "canvas") #end; - var forceWebGL = #if webgl true #else (renderType == "opengl" || renderType == "webgl" || renderType == "webgl1" || renderType == "webgl2") #end; - var allowWebGL2 = #if webgl1 false #else (renderType != "webgl1") #end; + var forceCanvas = #if (canvas || munit) true #else (renderType == CANVAS) #end; + var forceWebGL = #if webgl true #else (renderType == OPENGL || renderType == OPENGLES || renderType == WEBGL) #end; + var allowWebGL2 = #if webgl1 false #else (forceWebGL && (!Reflect.hasField (contextAttributes, "version") || contextAttributes.version != "1")) #end; var isWebGL2 = false; - if (forceWebGL || (!forceCanvas && (!Reflect.hasField (attributes, "hardware") || attributes.hardware))) { + if (forceWebGL || (!forceCanvas && (!Reflect.hasField (contextAttributes, "hardware") || contextAttributes.hardware))) { - var transparentBackground = Reflect.hasField (attributes, "background") && attributes.background == null; - var colorDepth = Reflect.hasField (attributes, "colorDepth") ? attributes.colorDepth : 16; + var transparentBackground = Reflect.hasField (contextAttributes, "background") && contextAttributes.background == null; + var colorDepth = Reflect.hasField (contextAttributes, "colorDepth") ? contextAttributes.colorDepth : 16; var options = { alpha: (transparentBackground || colorDepth > 16) ? true : false, - antialias: Reflect.hasField (attributes, "antialiasing") ? attributes.antialiasing > 0 : false, - depth: Reflect.hasField (attributes, "depth") ? attributes.depth : true, + antialias: Reflect.hasField (contextAttributes, "antialiasing") ? contextAttributes.antialiasing > 0 : false, + depth: Reflect.hasField (contextAttributes, "depth") ? contextAttributes.depth : true, premultipliedAlpha: true, - stencil: Reflect.hasField (attributes, "stencil") ? attributes.stencil : false, + stencil: Reflect.hasField (contextAttributes, "stencil") ? contextAttributes.stencil : false, preserveDrawingBuffer: false }; diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index 33cd9bd06..19fa0c794 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -176,11 +176,7 @@ class NativeApplication { updateTimer (); - for (window in parent.__windows) { - - if (window != null) window.onUpdate.dispatch (applicationEventInfo.deltaTime); - - } + parent.onUpdate.dispatch (applicationEventInfo.deltaTime); default: diff --git a/src/lime/_internal/backend/native/NativeWindow.hx b/src/lime/_internal/backend/native/NativeWindow.hx index ff0204c71..10c39691c 100644 --- a/src/lime/_internal/backend/native/NativeWindow.hx +++ b/src/lime/_internal/backend/native/NativeWindow.hx @@ -61,102 +61,55 @@ class NativeWindow { public function new (parent:Window) { this.parent = parent; - frameRate = 60; displayMode = new DisplayMode (0, 0, 0, 0); - } - - - public function alert (message:String, title:String):Void { - - if (handle != null) { - - #if (!macro && lime_cffi) - NativeCFFI.lime_window_alert (handle, message, title); - #end - - } - - } - - - public function close ():Void { - - if (!closing) { - - closing = true; - parent.onClose.dispatch (); - - if (!parent.onClose.canceled) { - - if (handle != null) { - - #if (!macro && lime_cffi) - NativeCFFI.lime_window_close (handle); - #end - handle = null; - - } - - } else { - - closing = false; - - } - - } - - - - } - - - public function create (application:Application):Void { - - var title = (parent.__title != null && parent.__title != "") ? parent.__title : "Lime Application"; - var attributes = parent.__contextAttributes; + var attributes = parent.__attributes; + var contextAttributes = Reflect.hasField (attributes, "context") ? attributes.context : {}; + var title = Reflect.hasField (attributes, "title") ? attributes.title : "Lime Application"; var flags = 0; - if (Reflect.hasField (attributes, "antialiasing")) { + if (!Reflect.hasField (contextAttributes, "antialiasing")) contextAttributes.antialiasing = 0; + if (!Reflect.hasField (contextAttributes, "background")) contextAttributes.background = 0; + if (!Reflect.hasField (contextAttributes, "colorDepth")) contextAttributes.colorDepth = 24; + if (!Reflect.hasField (contextAttributes, "depth")) contextAttributes.depth = true; + if (!Reflect.hasField (contextAttributes, "hardware")) contextAttributes.hardware = true; + if (!Reflect.hasField (contextAttributes, "stencil")) contextAttributes.stencil = true; + if (!Reflect.hasField (contextAttributes, "vsync")) contextAttributes.vsync = false; + + #if (cairo || !lime_opengl) contextAttributes.type = CAIRO; #end + if (Reflect.hasField (contextAttributes, "type") && contextAttributes.type == CAIRO) contextAttributes.hardware = false; + + if (Reflect.hasField (attributes, "allowHighDPI") && attributes.allowHighDPI) flags |= cast WindowFlags.WINDOW_FLAG_ALLOW_HIGHDPI; + if (Reflect.hasField (attributes, "alwaysOnTop") && attributes.alwaysOnTop) flags |= cast WindowFlags.WINDOW_FLAG_ALWAYS_ON_TOP; + if (Reflect.hasField (attributes, "borderless") && attributes.borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS; + if (Reflect.hasField (attributes, "fullscreen") && attributes.fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN; + if (Reflect.hasField (attributes, "hidden") && attributes.hidden) flags |= cast WindowFlags.WINDOW_FLAG_HIDDEN; + if (Reflect.hasField (attributes, "maximized") && attributes.maximized) flags |= cast WindowFlags.WINDOW_FLAG_MAXIMIZED; + if (Reflect.hasField (attributes, "minimized") && attributes.minimized) flags |= cast WindowFlags.WINDOW_FLAG_MINIMIZED; + if (Reflect.hasField (attributes, "resizable") && attributes.resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE; + + if (contextAttributes.antialiasing >= 4) { - if (attributes.antialiasing >= 4) { - - flags |= cast WindowFlags.WINDOW_FLAG_HW_AA_HIRES; - - } else if (attributes.antialiasing >= 2) { - - flags |= cast WindowFlags.WINDOW_FLAG_HW_AA; - - } + flags |= cast WindowFlags.WINDOW_FLAG_HW_AA_HIRES; + + } else if (contextAttributes.antialiasing >= 2) { + + flags |= cast WindowFlags.WINDOW_FLAG_HW_AA; } - if (parent.allowHighDPI) flags |= cast WindowFlags.WINDOW_FLAG_ALLOW_HIGHDPI; - if (parent.alwaysOnTop) flags |= cast WindowFlags.WINDOW_FLAG_ALWAYS_ON_TOP; - //if (Reflect.hasField (attributes, "borderless") && attributes.borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS; - if (parent.__borderless) flags |= cast WindowFlags.WINDOW_FLAG_BORDERLESS; - if (Reflect.hasField (attributes, "depth") && attributes.depth) flags |= cast WindowFlags.WINDOW_FLAG_DEPTH_BUFFER; - //if (Reflect.hasField (attributes, "fullscreen") && attributes.fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN; - if (parent.__fullscreen) flags |= cast WindowFlags.WINDOW_FLAG_FULLSCREEN; - #if !cairo if (Reflect.hasField (attributes, "hardware") && attributes.hardware) flags |= cast WindowFlags.WINDOW_FLAG_HARDWARE; #end - if (parent.hidden) flags |= cast WindowFlags.WINDOW_FLAG_HIDDEN; - if (parent.maximized) flags |= cast WindowFlags.WINDOW_FLAG_MAXIMIZED; - if (parent.minimized) flags |= cast WindowFlags.WINDOW_FLAG_MINIMIZED; - //if (Reflect.hasField (attributes, "resizable") && attributes.resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE; - if (parent.__resizable) flags |= cast WindowFlags.WINDOW_FLAG_RESIZABLE; - if (Reflect.hasField (attributes, "stencil") && attributes.stencil) flags |= cast WindowFlags.WINDOW_FLAG_STENCIL_BUFFER; - if (Reflect.hasField (attributes, "vsync") && attributes.vsync) flags |= cast WindowFlags.WINDOW_FLAG_VSYNC; - if (Reflect.hasField (attributes, "colorDepth") && attributes.colorDepth == 32) flags |= cast WindowFlags.WINDOW_FLAG_COLOR_DEPTH_32_BIT; + if (contextAttributes.colorDepth == 32) flags |= cast WindowFlags.WINDOW_FLAG_COLOR_DEPTH_32_BIT; + if (contextAttributes.depth) flags |= cast WindowFlags.WINDOW_FLAG_DEPTH_BUFFER; + if (contextAttributes.hardware) flags |= cast WindowFlags.WINDOW_FLAG_HARDWARE; + if (contextAttributes.stencil) flags |= cast WindowFlags.WINDOW_FLAG_STENCIL_BUFFER; + if (contextAttributes.vsync) flags |= cast WindowFlags.WINDOW_FLAG_VSYNC; - //if (Reflect.hasField (attributes, "title")) { - // - //title = attributes.title; - // - //} + var width = Reflect.hasField (attributes, "width") ? attributes.width : #if desktop 800 #else 0 #end; + var height = Reflect.hasField (attributes, "height") ? attributes.height : #if desktop 600 #else 0 #end; #if (!macro && lime_cffi) - handle = NativeCFFI.lime_window_create (application.__backend.handle, parent.width, parent.height, flags, title); + handle = NativeCFFI.lime_window_create (parent.application.__backend.handle, width, height, flags, title); if (handle != null) { @@ -164,6 +117,7 @@ class NativeWindow { parent.__height = NativeCFFI.lime_window_get_height (handle); parent.__x = NativeCFFI.lime_window_get_x (handle); parent.__y = NativeCFFI.lime_window_get_y (handle); + parent.__hidden = (Reflect.hasField (attributes, "hidden") && attributes.hidden); parent.id = NativeCFFI.lime_window_get_id (handle); } @@ -172,7 +126,6 @@ class NativeWindow { var context = new RenderContext (); context.window = parent; - context.attributes = parent.__contextAttributes; #if hl var contextType = @:privateAccess String.fromUTF8 (NativeCFFI.lime_window_get_context_type (handle)); @@ -226,11 +179,57 @@ class NativeWindow { } - #end - + contextAttributes.type = context.type; + context.attributes = contextAttributes; parent.context = context; - setFrameRate (frameRate); + setFrameRate (Reflect.hasField (attributes, "frameRate") ? attributes.frameRate : 60); + + #end + + } + + + public function alert (message:String, title:String):Void { + + if (handle != null) { + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_alert (handle, message, title); + #end + + } + + } + + + public function close ():Void { + + if (!closing) { + + closing = true; + parent.onClose.dispatch (); + + if (!parent.onClose.canceled) { + + if (handle != null) { + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_close (handle); + #end + handle = null; + + } + + } else { + + closing = false; + + } + + } + + } diff --git a/src/lime/app/Application.hx b/src/lime/app/Application.hx index 7c7102812..d4f043dac 100644 --- a/src/lime/app/Application.hx +++ b/src/lime/app/Application.hx @@ -12,6 +12,7 @@ import lime.ui.KeyCode; import lime.ui.KeyModifier; import lime.ui.Touch; import lime.ui.Window; +import lime.ui.WindowAttributes; import lime.utils.Preloader; @:access(lime.ui.Window) @@ -36,17 +37,23 @@ class Application extends Module { **/ public static var current (default, null):Application; - /** * Meta-data values for the application, such as a version or a package name **/ - public var meta:MetaData; + public var meta:Map; /** * A list of currently attached Module instances **/ public var modules (default, null):Array; + /** + * Update events are dispatched each frame (usually just before rendering) + */ + public var onUpdate = new EventVoid> (); + + public var onWindowCreate = new EventVoid> (); + /** * The Preloader for the current Application **/ @@ -98,45 +105,18 @@ class Application extends Module { } - meta = {}; + meta = new Map (); modules = new Array (); __windowByID = new Map (); __windows = new Array (); __backend = new ApplicationBackend (this); - registerModule (this); + __registerLimeModule (this); - // if (config != null) { - - // if (Reflect.hasField (config, "windows")) { - - // for (windowConfig in config.windows) { - - // var window = new Window (windowConfig); - // createWindow (window); - - // #if ((flash && !air) || html5) - // break; - // #end - - // } - - // } - - // if (__preloader == null || __preloader.complete) { - - // setPreloader (__preloader); - - // for (module in modules) { - - // setPreloader (__preloader); - - // } - - // } - - // } + __preloader = new Preloader (); + __preloader.onProgress.add (onPreloadProgress); + __preloader.onComplete.add (onPreloadComplete); } @@ -147,25 +127,19 @@ class Application extends Module { */ public function addModule (module:IModule):Void { - module.registerModule (this); + module.__registerLimeModule (this); modules.push (module); - if (__windows.length > 0) { - - for (window in __windows) { - - module.addWindow (window); - - } - - } - - module.setPreloader (__preloader); - } - @:noCompletion public override function addWindow (window:Window):Void { + /** + * Creates a new Window and adds it to the Application + * @param window A Window object to add + */ + public function createWindow (attributes:WindowAttributes):Void { + + var window = new Window (this, attributes); window.onClose.add (__onWindowClose.bind (window), false, -10000); @@ -176,7 +150,6 @@ class Application extends Module { window.onActivate.add (onWindowActivate); window.onRenderContextLost.add (onRenderContextLost); window.onRenderContextRestored.add (onRenderContextRestored); - window.onCreate.add (onWindowCreate); window.onDeactivate.add (onWindowDeactivate); window.onDropFile.add (onWindowDropFile); window.onEnter.add (onWindowEnter); @@ -199,39 +172,13 @@ class Application extends Module { window.onRestore.add (onWindowRestore); window.onTextEdit.add (onTextEdit); window.onTextInput.add (onTextInput); - window.onUpdate.add (update); } - if (__windows.indexOf (window) == -1) { - - __windows.push (window); - - for (module in modules) { - - module.addWindow (window); - - } - - if (window.id == -1) { - - window.__create (this); - //__windows.push (window); - __windowByID.set (window.id, window); - - window.onCreate.dispatch (); - - } else { - - if (window == __window) { - - onWindowCreate (); - - } - - } - - } + __windows.push (window); + __windowByID.set (window.id, window); + + onWindowCreate.dispatch (window); } @@ -497,12 +444,6 @@ class Application extends Module { public function onWindowClose ():Void { } - /** - * Called when a window create event is fired on the primary window - */ - public function onWindowCreate ():Void { } - - /** * Called when a window deactivate event is fired on the primary window */ @@ -579,8 +520,39 @@ class Application extends Module { public function onWindowRestore ():Void { } - @:noCompletion public override function registerModule (application:Application):Void { + /** + * Removes a module from the Application + * @param module A module to remove + */ + public function removeModule (module:IModule):Void { + if (module != null) { + + module.__unregisterLimeModule (this); + modules.remove (module); + + } + + } + + + /** + * Called when a render event is fired on the primary window + * @param context The render context ready to be rendered + */ + public function render (context:RenderContext):Void { } + + + /** + * Called when an update event is fired on the primary window + * @param deltaTime The amount of time in milliseconds that has elapsed since the last update + */ + public function update (deltaTime:Int):Void { } + + + @:noCompletion private override function __registerLimeModule (application:Application):Void { + + application.onUpdate.add (update); application.onExit.add (onModuleExit, false, 0); application.onExit.add (__onModuleExit, false, 0); @@ -608,23 +580,7 @@ class Application extends Module { } - /** - * Removes a module from the Application - * @param module A module to remove - */ - public function removeModule (module:IModule):Void { - - if (module != null) { - - module.unregisterModule (this); - modules.remove (module); - - } - - } - - - @:noCompletion public override function removeWindow (window:Window):Void { + @:noCompletion private function __removeWindow (window:Window):Void { if (window != null && __windowByID.exists (window.id)) { @@ -649,68 +605,6 @@ class Application extends Module { } - /** - * Called when a render event is fired on the primary window - * @param context The render context ready to be rendered - */ - public function render (context:RenderContext):Void { } - - - @:noCompletion public override function setPreloader (preloader:Preloader):Void { - - if (__preloader != null) { - - __preloader.onProgress.remove (onPreloadProgress); - __preloader.onComplete.remove (onPreloadComplete); - - } - - __preloader = preloader; - - if (preloader == null || preloader.complete) { - - onPreloadComplete (); - - } else { - - preloader.onProgress.add (onPreloadProgress); - preloader.onComplete.add (onPreloadComplete); - - } - - for (module in modules) { - - module.setPreloader (preloader); - - } - - } - - - @:noCompletion public override function unregisterModule (application:Application):Void { - - application.onExit.remove (__onModuleExit); - application.onExit.remove (onModuleExit); - - Gamepad.onConnect.remove (__onGamepadConnect); - Joystick.onConnect.remove (__onJoystickConnect); - Touch.onCancel.remove (onTouchCancel); - Touch.onStart.remove (onTouchStart); - Touch.onMove.remove (onTouchMove); - Touch.onEnd.remove (onTouchEnd); - - onModuleExit (0); - - } - - - /** - * Called when an update event is fired on the primary window - * @param deltaTime The amount of time in milliseconds that has elapsed since the last update - */ - public function update (deltaTime:Int):Void { } - - @:noCompletion private function __onGamepadConnect (gamepad:Gamepad):Void { onGamepadConnect (gamepad); @@ -752,7 +646,24 @@ class Application extends Module { } - removeWindow (window); + __removeWindow (window); + + } + + + @:noCompletion private override function __unregisterLimeModule (application:Application):Void { + + application.onExit.remove (__onModuleExit); + application.onExit.remove (onModuleExit); + + Gamepad.onConnect.remove (__onGamepadConnect); + Joystick.onConnect.remove (__onJoystickConnect); + Touch.onCancel.remove (onTouchCancel); + Touch.onStart.remove (onTouchStart); + Touch.onMove.remove (onTouchMove); + Touch.onEnd.remove (onTouchEnd); + + onModuleExit (0); } diff --git a/src/lime/app/IModule.hx b/src/lime/app/IModule.hx index f8fefbf9d..de6ac8413 100644 --- a/src/lime/app/IModule.hx +++ b/src/lime/app/IModule.hx @@ -1,18 +1,11 @@ package lime.app; -import lime.ui.Window; -import lime.utils.Preloader; - - interface IModule { - @:noCompletion public function addWindow (window:Window):Void; - @:noCompletion public function registerModule (application:Application):Void; - @:noCompletion public function removeWindow (window:Window):Void; - @:noCompletion public function setPreloader (preloader:Preloader):Void; - @:noCompletion public function unregisterModule (application:Application):Void; + @:noCompletion private function __registerLimeModule (application:Application):Void; + @:noCompletion private function __unregisterLimeModule (application:Application):Void; } \ No newline at end of file diff --git a/src/lime/app/MetaData.hx b/src/lime/app/MetaData.hx deleted file mode 100644 index 129889b52..000000000 --- a/src/lime/app/MetaData.hx +++ /dev/null @@ -1,80 +0,0 @@ -package lime.app; - - -@:forward() - - -abstract MetaData(Dynamic) from Dynamic to Dynamic { - - /** - * A build number - * - * The build number is a unique, integer-based value which increases - * upon each build or release of an application. This is distinct from - * the version number. - * - * In the default generated config for Lime applications, this is often - * updated automatically, or can be overriden in XML project files using - * the `` attribute - **/ - public var build (get, set):String; - @:noCompletion private inline function get_build () { return this.build; } - @:noCompletion private inline function set_build (value) { return this.build = value; } - - /** - * A company name - * - * In the default generated config for Lime applications, this value - * corresponds to the `` attribute in XML - **/ - public var company (get, set):String; - @:noCompletion private inline function get_company () { return this.company; } - @:noCompletion private inline function set_company (value) { return this.company = value; } - - /** - * An application file name, without a file extension - * - * In the default generated config for Lime applications, this value - * corresponds to the `` attribute in XML - **/ - public var file (get, set):String; - @:noCompletion private inline function get_file () { return this.file; } - @:noCompletion private inline function set_file (value) { return this.file = value; } - - /** - * An application name, used as the default Window title - * - * In the default generated config for Lime applications, this value - * corresponds to the `` attribute in XML - **/ - public var name (get, set):String; - @:noCompletion private inline function get_name () { return this.name; } - @:noCompletion private inline function set_name (value) { return this.name = value; } - - /** - * A package name, this usually corresponds to the unique ID used - * in application stores to identify the current application - * - * In the default generated config for Lime applications, this value - * corresponds to the `` attribute in XML - **/ - public var packageName (get, set):String; - @:noCompletion private inline function get_packageName () { return this.packageName; } - @:noCompletion private inline function set_packageName (value) { return this.packageName = value; } - - /** - * A version number - * - * The version number is what normally corresponds to the user-facing - * version for an application, such as "1.0.0" or "12.2.5". This is - * distinct from the build number. Many application stores expect the - * version number to include three segments. - * - * In the default generated config for Lime applications, this value - * corresponds to the `` attribute in XML - **/ - public var version (get, set):String; - @:noCompletion private inline function get_version () { return this.version; } - @:noCompletion private inline function set_version (value) { return this.version = value; } - -} \ No newline at end of file diff --git a/src/lime/app/Module.hx b/src/lime/app/Module.hx index 3a5e76c23..3c5710828 100644 --- a/src/lime/app/Module.hx +++ b/src/lime/app/Module.hx @@ -26,11 +26,8 @@ class Module implements IModule { } - @:noCompletion public function addWindow (window:Window):Void {} - @:noCompletion public function registerModule (application:Application):Void {} - @:noCompletion public function removeWindow (window:Window):Void {} - @:noCompletion public function setPreloader (preloader:Preloader):Void {} - @:noCompletion public function unregisterModule (application:Application):Void {} + @:noCompletion private function __registerLimeModule (application:Application):Void {} + @:noCompletion private function __unregisterLimeModule (application:Application):Void {} } \ No newline at end of file diff --git a/src/lime/graphics/RenderContextAttributes.hx b/src/lime/graphics/RenderContextAttributes.hx index 373668a3c..9564ceb2c 100644 --- a/src/lime/graphics/RenderContextAttributes.hx +++ b/src/lime/graphics/RenderContextAttributes.hx @@ -1,21 +1,16 @@ package lime.graphics; -#if (js && html5) -import js.html.Element; -#end - - typedef RenderContextAttributes = { @:optional var antialiasing:Int; @:optional var background:Null; @:optional var colorDepth:Int; @:optional var depth:Bool; - @:optional var element:#if (js && html5 && !doc_gen) js.html.Element #else Dynamic #end; @:optional var hardware:Bool; @:optional var stencil:Bool; @:optional var type:RenderContextType; + @:optional var version:String; @:optional var vsync:Bool; } \ No newline at end of file diff --git a/src/lime/system/BackgroundWorker.hx b/src/lime/system/BackgroundWorker.hx index 5588488e5..f4b894416 100644 --- a/src/lime/system/BackgroundWorker.hx +++ b/src/lime/system/BackgroundWorker.hx @@ -72,9 +72,9 @@ class BackgroundWorker { // TODO: Better way to do this - if (Application.current != null && Application.current.window != null) { + if (Application.current != null) { - Application.current.window.onUpdate.add (__update); + Application.current.onUpdate.add (__update); } diff --git a/src/lime/system/FileWatcher.hx b/src/lime/system/FileWatcher.hx index 6e369892f..26f35ba7d 100644 --- a/src/lime/system/FileWatcher.hx +++ b/src/lime/system/FileWatcher.hx @@ -39,9 +39,9 @@ class FileWatcher { public function addDirectory (path:String, recursive:Bool = true):Bool { #if (lime_cffi && !macro) - if (!__hasUpdate && Application.current != null && Application.current.window != null) { + if (!__hasUpdate && Application.current != null) { - Application.current.window.onUpdate.add (this_onUpdate); + Application.current.onUpdate.add (this_onUpdate); __hasUpdate = true; } diff --git a/src/lime/system/System.hx b/src/lime/system/System.hx index e0350d34e..91e9cfe73 100644 --- a/src/lime/system/System.hx +++ b/src/lime/system/System.hx @@ -6,7 +6,7 @@ import lime._internal.backend.native.NativeCFFI; import lime.app.Application; import lime.graphics.RenderContextAttributes; import lime.math.Rectangle; -import lime.ui.Window; +import lime.ui.WindowAttributes; import lime.utils.ArrayBuffer; import lime.utils.UInt8Array; import lime.utils.UInt16Array; @@ -413,17 +413,17 @@ class System { var company = "MyCompany"; var file = "MyApplication"; - if (Application.current != null && Application.current.meta != null) { + if (Application.current != null) { - if (Application.current.meta.company != null) { + if (Application.current.meta.exists ("company")) { - company = Application.current.meta.company; + company = Application.current.meta.get ("company"); } - if (Application.current.meta.file != null) { + if (Application.current.meta.exists ("file")) { - file = Application.current.meta.file; + file = Application.current.meta.get ("file"); } @@ -488,7 +488,7 @@ class System { #if sys - private static function __parseArguments (window:Window, attributes:RenderContextAttributes):Void { + private static function __parseArguments (attributes:WindowAttributes):Void { // TODO: Handle default arguments, like --window-fps=60 @@ -522,7 +522,8 @@ class System { if (parameters != null) { - if (window.parameters == null) window.parameters = {}; + if (attributes.parameters == null) attributes.parameters = {}; + if (attributes.context == null) attributes.context = {}; for (parameter in parameters.keys ()) { @@ -532,35 +533,36 @@ class System { switch (parameter.substr (windowParamPrefix.length)) { - case "allow-high-dpi": window.allowHighDPI = __parseBool (argValue); - case "always-on-top": window.alwaysOnTop = __parseBool (argValue); - case "antialiasing": attributes.antialiasing = Std.parseInt (argValue); - case "background": attributes.background = (argValue == "" || argValue == "null") ? null : Std.parseInt (argValue); - case "borderless": window.borderless = __parseBool (argValue); - case "colorDepth": attributes.colorDepth = Std.parseInt (argValue); - case "depth", "depthBuffer": attributes.depth = __parseBool (argValue); + case "allow-high-dpi": attributes.allowHighDPI = __parseBool (argValue); + case "always-on-top": attributes.alwaysOnTop = __parseBool (argValue); + case "antialiasing": attributes.context.antialiasing = Std.parseInt (argValue); + case "background": attributes.context.background = (argValue == "" || argValue == "null") ? null : Std.parseInt (argValue); + case "borderless": attributes.borderless = __parseBool (argValue); + case "colorDepth": attributes.context.colorDepth = Std.parseInt (argValue); + case "depth", "depth-buffer": attributes.context.depth = __parseBool (argValue); // case "display": windowConfig.display = Std.parseInt (argValue); - case "fullscreen": window.fullscreen = __parseBool (argValue); - case "hardware": attributes.hardware = __parseBool (argValue); - case "height": window.height = Std.parseInt (argValue); - case "hidden": window.hidden = __parseBool (argValue); - case "maximized": window.maximized = __parseBool (argValue); - case "minimized": window.minimized = __parseBool (argValue); - case "render-type", "renderer": attributes.type = argValue; - case "resizable": window.resizable = __parseBool (argValue); - case "stencil", "stencilBuffer": attributes.stencil = __parseBool (argValue); + case "fullscreen": attributes.fullscreen = __parseBool (argValue); + case "hardware": attributes.context.hardware = __parseBool (argValue); + case "height": attributes.height = Std.parseInt (argValue); + case "hidden": attributes.hidden = __parseBool (argValue); + case "maximized": attributes.maximized = __parseBool (argValue); + case "minimized": attributes.minimized = __parseBool (argValue); + case "render-type", "renderer": attributes.context.type = argValue; + case "render-version", "renderer-version": attributes.context.version = argValue; + case "resizable": attributes.resizable = __parseBool (argValue); + case "stencil", "stencil-buffer": attributes.context.stencil = __parseBool (argValue); //case "title": windowConfig.title = argValue; - case "vsync": attributes.vsync = __parseBool (argValue); - case "width": window.width = Std.parseInt (argValue); - case "x": window.x = Std.parseInt (argValue); - case "y": window.y = Std.parseInt (argValue); + case "vsync": attributes.context.vsync = __parseBool (argValue); + case "width": attributes.width = Std.parseInt (argValue); + case "x": attributes.x = Std.parseInt (argValue); + case "y": attributes.y = Std.parseInt (argValue); default: } - } else if (!Reflect.hasField (window.parameters, parameter)) { + } else if (!Reflect.hasField (attributes.parameters, parameter)) { - Reflect.setField (window.parameters, parameter, argValue); + Reflect.setField (attributes.parameters, parameter, argValue); } diff --git a/src/lime/system/ThreadPool.hx b/src/lime/system/ThreadPool.hx index 6b8d80432..b11092f52 100644 --- a/src/lime/system/ThreadPool.hx +++ b/src/lime/system/ThreadPool.hx @@ -91,9 +91,9 @@ class ThreadPool { } - if (!Application.current.window.onUpdate.has (__update)) { + if (!Application.current.onUpdate.has (__update)) { - Application.current.window.onUpdate.add (__update); + Application.current.onUpdate.add (__update); } @@ -253,9 +253,9 @@ class ThreadPool { // TODO: Add sleep if keeping minThreads running with no work? - if (currentThreads == 0 && minThreads <= 0 && Application.current != null && Application.current.window != null) { + if (currentThreads == 0 && minThreads <= 0 && Application.current != null) { - Application.current.window.onUpdate.remove (__update); + Application.current.onUpdate.remove (__update); } diff --git a/src/lime/ui/Window.hx b/src/lime/ui/Window.hx index 4bd60a8de..5a0e95842 100644 --- a/src/lime/ui/Window.hx +++ b/src/lime/ui/Window.hx @@ -31,8 +31,6 @@ typedef Stage = Dynamic; class Window { - public var allowHighDPI:Bool; - public var alwaysOnTop:Bool; public var application (default, null):Application; public var borderless (get, set):Bool; public var context (default, null):RenderContext; @@ -50,13 +48,12 @@ class Window { public var fullscreen (get, set):Bool; public var height (get, set):Int; - public var hidden:Bool; + public var hidden (get, null):Bool; public var id (default, null):Int; public var maximized (get, set):Bool; public var minimized (get, set):Bool; public var onActivate (default, null) = new EventVoid> (); public var onClose (default, null) = new EventVoid> (); - public var onCreate (default, null) = new EventVoid> (); public var onDeactivate (default, null) = new EventVoid> (); public var onDropFile (default, null) = new EventVoid> (); public var onEnter (default, null) = new EventVoid> (); @@ -81,12 +78,6 @@ class Window { public var onRestore (default, null) = new EventVoid> (); public var onTextEdit (default, null) = new EventInt->Int->Void> (); public var onTextInput (default, null) = new EventVoid> (); - - /** - * Update events are dispatched each frame (usually just before rendering) - */ - public var onUpdate = new EventVoid> (); - public var parameters:Dynamic; public var resizable (get, set):Bool; public var scale (get, null):Float; @@ -96,11 +87,12 @@ class Window { public var x (get, set):Int; public var y (get, set):Int; + @:noCompletion private var __attributes:WindowAttributes; @:noCompletion private var __backend:WindowBackend; @:noCompletion private var __borderless:Bool; - @:noCompletion private var __contextAttributes:RenderContextAttributes; @:noCompletion private var __fullscreen:Bool; @:noCompletion private var __height:Int; + @:noCompletion private var __hidden:Bool; @:noCompletion private var __maximized:Bool; @:noCompletion private var __minimized:Bool; @:noCompletion private var __resizable:Bool; @@ -136,15 +128,10 @@ class Window { #end - public function new () { + private function new (application:Application, attributes:WindowAttributes) { - __contextAttributes = { - - colorDepth: 32, - depth: true, - stencil: true - - }; + this.application = application; + __attributes = attributes != null ? attributes : {}; __width = 0; __height = 0; @@ -157,96 +144,6 @@ class Window { __backend = new WindowBackend (this); - } - - - public function alert (message:String = null, title:String = null):Void { - - __backend.alert (message, title); - - } - - - public function close ():Void { - - __backend.close (); - - } - - - public function focus ():Void { - - __backend.focus (); - - } - - - public function move (x:Int, y:Int):Void { - - __backend.move (x, y); - - __x = x; - __y = y; - - } - - - public function readPixels (rect:Rectangle = null):Image { - - return __backend.readPixels (rect); - - } - - - public function resize (width:Int, height:Int):Void { - - __backend.resize (width, height); - - __width = width; - __height = height; - - } - - - public function setContextAttributes (attributes:RenderContextAttributes):Void { - - if (attributes == null) return; - - for (field in Reflect.fields (attributes)) { - - Reflect.setField (__contextAttributes, field, Reflect.field (attributes, field)); - - } - - } - - - public function setIcon (image:Image):Void { - - if (image == null) { - - return; - - } - - __backend.setIcon (image); - - } - - - public function toString ():String { - - return "[object Window]"; - - } - - - @:noCompletion private function __create (application:Application):Void { - - this.application = application; - - __backend.create (application); - #if windows var mappings = [ @@ -462,6 +359,74 @@ class Window { } + public function alert (message:String = null, title:String = null):Void { + + __backend.alert (message, title); + + } + + + public function close ():Void { + + __backend.close (); + + } + + + public function focus ():Void { + + __backend.focus (); + + } + + + public function move (x:Int, y:Int):Void { + + __backend.move (x, y); + + __x = x; + __y = y; + + } + + + public function readPixels (rect:Rectangle = null):Image { + + return __backend.readPixels (rect); + + } + + + public function resize (width:Int, height:Int):Void { + + __backend.resize (width, height); + + __width = width; + __height = height; + + } + + + public function setIcon (image:Image):Void { + + if (image == null) { + + return; + + } + + __backend.setIcon (image); + + } + + + public function toString ():String { + + return "[object Window]"; + + } + + // Get & Set Methods @@ -561,6 +526,13 @@ class Window { } + @:noCompletion private inline function get_hidden ():Bool { + + return __hidden; + + } + + @:noCompletion private inline function get_maximized ():Bool { return __maximized; diff --git a/src/lime/ui/WindowAttributes.hx b/src/lime/ui/WindowAttributes.hx new file mode 100644 index 000000000..6c02b4f84 --- /dev/null +++ b/src/lime/ui/WindowAttributes.hx @@ -0,0 +1,28 @@ +package lime.ui; + + +import lime.graphics.RenderContextAttributes; + + +typedef WindowAttributes = { + + @:optional public var allowHighDPI:Bool; + @:optional public var alwaysOnTop:Bool; + @:optional public var borderless:Bool; + @:optional public var context:RenderContextAttributes; + // @:optional public var display:Int; + @:optional public var element:#if (js && html5 && !doc_gen) js.html.Element #else Dynamic #end; + @:optional public var frameRate:Float; + @:optional public var fullscreen:Bool; + @:optional public var height:Int; + @:optional public var hidden:Bool; + @:optional public var maximized:Bool; + @:optional public var minimized:Bool; + @:optional public var parameters:Dynamic; + @:optional public var resizable:Bool; + @:optional public var title:String; + @:optional public var width:Int; + @:optional public var x:Int; + @:optional public var y:Int; + +} \ No newline at end of file diff --git a/templates/haxe/ApplicationMain.hx b/templates/haxe/ApplicationMain.hx index f504c1ad0..f915af6f3 100644 --- a/templates/haxe/ApplicationMain.hx +++ b/templates/haxe/ApplicationMain.hx @@ -23,43 +23,43 @@ package; ManifestResources.init (config); - var preloader = new ::if (PRELOADER_NAME != "")::::PRELOADER_NAME::::else::lime.utils.Preloader::end:: (); - #if !munit var app = new ::APP_MAIN:: (); - app.setPreloader (preloader); - - app.meta.build = "::meta.buildNumber::"; - app.meta.company = "::meta.company::"; - app.meta.file = "::APP_FILE::"; - app.meta.name = "::meta.title::"; - app.meta.packageName = "::meta.packageName::"; + app.meta["build"] = "::meta.buildNumber::"; + app.meta["company"] = "::meta.company::"; + app.meta["file"] = "::APP_FILE::"; + app.meta["name"] = "::meta.title::"; + app.meta["packageName"] = "::meta.packageName::"; ::foreach windows:: - var window = new lime.ui.Window (); - ::if (allowHighDPI)::window.allowHighDPI = ::allowHighDPI::;::end:: - ::if (alwaysOnTop)::window.alwaysOnTop = ::alwaysOnTop::;::end:: - ::if (borderless)::window.borderless = ::borderless::;::end:: - ::if (fps)::window.frameRate = ::fps::;::end:: - ::if (fullscreen)::#if !web window.fullscreen = ::fullscreen::; #end::end:: - ::if (height)::window.height = ::height::;::end:: - ::if (hidden)::window.hidden = #if munit true #else ::hidden:: #end;::end:: - ::if (maximized)::window.maximized = ::maximized::;::end:: - ::if (minimized)::window.minimized = ::minimized::;::end:: - ::if (parameters)::window.parameters = ::parameters::;::end:: - ::if (resizable)::window.resizable = ::resizable::;::end:: - ::if (title)::window.title = "::title::";::end:: - ::if (width)::window.width = ::width::;::end:: - ::if (x)::window.x = ::x::;::end:: - ::if (y)::window.y = ::y::;::end:: + var attributes:lime.ui.WindowAttributes = { + + allowHighDPI: ::allowHighDPI::, + alwaysOnTop: ::alwaysOnTop::, + borderless: ::borderless::, + // display: ::display::, + element: null, + frameRate: ::fps::, + #if !web fullscreen: ::fullscreen::, #end + height: ::height::, + hidden: #if munit true #else ::hidden:: #end, + maximized: ::maximized::, + minimized: ::minimized::, + parameters: ::parameters::, + resizable: ::resizable::, + title: "::title::", + width: ::width::, + x: ::x::, + y: ::y::, + + }; - var attributes = { + attributes.context = { antialiasing: ::antialiasing::, background: ::background::, colorDepth: ::colorDepth::, depth: ::depthBuffer::, - element: null, hardware: ::hardware::, stencil: ::stencilBuffer::, type: null, @@ -73,14 +73,14 @@ package; for (field in Reflect.fields (config)) { - if (Reflect.hasField (window, field)) { - - Reflect.setField (window, field, Reflect.field (config, field)); - - } else if (Reflect.hasField (attributes, field)) { + if (Reflect.hasField (attributes, field)) { Reflect.setField (attributes, field, Reflect.field (config, field)); + } else if (Reflect.hasField (attributes.context, field)) { + + Reflect.setField (attributes.context, field, Reflect.field (config, field)); + } } @@ -88,31 +88,30 @@ package; } #if sys - lime.system.System.__parseArguments (window, attributes); + lime.system.System.__parseArguments (attributes); #end } - window.setContextAttributes (attributes); - app.addWindow (window); + app.createWindow (attributes); ::end:: #end - preloader.create (); + // preloader.create (); for (library in ManifestResources.preloadLibraries) { - preloader.addLibrary (library); + app.preloader.addLibrary (library); } for (name in ManifestResources.preloadLibraryNames) { - preloader.addLibraryName (name); + app.preloader.addLibraryName (name); } - preloader.load (); + app.preloader.load (); #if !munit start (app);