load and outstanding progress

beta.r3js.org
-=yb4f310 2017-10-09 13:00:50 +02:00
parent f419657ac6
commit 9ad44012ce
2 changed files with 10 additions and 0 deletions

View File

@ -105,6 +105,7 @@ GameLib.Event.FONT_INSTANCE_CREATED = 0x57;
GameLib.Event.REGISTER_DEPENDENCIES = 0x58;
GameLib.Event.GAME_LOADED = 0x59;
GameLib.Event.GAME_RESTART = 0x5a;
GameLib.Event.LOAD_PROGRESS = 0x5b;
/**
* Returns string name of event ID
@ -205,6 +206,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x58 : return 'register_dependencies';
case 0x59 : return 'game_loaded';
case 0x5a : return 'game_restart';
case 0x5b : return 'load_progress';
break;
}

View File

@ -579,6 +579,14 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
var toProcess = GameLib.Utils.Difference(loaded.map(function(component){return component.id}), loading);
GameLib.Event.Emit(
GameLib.Event.LOAD_PROGRESS,
{
loaded : loaded.length,
toProcess : toProcess.length
}
);
if (toProcess.length === 0) {
if (clientCallback) {