From 73fd3523015f17fbf55e2d1bc71f374f39071af6 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 27 Oct 2016 15:55:57 -0700 Subject: [PATCH] Register default asset library later during init --- lime/Assets.hx | 51 ------------------------------- templates/haxe/ApplicationMain.hx | 7 ++--- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/lime/Assets.hx b/lime/Assets.hx index 661f5a0e1..c76ee7ee1 100644 --- a/lime/Assets.hx +++ b/lime/Assets.hx @@ -44,13 +44,9 @@ class Assets { public static var libraries (default, null) = new Map (); public static var onChange = new EventVoid> (); - private static var initialized = false; - public static function exists (id:String, type:AssetType = null):Bool { - initialize (); - #if (tools && !display) if (type == null) { @@ -84,8 +80,6 @@ class Assets { */ public static function getAudioBuffer (id:String, useCache:Bool = true):AudioBuffer { - initialize (); - #if (tools && !display) if (useCache && cache.enabled && cache.audio.exists (id)) { @@ -153,8 +147,6 @@ class Assets { */ public static function getBytes (id:String):Bytes { - initialize (); - #if (tools && !display) var libraryName = id.substring (0, id.indexOf(":")); @@ -202,8 +194,6 @@ class Assets { */ public static function getFont (id:String, useCache:Bool = true):Font { - initialize (); - #if (tools && !display) if (useCache && cache.enabled && cache.font.exists (id)) { @@ -266,8 +256,6 @@ class Assets { */ public static function getImage (id:String, useCache:Bool = true):Image { - initialize (); - #if (tools && !display) if (useCache && cache.enabled && cache.image.exists (id)) { @@ -348,8 +336,6 @@ class Assets { */ public static function getPath (id:String):String { - initialize (); - #if (tools && !display) var libraryName = id.substring (0, id.indexOf (":")); @@ -389,8 +375,6 @@ class Assets { */ public static function getText (id:String):String { - initialize (); - #if (tools && !display) var libraryName = id.substring (0, id.indexOf(":")); @@ -430,27 +414,8 @@ class Assets { } - private static function initialize ():Void { - - if (!initialized) { - - #if (tools && !display) - - //registerLibrary ("default", new DefaultAssetLibrary ()); - - #end - - initialized = true; - - } - - } - - public static function isLocal (id:String, type:AssetType = null, useCache:Bool = true):Bool { - initialize (); - #if (tools && !display) if (useCache && cache.enabled) { @@ -539,8 +504,6 @@ class Assets { public static function list (type:AssetType = null):Array { - initialize (); - var items = []; for (library in libraries) { @@ -562,8 +525,6 @@ class Assets { public static function loadAudioBuffer (id:String, useCache:Bool = true):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -620,8 +581,6 @@ class Assets { public static function loadBytes (id:String):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -657,8 +616,6 @@ class Assets { public static function loadFont (id:String):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -694,8 +651,6 @@ class Assets { public static function loadImage (id:String, useCache:Bool = true):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -752,8 +707,6 @@ class Assets { public static function loadLibrary (name:String):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -783,8 +736,6 @@ class Assets { public static function loadText (id:String):Future { - initialize (); - var promise = new Promise (); #if (tools && !display) @@ -847,8 +798,6 @@ class Assets { public static function unloadLibrary (name:String):Void { - initialize(); - #if (tools && !display) var library = libraries.get (name); diff --git a/templates/haxe/ApplicationMain.hx b/templates/haxe/ApplicationMain.hx index af68dd2c1..2986cfa2d 100644 --- a/templates/haxe/ApplicationMain.hx +++ b/templates/haxe/ApplicationMain.hx @@ -1,5 +1,4 @@ -import ::APP_MAIN::; -import lime.Assets; +package; @:access(lime.app.Application) @@ -16,8 +15,6 @@ class ApplicationMain { public static function main () { - lime.Assets.registerLibrary ("default", new DefaultAssetLibrary ()); - config = { build: "::meta.buildNumber::", @@ -175,6 +172,8 @@ class ApplicationMain { public static function start ():Void { + lime.Assets.registerLibrary ("default", new DefaultAssetLibrary ()); + #if !munit var result = app.exec ();