Merge pull request #326 from ioga/assets-prefix
Support custom prefix (root) for resources URLs in html5.
This commit is contained in:
@@ -9,6 +9,7 @@ typedef Config = {
|
|||||||
@:optional var depthBuffer:Bool;
|
@:optional var depthBuffer:Bool;
|
||||||
#if (js && html5)
|
#if (js && html5)
|
||||||
@:optional var element:js.html.HtmlElement;
|
@:optional var element:js.html.HtmlElement;
|
||||||
|
@:optional var assetsPrefix:String;
|
||||||
#end
|
#end
|
||||||
@:optional var fps:Int;
|
@:optional var fps:Int;
|
||||||
@:optional var fullscreen:Bool;
|
@:optional var fullscreen:Bool;
|
||||||
@@ -20,4 +21,4 @@ typedef Config = {
|
|||||||
@:optional var vsync:Bool;
|
@:optional var vsync:Bool;
|
||||||
@:optional var width:Int;
|
@:optional var width:Int;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class System {
|
|||||||
|
|
||||||
#if (js && html5)
|
#if (js && html5)
|
||||||
@:keep @:expose("lime.embed")
|
@:keep @:expose("lime.embed")
|
||||||
public static function embed (element:Dynamic, width:Null<Int> = null, height:Null<Int> = null, background:String = null) {
|
public static function embed (element:Dynamic, width:Null<Int> = null, height:Null<Int> = null, background:String = null, assetsPrefix:String = null) {
|
||||||
|
|
||||||
var htmlElement:HtmlElement = null;
|
var htmlElement:HtmlElement = null;
|
||||||
|
|
||||||
@@ -91,6 +91,7 @@ class System {
|
|||||||
ApplicationMain.config.element = htmlElement;
|
ApplicationMain.config.element = htmlElement;
|
||||||
ApplicationMain.config.width = width;
|
ApplicationMain.config.width = width;
|
||||||
ApplicationMain.config.height = height;
|
ApplicationMain.config.height = height;
|
||||||
|
ApplicationMain.config.assetsPrefix = assetsPrefix;
|
||||||
ApplicationMain.create ();
|
ApplicationMain.create ();
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -436,4 +437,4 @@ class System {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class ApplicationMain {
|
|||||||
::else::types.push (null);::end::
|
::else::types.push (null);::end::
|
||||||
::end::::end::
|
::end::::end::
|
||||||
|
|
||||||
|
urls = [for (url in urls) Assets.getPath(url)];
|
||||||
|
|
||||||
preloader.load (urls, types);
|
preloader.load (urls, types);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
@@ -99,4 +101,4 @@ class ApplicationMain {
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,13 @@ class DefaultAssetLibrary extends AssetLibrary {
|
|||||||
type.set (id, AssetType.$$upper(::type::));
|
type.set (id, AssetType.$$upper(::type::));
|
||||||
::end::::end::
|
::end::::end::
|
||||||
|
|
||||||
|
var assetsPrefix = ApplicationMain.config.assetsPrefix;
|
||||||
|
if (assetsPrefix != null) {
|
||||||
|
for (k in path.keys()) {
|
||||||
|
path.set(k, assetsPrefix + path[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if openfl
|
#if openfl
|
||||||
|
|||||||
Reference in New Issue
Block a user