Skip to content

Commit e98c6b3

Browse files
committed
Merge branch 'master' into rendering-cleanup
2 parents f388391 + 864fa63 commit e98c6b3

44 files changed

Lines changed: 1086 additions & 671 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/boot/Config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ var Config = new Class({
182182
this.physics = GetValue(config, 'physics', {});
183183
this.defaultPhysicsSystem = GetValue(this.physics, 'default', false);
184184

185+
// Loader Defaults
186+
this.loaderBaseURL = GetValue(config, 'loader.baseURL', '');
187+
this.loaderPath = GetValue(config, 'loader.path', '');
188+
this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true);
189+
this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4);
190+
this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined);
191+
this.loaderResponseType = GetValue(config, 'loader.responseType', '');
192+
this.loaderAsync = GetValue(config, 'loader.async', true);
193+
this.loaderUser = GetValue(config, 'loader.user', '');
194+
this.loaderPassword = GetValue(config, 'loader.password', '');
195+
this.loaderTimeout = GetValue(config, 'loader.timeout', 0);
196+
185197
// Scene Plugins
186198
this.defaultPlugins = GetValue(config, 'plugins', DefaultScenePlugins);
187199

src/boot/DebugHeader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var DebugHeader = function (game)
2020

2121
var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
2222

23-
var audioConfig = game.config.audio;
23+
var audioConfig = config.audio;
2424
var deviceAudio = game.device.Audio;
2525

2626
var audioType;
@@ -105,7 +105,7 @@ var DebugHeader = function (game)
105105
}
106106

107107
// Keep this during dev build only
108-
console.log(CHECKSUM.build);
108+
// console.log(CHECKSUM.build);
109109
};
110110

111111
module.exports = DebugHeader;

src/geom/point/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Point.Floor = require('./Floor');
1414
Point.GetCentroid = require('./GetCentroid');
1515
Point.GetMagnitude = require('./GetMagnitude');
1616
Point.GetMagnitudeSq = require('./GetMagnitudeSq');
17+
Point.GetRectangleFromPoints = require('./GetRectangleFromPoints');
1718
Point.Interpolate = require('./Interpolate');
1819
Point.Invert = require('./Invert');
1920
Point.Multiply = require('./Multiply');

src/loader/File.js

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var File = new Class({
4848
this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {}));
4949
}
5050

51+
// The LoaderPlugin instance that is loading this file
52+
this.loader = null;
53+
5154
this.xhrLoader = null;
5255

5356
this.state = CONST.FILE_PENDING;
@@ -70,8 +73,6 @@ var File = new Class({
7073
// Multipart file? (i.e. an atlas and its json together)
7174
this.linkFile = undefined;
7275
this.linkType = '';
73-
74-
this.callback = null;
7576
},
7677

7778
resetXHR: function ()
@@ -81,20 +82,54 @@ var File = new Class({
8182
this.xhrLoader.onprogress = undefined;
8283
},
8384

84-
// Called when the Image loads
85-
// ProgressEvent
85+
// Called by the Loader, starts the actual file downloading.
86+
// During the load the methods onLoad, onProgress, etc are called based on the XHR events.
87+
load: function (loader)
88+
{
89+
this.loader = loader;
90+
91+
if (this.state === CONST.FILE_POPULATED)
92+
{
93+
this.onComplete();
94+
95+
loader.nextFile(this);
96+
}
97+
else
98+
{
99+
this.src = GetURL(this, loader.baseURL);
100+
101+
if (this.src.indexOf('data:') === 0)
102+
{
103+
console.log('Local data URI');
104+
}
105+
else
106+
{
107+
this.xhrLoader = XHRLoader(this, loader.xhr);
108+
}
109+
}
110+
},
111+
112+
// Called when the file loads, is sent a DOM ProgressEvent
86113
onLoad: function (event)
87114
{
88115
this.resetXHR();
89116

90-
this.callback(this, true);
117+
if (event.target && event.target.status !== 200)
118+
{
119+
this.loader.nextFile(this, false);
120+
}
121+
else
122+
{
123+
this.loader.nextFile(this, true);
124+
}
91125
},
92126

127+
// Called when the file errors, is sent a DOM ProgressEvent
93128
onError: function (event)
94129
{
95130
this.resetXHR();
96131

97-
this.callback(this, false);
132+
this.loader.nextFile(this, false);
98133
},
99134

100135
onProgress: function (event)
@@ -105,11 +140,14 @@ var File = new Class({
105140
this.bytesTotal = event.total;
106141

107142
this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1);
108-
}
109143

110-
// console.log(this.percentComplete + '% (' + this.bytesLoaded + ' bytes)');
144+
// console.log(this.percentComplete + '% (' + this.bytesLoaded + ' bytes)');
145+
this.loader.emit('fileprogress', this, this.percentComplete);
146+
}
111147
},
112148

149+
// Usually overriden by the FileTypes and is called by Loader.finishedLoading.
150+
// The callback is Loader.processUpdate
113151
onProcess: function (callback)
114152
{
115153
this.state = CONST.FILE_PROCESSING;
@@ -139,25 +177,6 @@ var File = new Class({
139177
{
140178
this.state = CONST.FILE_COMPLETE;
141179
}
142-
},
143-
144-
// Called by the Loader, starts the actual file downloading
145-
load: function (callback, baseURL, globalXHR)
146-
{
147-
if (baseURL === undefined) { baseURL = ''; }
148-
149-
this.callback = callback;
150-
151-
this.src = GetURL(this, baseURL);
152-
153-
if (this.src.indexOf('data:') === 0)
154-
{
155-
console.log('Local data URI');
156-
}
157-
else
158-
{
159-
this.xhrLoader = XHRLoader(this, globalXHR);
160-
}
161180
}
162181

163182
});

src/loader/FileTypesManager.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var types = {};
2+
3+
var FileTypesManager = {
4+
5+
install: function (loader)
6+
{
7+
for (var key in types)
8+
{
9+
loader[key] = types[key];
10+
}
11+
},
12+
13+
register: function (key, factoryFunction)
14+
{
15+
types[key] = factoryFunction;
16+
17+
// console.log('FileTypesManager.register', key);
18+
},
19+
20+
destroy: function ()
21+
{
22+
types = {};
23+
}
24+
25+
};
26+
27+
module.exports = FileTypesManager;

0 commit comments

Comments
 (0)