Register default asset library later during init
This commit is contained in:
@@ -44,13 +44,9 @@ class Assets {
|
||||
public static var libraries (default, null) = new Map <String, AssetLibrary> ();
|
||||
public static var onChange = new Event<Void->Void> ();
|
||||
|
||||
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<String> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var items = [];
|
||||
|
||||
for (library in libraries) {
|
||||
@@ -562,8 +525,6 @@ class Assets {
|
||||
|
||||
public static function loadAudioBuffer (id:String, useCache:Bool = true):Future<AudioBuffer> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<AudioBuffer> ();
|
||||
|
||||
#if (tools && !display)
|
||||
@@ -620,8 +581,6 @@ class Assets {
|
||||
|
||||
public static function loadBytes (id:String):Future<Bytes> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<Bytes> ();
|
||||
|
||||
#if (tools && !display)
|
||||
@@ -657,8 +616,6 @@ class Assets {
|
||||
|
||||
public static function loadFont (id:String):Future<Font> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<Font> ();
|
||||
|
||||
#if (tools && !display)
|
||||
@@ -694,8 +651,6 @@ class Assets {
|
||||
|
||||
public static function loadImage (id:String, useCache:Bool = true):Future<Image> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<Image> ();
|
||||
|
||||
#if (tools && !display)
|
||||
@@ -752,8 +707,6 @@ class Assets {
|
||||
|
||||
public static function loadLibrary (name:String):Future<AssetLibrary> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<AssetLibrary> ();
|
||||
|
||||
#if (tools && !display)
|
||||
@@ -783,8 +736,6 @@ class Assets {
|
||||
|
||||
public static function loadText (id:String):Future<String> {
|
||||
|
||||
initialize ();
|
||||
|
||||
var promise = new Promise<String> ();
|
||||
|
||||
#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);
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
Reference in New Issue
Block a user