mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
loader.path doesn't need to be in the config. Added prefix.
This commit is contained in:
parent
196fad18a0
commit
e6a3747291
15 changed files with 38 additions and 29 deletions
|
@ -83,7 +83,7 @@ var File = new Class({
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
this.key = GetFastValue(fileConfig, 'key', false);
|
this.key = loader.prefix + GetFastValue(fileConfig, 'key', false);
|
||||||
|
|
||||||
if (!this.type || !this.key)
|
if (!this.type || !this.key)
|
||||||
{
|
{
|
||||||
|
@ -101,11 +101,11 @@ var File = new Class({
|
||||||
|
|
||||||
if (this.url === undefined)
|
if (this.url === undefined)
|
||||||
{
|
{
|
||||||
this.url = GetFastValue(fileConfig, 'path', '') + this.key + '.' + GetFastValue(fileConfig, 'extension', '');
|
this.url = loader.path + this.key + '.' + GetFastValue(fileConfig, 'extension', '');
|
||||||
}
|
}
|
||||||
else if (typeof(this.url) !== 'function')
|
else if (typeof(this.url) !== 'function')
|
||||||
{
|
{
|
||||||
this.url = GetFastValue(fileConfig, 'path', '').concat(this.url);
|
this.url = loader.path + this.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,6 +65,9 @@ var LoaderPlugin = new Class({
|
||||||
{
|
{
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
|
var gameConfig = scene.sys.game.config;
|
||||||
|
var sceneConfig = scene.sys.settings.loader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
@ -101,22 +104,19 @@ var LoaderPlugin = new Class({
|
||||||
*/
|
*/
|
||||||
this.textureManager = scene.sys.textures;
|
this.textureManager = scene.sys.textures;
|
||||||
|
|
||||||
/**
|
|
||||||
* [description]
|
|
||||||
*
|
|
||||||
* @name Phaser.Loader.LoaderPlugin#_multilist
|
|
||||||
* @type {object}
|
|
||||||
* @private
|
|
||||||
* @default {}
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
// this._multilist = {};
|
|
||||||
|
|
||||||
// Inject the available filetypes into the Loader
|
// Inject the available filetypes into the Loader
|
||||||
FileTypesManager.install(this);
|
FileTypesManager.install(this);
|
||||||
|
|
||||||
var gameConfig = this.systems.game.config;
|
/**
|
||||||
var sceneConfig = this.systems.settings.loader;
|
* An optional prefix that is automatically prepended to the start of every file key.
|
||||||
|
* If prefix was `MENU` and you load an image with the key 'Background' the resulting key would be `MENUBackground`.
|
||||||
|
*
|
||||||
|
* @name Phaser.Loader.LoaderPlugin#prefix
|
||||||
|
* @type {string}
|
||||||
|
* @default ''
|
||||||
|
* @since 3.7.0
|
||||||
|
*/
|
||||||
|
this.prefix = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
|
@ -142,6 +142,8 @@ var LoaderPlugin = new Class({
|
||||||
|
|
||||||
this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath));
|
this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath));
|
||||||
|
|
||||||
|
this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
@ -333,6 +335,26 @@ var LoaderPlugin = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional prefix that is automatically prepended to the start of every file key.
|
||||||
|
* If prefix was `MENU` and you load an image with the key 'Background' the resulting key would be `MENUBackground`.
|
||||||
|
*
|
||||||
|
* @method Phaser.Loader.LoaderPlugin#setPrefix
|
||||||
|
* @since 3.7.0
|
||||||
|
*
|
||||||
|
* @param {string} prefix - The prefix to use. Leave empty to reset.
|
||||||
|
*
|
||||||
|
* @return {Phaser.Loader.LoaderPlugin} This Loader object.
|
||||||
|
*/
|
||||||
|
setPrefix: function (prefix)
|
||||||
|
{
|
||||||
|
if (prefix === undefined) { prefix = ''; }
|
||||||
|
|
||||||
|
this.prefix = prefix;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,7 +51,6 @@ var AudioFile = new Class({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
key: key,
|
key: key,
|
||||||
url: GetFastValue(url, 'uri', url),
|
url: GetFastValue(url, 'uri', url),
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ var BinaryFile = new Class({
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ var GLSLFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ var HTML5AudioFile = new Class({
|
||||||
extension: GetFastValue(url, 'type', ''),
|
extension: GetFastValue(url, 'type', ''),
|
||||||
key: key,
|
key: key,
|
||||||
url: GetFastValue(url, 'uri', url),
|
url: GetFastValue(url, 'uri', url),
|
||||||
path: loader.path,
|
|
||||||
config: config
|
config: config
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ var HTMLFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings,
|
xhrSettings: xhrSettings,
|
||||||
config: {
|
config: {
|
||||||
width: width,
|
width: width,
|
||||||
|
|
|
@ -55,7 +55,6 @@ var ImageFile = new Class({
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings,
|
xhrSettings: xhrSettings,
|
||||||
config: frameConfig
|
config: frameConfig
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,6 @@ var JSONFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,6 @@ var PluginFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ var SVGFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ var ScriptFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ var TextFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ var TilemapCSVFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ var XMLFile = new Class({
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: loader.path,
|
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue