Load assets from next of the executable, #Fix openfl/723 (#719)
This commit is contained in:
@@ -18,6 +18,7 @@ import lime.utils.UInt8Array;
|
|||||||
import lime.Assets;
|
import lime.Assets;
|
||||||
|
|
||||||
#if sys
|
#if sys
|
||||||
|
import haxe.io.Path;
|
||||||
import sys.FileSystem;
|
import sys.FileSystem;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -44,6 +45,12 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
private var lastModified:Float;
|
private var lastModified:Float;
|
||||||
private var timer:Timer;
|
private var timer:Timer;
|
||||||
|
|
||||||
|
#if sys
|
||||||
|
private var rootPath = FileSystem.absolutePath (Path.directory (#if (haxe_ver >= 3.3) Sys.programPath () #else Sys.executablePath () #end)) + "/";
|
||||||
|
#else
|
||||||
|
private var rootPath = "";
|
||||||
|
#end
|
||||||
|
|
||||||
|
|
||||||
public function new () {
|
public function new () {
|
||||||
|
|
||||||
@@ -195,7 +202,7 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
if (className.exists(id)) return AudioBuffer.fromBytes (cast (Type.createInstance (className.get (id), []), Bytes));
|
if (className.exists(id)) return AudioBuffer.fromBytes (cast (Type.createInstance (className.get (id), []), Bytes));
|
||||||
else return AudioBuffer.fromFile (path.get (id));
|
else return AudioBuffer.fromFile (rootPath + path.get (id));
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -249,7 +256,7 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
if (className.exists(id)) return cast (Type.createInstance (className.get (id), []), Bytes);
|
if (className.exists(id)) return cast (Type.createInstance (className.get (id), []), Bytes);
|
||||||
else return Bytes.readFile (path.get (id));
|
else return Bytes.readFile (rootPath + path.get (id));
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -279,7 +286,7 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return Font.fromFile (path.get (id));
|
return Font.fromFile (rootPath + path.get (id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +314,7 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return Image.fromFile (path.get (id));
|
return Image.fromFile (rootPath + path.get (id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,4 +776,4 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
::end::::end::::end::
|
::end::::end::::end::
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|||||||
Reference in New Issue
Block a user