loader.path doesn't need to be in the config. Added prefix.

This commit is contained in:
Richard Davey 2018-05-02 13:11:17 +01:00
parent 196fad18a0
commit e6a3747291
15 changed files with 38 additions and 29 deletions

View file

@ -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;
} }
/** /**

View file

@ -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]
* *

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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,

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };

View file

@ -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
}; };