|
1 | 1 | var BaseLoader = require('./BaseLoader'); |
2 | 2 | var Class = require('../utils/Class'); |
3 | | -var CONST = require('./const'); |
4 | 3 | var FileTypesManager = require('./FileTypesManager'); |
5 | | -var NumberArray = require('../utils/array/NumberArray'); |
6 | 4 | var PluginManager = require('../plugins/PluginManager'); |
7 | 5 |
|
8 | 6 | var Loader = new Class({ |
@@ -36,238 +34,6 @@ var Loader = new Class({ |
36 | 34 | eventEmitter.on('destroy', this.destroy, this); |
37 | 35 | }, |
38 | 36 |
|
39 | | - // key can be either a string, an object or an array of objects |
40 | | - |
41 | | - /* |
42 | | - image: function (key, url, xhrSettings) |
43 | | - { |
44 | | - return ImageFile.create(this, key, url, xhrSettings); |
45 | | - }, |
46 | | -
|
47 | | - animation: function (key, url, xhrSettings) |
48 | | - { |
49 | | - return AnimationJSONFile.create(this, key, url, xhrSettings); |
50 | | - }, |
51 | | -
|
52 | | - json: function (key, url, xhrSettings) |
53 | | - { |
54 | | - return JSONFile.create(this, key, url, xhrSettings); |
55 | | - }, |
56 | | -
|
57 | | - script: function (key, url, xhrSettings) |
58 | | - { |
59 | | - return ScriptFile.create(this, key, url, xhrSettings); |
60 | | - }, |
61 | | -
|
62 | | - plugin: function (key, url, xhrSettings) |
63 | | - { |
64 | | - return PluginFile.create(this, key, url, xhrSettings); |
65 | | - }, |
66 | | -
|
67 | | - xml: function (key, url, xhrSettings) |
68 | | - { |
69 | | - return XMLFile.create(this, key, url, xhrSettings); |
70 | | - }, |
71 | | -
|
72 | | - /* |
73 | | - binary: function (key, url, xhrSettings) |
74 | | - { |
75 | | - return BinaryFile.create(this, key, url, xhrSettings); |
76 | | - }, |
77 | | -
|
78 | | - text: function (key, url, xhrSettings) |
79 | | - { |
80 | | - return TextFile.create(this, key, url, xhrSettings); |
81 | | - }, |
82 | | -
|
83 | | - glsl: function (key, url, xhrSettings) |
84 | | - { |
85 | | - return GLSLFile.create(this, key, url, xhrSettings); |
86 | | - }, |
87 | | -
|
88 | | - html: function (key, url, width, height, xhrSettings) |
89 | | - { |
90 | | - return HTMLFile.create(this, key, url, width, height, xhrSettings); |
91 | | - }, |
92 | | -
|
93 | | - svg: function (key, url, xhrSettings) |
94 | | - { |
95 | | - return SVGFile.create(this, key, url, xhrSettings); |
96 | | - }, |
97 | | -
|
98 | | - obj: function (key, url, xhrSettings) |
99 | | - { |
100 | | - return WavefrontFile.create(this, key, url, xhrSettings); |
101 | | - }, |
102 | | -
|
103 | | - // config can include: frameWidth, frameHeight, startFrame, endFrame, margin, spacing |
104 | | - spritesheet: function (key, url, config, xhrSettings) |
105 | | - { |
106 | | - return SpriteSheet.create(this, key, url, config, xhrSettings); |
107 | | - }, |
108 | | - */ |
109 | | - |
110 | | - // config can include: instances |
111 | | - /* |
112 | | - audio: function (key, urls, config, xhrSettings) |
113 | | - { |
114 | | - var audioFile = AudioFile.create(this, key, urls, config, xhrSettings); |
115 | | -
|
116 | | - if(audioFile) |
117 | | - { |
118 | | - this.addFile(audioFile); |
119 | | - } |
120 | | -
|
121 | | - return this; |
122 | | - }, |
123 | | - */ |
124 | | - |
125 | | - /* |
126 | | - tilemapCSV: function (key, url, xhrSettings) |
127 | | - { |
128 | | - return TilemapCSVFile.create(this, key, url, TILEMAP_FORMATS.CSV, xhrSettings); |
129 | | - }, |
130 | | -
|
131 | | - tilemapTiledJSON: function (key, url, xhrSettings) |
132 | | - { |
133 | | - return TilemapJSONFile.create(this, key, url, TILEMAP_FORMATS.TILED_JSON, xhrSettings); |
134 | | - }, |
135 | | -
|
136 | | - tilemapWeltmeister: function (key, url, xhrSettings) |
137 | | - { |
138 | | - return TilemapJSONFile.create(this, key, url, TILEMAP_FORMATS.WELTMEISTER, xhrSettings); |
139 | | - }, |
140 | | - */ |
141 | | - |
142 | | - // --------------------------------------------------- |
143 | | - // Multi-File Loaders |
144 | | - // --------------------------------------------------- |
145 | | - |
146 | | - audioSprite: function (key, urls, json, config, audioXhrSettings, jsonXhrSettings) |
147 | | - { |
148 | | - var audioFile = AudioFile.create(this, key, urls, config, audioXhrSettings); |
149 | | - |
150 | | - if(audioFile) |
151 | | - { |
152 | | - var jsonFile; |
153 | | - |
154 | | - if (typeof json === 'string') |
155 | | - { |
156 | | - jsonFile = new JSONFile(key, json, this.path, jsonXhrSettings); |
157 | | - |
158 | | - this.addFile(jsonFile); |
159 | | - } |
160 | | - else |
161 | | - { |
162 | | - jsonFile = { |
163 | | - type: 'json', |
164 | | - key: key, |
165 | | - data: json, |
166 | | - state: CONST.FILE_WAITING_LINKFILE |
167 | | - }; |
168 | | - } |
169 | | - |
170 | | - // Link them together |
171 | | - audioFile.linkFile = jsonFile; |
172 | | - jsonFile.linkFile = audioFile; |
173 | | - |
174 | | - // Set the type |
175 | | - audioFile.linkType = 'audioSprite'; |
176 | | - jsonFile.linkType = 'audioSprite'; |
177 | | - |
178 | | - this.addFile(audioFile); |
179 | | - } |
180 | | - |
181 | | - return this; |
182 | | - }, |
183 | | - |
184 | | - /* |
185 | | - unityAtlas: function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) |
186 | | - { |
187 | | - // Returns an object with two properties: 'texture' and 'data' |
188 | | - var files = new UnityAtlasFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); |
189 | | -
|
190 | | - this.addFile(files.texture); |
191 | | - this.addFile(files.data); |
192 | | -
|
193 | | - return this; |
194 | | - }, |
195 | | -
|
196 | | - atlas: function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) |
197 | | - { |
198 | | - // Returns an object with two properties: 'texture' and 'data' |
199 | | - var files = new AtlasJSONFile(key, textureURL, atlasURL, this.path, textureXhrSettings, atlasXhrSettings); |
200 | | -
|
201 | | - this.addFile(files.texture); |
202 | | - this.addFile(files.data); |
203 | | -
|
204 | | - return this; |
205 | | - }, |
206 | | -
|
207 | | - bitmapFont: function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings) |
208 | | - { |
209 | | - // Returns an object with two properties: 'texture' and 'data' |
210 | | - var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings); |
211 | | -
|
212 | | - this.addFile(files.texture); |
213 | | - this.addFile(files.data); |
214 | | -
|
215 | | - return this; |
216 | | - }, |
217 | | - */ |
218 | | - |
219 | | - multiatlas: function (key, textureURLs, atlasURLs, textureXhrSettings, atlasXhrSettings) |
220 | | - { |
221 | | - if (typeof textureURLs === 'number') |
222 | | - { |
223 | | - var total = textureURLs; |
224 | | - var suffix = (atlasURLs === undefined) ? '' : atlasURLs; |
225 | | - |
226 | | - textureURLs = NumberArray(0, total, key + suffix, '.png'); |
227 | | - atlasURLs = NumberArray(0, total, key + suffix, '.json'); |
228 | | - } |
229 | | - else |
230 | | - { |
231 | | - if (!Array.isArray(textureURLs)) |
232 | | - { |
233 | | - textureURLs = [ textureURLs ]; |
234 | | - } |
235 | | - |
236 | | - if (!Array.isArray(atlasURLs)) |
237 | | - { |
238 | | - atlasURLs = [ atlasURLs ]; |
239 | | - } |
240 | | - } |
241 | | - |
242 | | - var file; |
243 | | - var i = 0; |
244 | | - var multiKey; |
245 | | - |
246 | | - this._multilist[key] = []; |
247 | | - |
248 | | - for (i = 0; i < textureURLs.length; i++) |
249 | | - { |
250 | | - multiKey = '_MA_IMG_' + key + '_' + i.toString(); |
251 | | - |
252 | | - file = new ImageFile(multiKey, textureURLs[i], this.path, textureXhrSettings); |
253 | | - |
254 | | - this.addFile(file); |
255 | | - |
256 | | - this._multilist[key].push(multiKey); |
257 | | - } |
258 | | - |
259 | | - for (i = 0; i < atlasURLs.length; i++) |
260 | | - { |
261 | | - multiKey = '_MA_JSON_' + key + '_' + i.toString(); |
262 | | - |
263 | | - file = new JSONFile(multiKey, atlasURLs[i], this.path, atlasXhrSettings); |
264 | | - |
265 | | - this.addFile(file); |
266 | | - |
267 | | - this._multilist[key].push(multiKey); |
268 | | - } |
269 | | - }, |
270 | | - |
271 | 37 | loadArray: function (files) |
272 | 38 | { |
273 | 39 | if (Array.isArray(files)) |
|
0 commit comments