Tidying up before merging with BaseLoader.

This commit is contained in:
Richard Davey 2018-01-19 13:52:03 +00:00
parent f5462146e2
commit e18858010c

View file

@ -1,8 +1,6 @@
var BaseLoader = require('./BaseLoader');
var Class = require('../utils/Class');
var CONST = require('./const');
var FileTypesManager = require('./FileTypesManager');
var NumberArray = require('../utils/array/NumberArray');
var PluginManager = require('../plugins/PluginManager');
var Loader = new Class({
@ -36,238 +34,6 @@ var Loader = new Class({
eventEmitter.on('destroy', this.destroy, this);
},
// key can be either a string, an object or an array of objects
/*
image: function (key, url, xhrSettings)
{
return ImageFile.create(this, key, url, xhrSettings);
},
animation: function (key, url, xhrSettings)
{
return AnimationJSONFile.create(this, key, url, xhrSettings);
},
json: function (key, url, xhrSettings)
{
return JSONFile.create(this, key, url, xhrSettings);
},
script: function (key, url, xhrSettings)
{
return ScriptFile.create(this, key, url, xhrSettings);
},
plugin: function (key, url, xhrSettings)
{
return PluginFile.create(this, key, url, xhrSettings);
},
xml: function (key, url, xhrSettings)
{
return XMLFile.create(this, key, url, xhrSettings);
},
/*
binary: function (key, url, xhrSettings)
{
return BinaryFile.create(this, key, url, xhrSettings);
},
text: function (key, url, xhrSettings)
{
return TextFile.create(this, key, url, xhrSettings);
},
glsl: function (key, url, xhrSettings)
{
return GLSLFile.create(this, key, url, xhrSettings);
},
html: function (key, url, width, height, xhrSettings)
{
return HTMLFile.create(this, key, url, width, height, xhrSettings);
},
svg: function (key, url, xhrSettings)
{
return SVGFile.create(this, key, url, xhrSettings);
},
obj: function (key, url, xhrSettings)
{
return WavefrontFile.create(this, key, url, xhrSettings);
},
// config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing
spritesheet: function (key, url, config, xhrSettings)
{
return SpriteSheet.create(this, key, url, config, xhrSettings);
},
*/
// config can include: instances
/*
audio: function (key, urls, config, xhrSettings)
{
var audioFile = AudioFile.create(this, key, urls, config, xhrSettings);
if(audioFile)
{
this.addFile(audioFile);
}
return this;
},
*/
/*
tilemapCSV: function (key, url, xhrSettings)
{
return TilemapCSVFile.create(this, key, url, TILEMAP_FORMATS.CSV, xhrSettings);
},
tilemapTiledJSON: function (key, url, xhrSettings)
{
return TilemapJSONFile.create(this, key, url, TILEMAP_FORMATS.TILED_JSON, xhrSettings);
},
tilemapWeltmeister: function (key, url, xhrSettings)
{
return TilemapJSONFile.create(this, key, url, TILEMAP_FORMATS.WELTMEISTER, xhrSettings);
},
*/
// ---------------------------------------------------
// Multi-File Loaders
// ---------------------------------------------------
audioSprite: function (key, urls, json, config, audioXhrSettings, jsonXhrSettings)
{
var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings);
if(audioFile)
{
var jsonFile;
if (typeof json === 'string')
{
jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings);
this.addFile(jsonFile);
}
else
{
jsonFile = {
type: 'json',
key: key,
data: json,
state: CONST.FILE_WAITING_LINKFILE
};
}
// Link them together
audioFile.linkFile = jsonFile;
jsonFile.linkFile = audioFile;
// Set the type
audioFile.linkType = 'audioSprite';
jsonFile.linkType = 'audioSprite';
this.addFile(audioFile);
}
return this;
},
/*
unityAtlas: function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'
var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
this.addFile(files.texture);
this.addFile(files.data);
return this;
},
atlas: function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'
var files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings);
this.addFile(files.texture);
this.addFile(files.data);
return this;
},
bitmapFont: function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'
var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings);
this.addFile(files.texture);
this.addFile(files.data);
return this;
},
*/
multiatlas: function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings)
{
if (typeof textureURLs === 'number')
{
var total = textureURLs;
var suffix = (atlasURLs === undefined) ? '' : atlasURLs;
textureURLs = NumberArray(0, total, key + suffix, '.png');
atlasURLs = NumberArray(0, total, key + suffix, '.json');
}
else
{
if (!Array.isArray(textureURLs))
{
textureURLs = [ textureURLs ];
}
if (!Array.isArray(atlasURLs))
{
atlasURLs = [ atlasURLs ];
}
}
var file;
var i = 0;
var multiKey;
this._multilist[key] = [];
for (i = 0; i < textureURLs.length; i++)
{
multiKey = '_MA_IMG_' + key + '_' + i.toString();
file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings);
this.addFile(file);
this._multilist[key].push(multiKey);
}
for (i = 0; i < atlasURLs.length; i++)
{
multiKey = '_MA_JSON_' + key + '_' + i.toString();
file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings);
this.addFile(file);
this._multilist[key].push(multiKey);
}
},
loadArray: function (files)
{
if (Array.isArray(files))