mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
de7568acbb
21 changed files with 257 additions and 151 deletions
|
@ -24,10 +24,19 @@
|
||||||
* TextureSource will now remove its respective WebGLTexture from the renderer when destroyed.
|
* TextureSource will now remove its respective WebGLTexture from the renderer when destroyed.
|
||||||
* TextureSource will now automatically create a glTexture from its canvas if using one.
|
* TextureSource will now automatically create a glTexture from its canvas if using one.
|
||||||
* WebGLRenderer will now remove a GL texture from its local `nativeTextures` array when you call the `deleteTexture` method.
|
* WebGLRenderer will now remove a GL texture from its local `nativeTextures` array when you call the `deleteTexture` method.
|
||||||
|
* The BaseCache has a new method `exists` that will return a boolean if an entry for the given key exists in the cache or not.
|
||||||
|
* Loader.File has a new argument in its constructor which is an instance of the LoaderPlugin. It stores this in the `loader` property. It also has a new property `cache` which is a reference to the cache that the file type will be stored in.
|
||||||
|
* Loader.File has a new method `hasCacheConflict` which checks if a key matching the one used by this file exists in the target Cache or not.
|
||||||
|
* Loader.File has a new method `addToCache` which will add the file to its target cache and then emit a `filecomplete` event, passing its key and a reference to itself to the listener.
|
||||||
|
* LoaderPlugin has a new property `cacheManager` which is a reference to the global game cache and is used by the File Types.
|
||||||
|
* LoaderPlugin has a new property `textureManager` which is a reference to the global Texture Manager and is used by the File Types.
|
||||||
|
* LoaderPlugin will now check to see if loading a file would cache a cache conflict or not, and prevent it if it will.
|
||||||
|
* LoaderPlugin now passes off processing of the final file data to the file itself, which will now self-add itself to its target cache.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* DataManagerPlugin would throw an error on Game.destroy if you had any Scenes in the Scene Manager had not been run. Fix #3596 (thanks @kuoruan)
|
* DataManagerPlugin would throw an error on Game.destroy if you had any Scenes in the Scene Manager had not been run. Fix #3596 (thanks @kuoruan)
|
||||||
|
* If you created a Game with no Scenes defined, and then added one via `Game.scene.add` and passed in a data object, the data would be ignored when starting the Scene.
|
||||||
|
|
||||||
### Examples, Documentation and TypeScript
|
### Examples, Documentation and TypeScript
|
||||||
|
|
||||||
|
|
17
src/cache/BaseCache.js
vendored
17
src/cache/BaseCache.js
vendored
|
@ -83,6 +83,7 @@ var BaseCache = new Class({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this cache contains an item matching the given key.
|
* Checks if this cache contains an item matching the given key.
|
||||||
|
* This performs the same action as `BaseCache.exists`.
|
||||||
*
|
*
|
||||||
* @method Phaser.Cache.BaseCache#has
|
* @method Phaser.Cache.BaseCache#has
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
|
@ -96,6 +97,22 @@ var BaseCache = new Class({
|
||||||
return this.entries.has(key);
|
return this.entries.has(key);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this cache contains an item matching the given key.
|
||||||
|
* This performs the same action as `BaseCache.has` and is called directly by the Loader.
|
||||||
|
*
|
||||||
|
* @method Phaser.Cache.BaseCache#exists
|
||||||
|
* @since 3.7.0
|
||||||
|
*
|
||||||
|
* @param {string} key - The unique key of the item to be checked in this cache.
|
||||||
|
*
|
||||||
|
* @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`.
|
||||||
|
*/
|
||||||
|
exists: function (key)
|
||||||
|
{
|
||||||
|
return this.entries.has(key);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an item from this cache based on the given key.
|
* Gets an item from this cache based on the given key.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,14 +40,33 @@ var XHRSettings = require('./XHRSettings');
|
||||||
* @constructor
|
* @constructor
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
|
* @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File.
|
||||||
* @param {FileConfig} fileConfig - [description]
|
* @param {FileConfig} fileConfig - [description]
|
||||||
*/
|
*/
|
||||||
var File = new Class({
|
var File = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function File (fileConfig)
|
function File (loader, fileConfig)
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* A reference to the Loader that is going to load this file.
|
||||||
|
*
|
||||||
|
* @name Phaser.Loader.File#loader
|
||||||
|
* @type {Phaser.Loader.LoaderPlugin}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
|
this.loader = loader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the Cache, or Texture Manager, that is going to store this file if it loads.
|
||||||
|
*
|
||||||
|
* @name Phaser.Loader.File#cache
|
||||||
|
* @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)}
|
||||||
|
* @since 3.7.0
|
||||||
|
*/
|
||||||
|
this.cache = GetFastValue(fileConfig, 'cache');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file type string (image, json, etc) for sorting within the Loader.
|
* The file type string (image, json, etc) for sorting within the Loader.
|
||||||
*
|
*
|
||||||
|
@ -112,15 +131,6 @@ var File = new Class({
|
||||||
this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {}));
|
this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The LoaderPlugin instance that is loading this file.
|
|
||||||
*
|
|
||||||
* @name Phaser.Loader.File#loader
|
|
||||||
* @type {?Phaser.Loader.LoaderPlugin}
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
this.loader = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.
|
* The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.
|
||||||
*
|
*
|
||||||
|
@ -275,22 +285,18 @@ var File = new Class({
|
||||||
*
|
*
|
||||||
* @method Phaser.Loader.File#load
|
* @method Phaser.Loader.File#load
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
|
||||||
* @param {Phaser.Loader.LoaderPlugin} loader - The Loader that will load this File.
|
|
||||||
*/
|
*/
|
||||||
load: function (loader)
|
load: function ()
|
||||||
{
|
{
|
||||||
this.loader = loader;
|
|
||||||
|
|
||||||
if (this.state === CONST.FILE_POPULATED)
|
if (this.state === CONST.FILE_POPULATED)
|
||||||
{
|
{
|
||||||
this.onComplete();
|
this.onComplete();
|
||||||
|
|
||||||
loader.nextFile(this);
|
this.loader.nextFile(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.src = GetURL(this, loader.baseURL);
|
this.src = GetURL(this, this.loader.baseURL);
|
||||||
|
|
||||||
if (this.src.indexOf('data:') === 0)
|
if (this.src.indexOf('data:') === 0)
|
||||||
{
|
{
|
||||||
|
@ -298,7 +304,7 @@ var File = new Class({
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.xhrLoader = XHRLoader(this, loader.xhr);
|
this.xhrLoader = XHRLoader(this, this.loader.xhr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -407,6 +413,36 @@ var File = new Class({
|
||||||
{
|
{
|
||||||
this.state = CONST.FILE_COMPLETE;
|
this.state = CONST.FILE_COMPLETE;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a key matching the one used by this file exists in the target Cache or not.
|
||||||
|
* This is called automatically by the LoaderPlugin to decide if the file can be safely
|
||||||
|
* loaded or will conflict.
|
||||||
|
*
|
||||||
|
* @method Phaser.Loader.File#hasCacheConflict
|
||||||
|
* @since 3.7.0
|
||||||
|
*
|
||||||
|
* @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`.
|
||||||
|
*/
|
||||||
|
hasCacheConflict: function ()
|
||||||
|
{
|
||||||
|
return (this.cache.exists(this.key));
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds this file to its target cache upon successful loading and processing.
|
||||||
|
* It will emit a `filecomplete` event from the LoaderPlugin.
|
||||||
|
* This method is often overridden by specific file types.
|
||||||
|
*
|
||||||
|
* @method Phaser.Loader.File#addToCache
|
||||||
|
* @since 3.7.0
|
||||||
|
*/
|
||||||
|
addToCache: function ()
|
||||||
|
{
|
||||||
|
this.cache.add(this.key, this.data);
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,6 +84,24 @@ var LoaderPlugin = new Class({
|
||||||
*/
|
*/
|
||||||
this.systems = scene.sys;
|
this.systems = scene.sys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the global Cache Manager.
|
||||||
|
*
|
||||||
|
* @name Phaser.Loader.LoaderPlugin#cacheManager
|
||||||
|
* @type {Phaser.Cache.CacheManager}
|
||||||
|
* @since 3.7.0
|
||||||
|
*/
|
||||||
|
this.cacheManager = scene.sys.cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the global Texture Manager.
|
||||||
|
*
|
||||||
|
* @name Phaser.Loader.LoaderPlugin#textureManager
|
||||||
|
* @type {Phaser.Textures.TextureManager}
|
||||||
|
* @since 3.7.0
|
||||||
|
*/
|
||||||
|
this.textureManager = scene.sys.textures;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
@ -350,9 +368,13 @@ var LoaderPlugin = new Class({
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.path = this.path;
|
// Does the file already exist in the cache or texture manager?
|
||||||
|
if (!file.hasCacheConflict())
|
||||||
|
{
|
||||||
|
file.path = this.path;
|
||||||
|
|
||||||
this.list.set(file);
|
this.list.set(file);
|
||||||
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
},
|
},
|
||||||
|
@ -721,12 +743,6 @@ var LoaderPlugin = new Class({
|
||||||
animJSON.push(file);
|
animJSON.push(file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'image':
|
|
||||||
case 'svg':
|
|
||||||
case 'html':
|
|
||||||
textures.addImage(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'atlasjson':
|
case 'atlasjson':
|
||||||
|
|
||||||
fileA = file.fileA;
|
fileA = file.fileA;
|
||||||
|
@ -789,34 +805,6 @@ var LoaderPlugin = new Class({
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'spritesheet':
|
|
||||||
textures.addSpriteSheet(file.key, file.data, file.config);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'json':
|
|
||||||
cache.json.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'xml':
|
|
||||||
cache.xml.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'text':
|
|
||||||
cache.text.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'obj':
|
|
||||||
cache.obj.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'binary':
|
|
||||||
cache.binary.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'audio':
|
|
||||||
cache.audio.add(file.key, file.data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'audioSprite':
|
case 'audioSprite':
|
||||||
|
|
||||||
var files = [ file.fileA, file.fileB ];
|
var files = [ file.fileA, file.fileB ];
|
||||||
|
@ -828,14 +816,9 @@ var LoaderPlugin = new Class({
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'glsl':
|
default:
|
||||||
cache.shader.add(file.key, file.data);
|
file.addToCache();
|
||||||
break;
|
|
||||||
|
|
||||||
case 'tilemapCSV':
|
|
||||||
case 'tilemapJSON':
|
|
||||||
cache.tilemap.add(file.key, { format: file.tilemapFormat, data: file.data });
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1027,6 +1010,8 @@ var LoaderPlugin = new Class({
|
||||||
|
|
||||||
this.scene = null;
|
this.scene = null;
|
||||||
this.systems = null;
|
this.systems = null;
|
||||||
|
this.textureManager = null;
|
||||||
|
this.cacheManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,9 +20,9 @@ var JSONFile = require('./JSONFile.js');
|
||||||
*
|
*
|
||||||
* @return {Phaser.Loader.FileTypes.JSONFile} A File instance to be added to the Loader.
|
* @return {Phaser.Loader.FileTypes.JSONFile} A File instance to be added to the Loader.
|
||||||
*/
|
*/
|
||||||
var AnimationJSONFile = function (key, url, path, xhrSettings)
|
var AnimationJSONFile = function (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var json = new JSONFile(key, url, path, xhrSettings);
|
var json = new JSONFile(loader, key, url, xhrSettings);
|
||||||
|
|
||||||
// Override the File type
|
// Override the File type
|
||||||
json.type = 'animationJSON';
|
json.type = 'animationJSON';
|
||||||
|
@ -55,12 +55,12 @@ FileTypesManager.register('animation', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new AnimationJSONFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new AnimationJSONFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new AnimationJSONFile(key, url, this.path, xhrSettings));
|
this.addFile(new AnimationJSONFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -23,10 +23,10 @@ var JSONFile = require('./JSONFile.js');
|
||||||
*
|
*
|
||||||
* @return {object} An object containing two File objects to be added to the loader.
|
* @return {object} An object containing two File objects to be added to the loader.
|
||||||
*/
|
*/
|
||||||
var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings)
|
var AtlasJSONFile = function (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
||||||
{
|
{
|
||||||
var image = new ImageFile(key, textureURL, path, textureXhrSettings);
|
var image = new ImageFile(loader, key, textureURL, textureXhrSettings);
|
||||||
var data = new JSONFile(key, atlasURL, path, atlasXhrSettings);
|
var data = new JSONFile(loader, key, atlasURL, atlasXhrSettings);
|
||||||
|
|
||||||
// Link them together
|
// Link them together
|
||||||
image.linkFile = data;
|
image.linkFile = data;
|
||||||
|
@ -60,20 +60,19 @@ var AtlasJSONFile = function (key, textureURL, atlasURL, path, textureXhrSetting
|
||||||
*/
|
*/
|
||||||
FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
||||||
{
|
{
|
||||||
|
|
||||||
var files;
|
var files;
|
||||||
|
|
||||||
// If param key is an object, use object based loading method
|
// If param key is an object, use object based loading method
|
||||||
if ((typeof key === 'object') && (key !== null))
|
if ((typeof key === 'object') && (key !== null))
|
||||||
{
|
{
|
||||||
files = new AtlasJSONFile(key.key, key.texture, key.data, this.path, textureXhrSettings, atlasXhrSettings);
|
files = new AtlasJSONFile(this, key.key, key.texture, key.data, textureXhrSettings, atlasXhrSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Else just use the parameters like normal
|
// Else just use the parameters like normal
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Returns an object with two properties: 'texture' and 'data'
|
// Returns an object with two properties: 'texture' and 'data'
|
||||||
files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
|
files = new AtlasJSONFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addFile(files.texture);
|
this.addFile(files.texture);
|
||||||
|
|
|
@ -33,7 +33,7 @@ var AudioFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function AudioFile (key, url, path, xhrSettings, audioContext)
|
function AudioFile (loader, key, url, xhrSettings, audioContext)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
|
@ -46,15 +46,16 @@ var AudioFile = new Class({
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
|
cache: loader.cacheManager.audio,
|
||||||
extension: GetFastValue(url, 'type', ''),
|
extension: GetFastValue(url, 'type', ''),
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
key: key,
|
key: key,
|
||||||
url: GetFastValue(url, 'uri', url),
|
url: GetFastValue(url, 'uri', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,11 +120,11 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings)
|
||||||
|
|
||||||
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
|
if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
|
||||||
{
|
{
|
||||||
return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context);
|
return new AudioFile(loader, key, url, xhrSettings, game.sound.context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return new HTML5AudioFile(key, url, loader.path, config);
|
return new HTML5AudioFile(loader, key, url, config);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,21 +31,22 @@ var BinaryFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function BinaryFile (key, url, path, xhrSettings)
|
function BinaryFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'binary',
|
type: 'binary',
|
||||||
|
cache: loader.cacheManager.binary,
|
||||||
extension: GetFastValue(key, 'extension', 'bin'),
|
extension: GetFastValue(key, 'extension', 'bin'),
|
||||||
responseType: 'arraybuffer',
|
responseType: 'arraybuffer',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -85,12 +86,12 @@ FileTypesManager.register('binary', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new BinaryFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new BinaryFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new BinaryFile(key, url, this.path, xhrSettings));
|
this.addFile(new BinaryFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -31,21 +31,22 @@ var GLSLFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function GLSLFile (key, url, path, xhrSettings)
|
function GLSLFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'glsl',
|
type: 'glsl',
|
||||||
|
cache: loader.cacheManager.shader,
|
||||||
extension: GetFastValue(key, 'extension', 'glsl'),
|
extension: GetFastValue(key, 'extension', 'glsl'),
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -85,12 +86,12 @@ FileTypesManager.register('glsl', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new GLSLFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new GLSLFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new GLSLFile(key, url, this.path, xhrSettings));
|
this.addFile(new GLSLFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -30,23 +30,24 @@ var HTML5AudioFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function HTML5AudioFile (key, url, path, config)
|
function HTML5AudioFile (loader, key, url, config)
|
||||||
{
|
{
|
||||||
this.locked = 'ontouchstart' in window;
|
this.locked = 'ontouchstart' in window;
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
extension: GetFastValue(url, 'type', ''),
|
cache: loader.cacheManager.audio,
|
||||||
key: key,
|
extension: GetFastValue(url, 'type', ''),
|
||||||
url: GetFastValue(url, 'uri', url),
|
key: key,
|
||||||
path: path,
|
url: GetFastValue(url, 'uri', url),
|
||||||
config: config
|
path: loader.path,
|
||||||
};
|
config: config
|
||||||
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad: function ()
|
onLoad: function ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ var HTMLFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function HTMLFile (key, url, width, height, path, xhrSettings)
|
function HTMLFile (loader, key, url, width, height, xhrSettings)
|
||||||
{
|
{
|
||||||
if (width === undefined) { width = 512; }
|
if (width === undefined) { width = 512; }
|
||||||
if (height === undefined) { height = 512; }
|
if (height === undefined) { height = 512; }
|
||||||
|
@ -42,11 +42,12 @@ var HTMLFile = new Class({
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
|
cache: loader.textureManager,
|
||||||
extension: GetFastValue(key, 'extension', 'html'),
|
extension: GetFastValue(key, 'extension', 'html'),
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings),
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings),
|
||||||
config: {
|
config: {
|
||||||
width: width,
|
width: width,
|
||||||
|
@ -54,7 +55,7 @@ var HTMLFile = new Class({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -113,6 +114,13 @@ var HTMLFile = new Class({
|
||||||
};
|
};
|
||||||
|
|
||||||
File.createObjectURL(this.data, blob, 'image/svg+xml');
|
File.createObjectURL(this.data, blob, 'image/svg+xml');
|
||||||
|
},
|
||||||
|
|
||||||
|
addToCache: function ()
|
||||||
|
{
|
||||||
|
this.cache.addImage(this.key, this.data);
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -143,12 +151,12 @@ FileTypesManager.register('html', function (key, url, width, height, xhrSettings
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new HTMLFile(key[i], url, width, height, this.path, xhrSettings));
|
this.addFile(new HTMLFile(this, key[i], url, width, height, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new HTMLFile(key, url, width, height, this.path, xhrSettings));
|
this.addFile(new HTMLFile(this, key, url, width, height, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -48,22 +48,23 @@ var ImageFile = new Class({
|
||||||
// this.load.image({ key: 'bunny' });
|
// this.load.image({ key: 'bunny' });
|
||||||
// this.load.image({ key: 'bunny', extension: 'jpg' });
|
// this.load.image({ key: 'bunny', extension: 'jpg' });
|
||||||
|
|
||||||
function ImageFile (key, url, path, xhrSettings, config)
|
function ImageFile (loader, key, url, xhrSettings, config)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'image',
|
type: 'image',
|
||||||
|
cache: loader.textureManager,
|
||||||
extension: GetFastValue(key, 'extension', 'png'),
|
extension: GetFastValue(key, 'extension', 'png'),
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings),
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings),
|
||||||
config: GetFastValue(key, 'config', config)
|
config: GetFastValue(key, 'config', config)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -95,6 +96,13 @@ var ImageFile = new Class({
|
||||||
};
|
};
|
||||||
|
|
||||||
File.createObjectURL(this.data, this.xhrLoader.response, 'image/png');
|
File.createObjectURL(this.data, this.xhrLoader.response, 'image/png');
|
||||||
|
},
|
||||||
|
|
||||||
|
addToCache: function ()
|
||||||
|
{
|
||||||
|
this.cache.addImage(this.key, this.data);
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -131,14 +139,14 @@ FileTypesManager.register('image', function (key, url, xhrSettings)
|
||||||
|
|
||||||
if (Array.isArray(urls) && urls.length === 2)
|
if (Array.isArray(urls) && urls.length === 2)
|
||||||
{
|
{
|
||||||
fileA = this.addFile(new ImageFile(key[i], urls[0], this.path, xhrSettings));
|
fileA = this.addFile(new ImageFile(this, key[i], urls[0], xhrSettings));
|
||||||
fileB = this.addFile(new ImageFile(key[i], urls[1], this.path, xhrSettings));
|
fileB = this.addFile(new ImageFile(this, key[i], urls[1], xhrSettings));
|
||||||
|
|
||||||
fileA.setLinkFile(fileB, 'dataimage');
|
fileA.setLinkFile(fileB, 'dataimage');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new ImageFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new ImageFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,14 +156,14 @@ FileTypesManager.register('image', function (key, url, xhrSettings)
|
||||||
|
|
||||||
if (Array.isArray(urls) && urls.length === 2)
|
if (Array.isArray(urls) && urls.length === 2)
|
||||||
{
|
{
|
||||||
fileA = this.addFile(new ImageFile(key, urls[0], this.path, xhrSettings));
|
fileA = this.addFile(new ImageFile(this, key, urls[0], xhrSettings));
|
||||||
fileB = this.addFile(new ImageFile(key, urls[1], this.path, xhrSettings));
|
fileB = this.addFile(new ImageFile(this, key, urls[1], xhrSettings));
|
||||||
|
|
||||||
fileA.setLinkFile(fileB, 'dataimage');
|
fileA.setLinkFile(fileB, 'dataimage');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new ImageFile(key, url, this.path, xhrSettings));
|
this.addFile(new ImageFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,21 +33,22 @@ var JSONFile = new Class({
|
||||||
|
|
||||||
// url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object
|
// url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object
|
||||||
|
|
||||||
function JSONFile (key, url, path, xhrSettings)
|
function JSONFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
|
cache: loader.cacheManager.json,
|
||||||
extension: GetFastValue(key, 'extension', 'json'),
|
extension: GetFastValue(key, 'extension', 'json'),
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
|
|
||||||
if (typeof fileConfig.url === 'object')
|
if (typeof fileConfig.url === 'object')
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,21 +31,22 @@ var SVGFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function SVGFile (key, url, path, xhrSettings)
|
function SVGFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'svg',
|
type: 'svg',
|
||||||
|
cache: loader.textureManager,
|
||||||
extension: GetFastValue(key, 'extension', 'svg'),
|
extension: GetFastValue(key, 'extension', 'svg'),
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -106,6 +107,13 @@ var SVGFile = new Class({
|
||||||
};
|
};
|
||||||
|
|
||||||
File.createObjectURL(this.data, blob, 'image/svg+xml');
|
File.createObjectURL(this.data, blob, 'image/svg+xml');
|
||||||
|
},
|
||||||
|
|
||||||
|
addToCache: function ()
|
||||||
|
{
|
||||||
|
this.cache.addImage(this.key, this.data);
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -134,12 +142,12 @@ FileTypesManager.register('svg', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new SVGFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new SVGFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new SVGFile(key, url, this.path, xhrSettings));
|
this.addFile(new SVGFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -21,13 +21,20 @@ var ImageFile = require('./ImageFile.js');
|
||||||
*
|
*
|
||||||
* @return {object} An object containing two File objects to be added to the loader.
|
* @return {object} An object containing two File objects to be added to the loader.
|
||||||
*/
|
*/
|
||||||
var SpriteSheetFile = function (key, url, config, path, xhrSettings)
|
var SpriteSheetFile = function (loader, key, url, config, xhrSettings)
|
||||||
{
|
{
|
||||||
var image = new ImageFile(key, url, path, xhrSettings, config);
|
var image = new ImageFile(loader, key, url, xhrSettings, config);
|
||||||
|
|
||||||
// Override the File type
|
// Override the File type
|
||||||
image.type = 'spritesheet';
|
image.type = 'spritesheet';
|
||||||
|
|
||||||
|
image.addToCache = function ()
|
||||||
|
{
|
||||||
|
this.cache.addSpriteSheet(this.key, this.data, this.config);
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
|
};
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,12 +63,12 @@ FileTypesManager.register('spritesheet', function (key, url, config, xhrSettings
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new SpriteSheetFile(key[i], url, null, this.path, xhrSettings));
|
this.addFile(new SpriteSheetFile(this, key[i], url, null, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new SpriteSheetFile(key, url, config, this.path, xhrSettings));
|
this.addFile(new SpriteSheetFile(this, key, url, config, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -30,19 +30,20 @@ var TextFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function TextFile (key, url, path, xhrSettings)
|
function TextFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
cache: loader.cacheManager.text,
|
||||||
extension: 'txt',
|
extension: 'txt',
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -82,12 +83,12 @@ FileTypesManager.register('text', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new TextFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new TextFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new TextFile(key, url, this.path, xhrSettings));
|
this.addFile(new TextFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -32,19 +32,20 @@ var TilemapCSVFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function TilemapCSVFile (key, url, path, format, xhrSettings)
|
function TilemapCSVFile (loader, key, url, format, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'tilemapCSV',
|
type: 'tilemapCSV',
|
||||||
|
cache: loader.cacheManager.tilemap,
|
||||||
extension: '.csv',
|
extension: '.csv',
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: key,
|
key: key,
|
||||||
url: url,
|
url: url,
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: xhrSettings
|
xhrSettings: xhrSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
|
|
||||||
this.tilemapFormat = format;
|
this.tilemapFormat = format;
|
||||||
},
|
},
|
||||||
|
@ -58,6 +59,13 @@ var TilemapCSVFile = new Class({
|
||||||
this.onComplete();
|
this.onComplete();
|
||||||
|
|
||||||
callback(this);
|
callback(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
addToCache: function ()
|
||||||
|
{
|
||||||
|
this.cache.add(this.key, { format: this.tilemapFormat, data: this.data });
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -86,12 +94,12 @@ FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new TilemapCSVFile(key[i], url, this.path, TILEMAP_FORMATS.CSV, xhrSettings));
|
this.addFile(new TilemapCSVFile(this, key[i], url, TILEMAP_FORMATS.CSV, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new TilemapCSVFile(key, url, this.path, TILEMAP_FORMATS.CSV, xhrSettings));
|
this.addFile(new TilemapCSVFile(this, key, url, TILEMAP_FORMATS.CSV, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -22,15 +22,24 @@ var TILEMAP_FORMATS = require('../../tilemaps/Formats');
|
||||||
*
|
*
|
||||||
* @return {object} An object containing two File objects to be added to the loader.
|
* @return {object} An object containing two File objects to be added to the loader.
|
||||||
*/
|
*/
|
||||||
var TilemapJSONFile = function (key, url, path, format, xhrSettings)
|
var TilemapJSONFile = function (loader, key, url, format, xhrSettings)
|
||||||
{
|
{
|
||||||
var json = new JSONFile(key, url, path, xhrSettings);
|
var json = new JSONFile(loader, key, url, xhrSettings);
|
||||||
|
|
||||||
// Override the File type
|
// Override the File type
|
||||||
json.type = 'tilemapJSON';
|
json.type = 'tilemapJSON';
|
||||||
|
|
||||||
|
json.cache = loader.cacheManager.tilemap;
|
||||||
|
|
||||||
json.tilemapFormat = format;
|
json.tilemapFormat = format;
|
||||||
|
|
||||||
|
json.addToCache = function ()
|
||||||
|
{
|
||||||
|
this.cache.add(this.key, { format: this.tilemapFormat, data: this.data });
|
||||||
|
|
||||||
|
this.loader.emit('filecomplete', this.key, this);
|
||||||
|
};
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,12 +67,12 @@ FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings));
|
this.addFile(TilemapJSONFile(this, key[i], url, TILEMAP_FORMATS.TILED_JSON, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.TILED_JSON, xhrSettings));
|
this.addFile(TilemapJSONFile(this, key, url, TILEMAP_FORMATS.TILED_JSON, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
@ -94,12 +103,12 @@ FileTypesManager.register('tilemapWeltmeister', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(TilemapJSONFile(key[i], url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
|
this.addFile(TilemapJSONFile(this, key[i], url, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(TilemapJSONFile(key, url, this.path, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
|
this.addFile(TilemapJSONFile(this, key, url, TILEMAP_FORMATS.WELTMEISTER, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -23,10 +23,10 @@ var TextFile = require('./TextFile.js');
|
||||||
*
|
*
|
||||||
* @return {object} An object containing two File objects to be added to the loader.
|
* @return {object} An object containing two File objects to be added to the loader.
|
||||||
*/
|
*/
|
||||||
var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettings, atlasXhrSettings)
|
var UnityAtlasFile = function (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
||||||
{
|
{
|
||||||
var image = new ImageFile(key, textureURL, path, textureXhrSettings);
|
var image = new ImageFile(loader, key, textureURL, textureXhrSettings);
|
||||||
var data = new TextFile(key, atlasURL, path, atlasXhrSettings);
|
var data = new TextFile(loader, key, atlasURL, atlasXhrSettings);
|
||||||
|
|
||||||
// Link them together
|
// Link them together
|
||||||
image.linkFile = data;
|
image.linkFile = data;
|
||||||
|
@ -61,7 +61,7 @@ var UnityAtlasFile = function (key, textureURL, atlasURL, path, textureXhrSettin
|
||||||
FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
|
||||||
{
|
{
|
||||||
// Returns an object with two properties: 'texture' and 'data'
|
// Returns an object with two properties: 'texture' and 'data'
|
||||||
var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
|
var files = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings);
|
||||||
|
|
||||||
this.addFile(files.texture);
|
this.addFile(files.texture);
|
||||||
this.addFile(files.data);
|
this.addFile(files.data);
|
||||||
|
|
|
@ -32,21 +32,22 @@ var XMLFile = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function XMLFile (key, url, path, xhrSettings)
|
function XMLFile (loader, key, url, xhrSettings)
|
||||||
{
|
{
|
||||||
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', '');
|
||||||
|
|
||||||
var fileConfig = {
|
var fileConfig = {
|
||||||
type: 'xml',
|
type: 'xml',
|
||||||
|
cache: loader.cacheManager.xml,
|
||||||
extension: GetFastValue(key, 'extension', 'xml'),
|
extension: GetFastValue(key, 'extension', 'xml'),
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
key: fileKey,
|
key: fileKey,
|
||||||
url: GetFastValue(key, 'file', url),
|
url: GetFastValue(key, 'file', url),
|
||||||
path: path,
|
path: loader.path,
|
||||||
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
xhrSettings: GetFastValue(key, 'xhr', xhrSettings)
|
||||||
};
|
};
|
||||||
|
|
||||||
File.call(this, fileConfig);
|
File.call(this, loader, fileConfig);
|
||||||
},
|
},
|
||||||
|
|
||||||
onProcess: function (callback)
|
onProcess: function (callback)
|
||||||
|
@ -91,12 +92,12 @@ FileTypesManager.register('xml', function (key, url, xhrSettings)
|
||||||
for (var i = 0; i < key.length; i++)
|
for (var i = 0; i < key.length; i++)
|
||||||
{
|
{
|
||||||
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
// If it's an array it has to be an array of Objects, so we get everything out of the 'key' object
|
||||||
this.addFile(new XMLFile(key[i], url, this.path, xhrSettings));
|
this.addFile(new XMLFile(this, key[i], url, xhrSettings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.addFile(new XMLFile(key, url, this.path, xhrSettings));
|
this.addFile(new XMLFile(this, key, url, xhrSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For method chaining
|
// For method chaining
|
||||||
|
|
|
@ -319,6 +319,11 @@ var SceneManager = new Class({
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!this.isBooted)
|
||||||
|
{
|
||||||
|
this._data[key] = { data: data };
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue