From 9ad44012ce8461a1da233b0c9bb62aaa84f5b371 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Mon, 9 Oct 2017 13:00:50 +0200 Subject: [PATCH] load and outstanding progress --- src/game-lib-a-1-event.js | 2 ++ src/game-lib-system-storage.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/game-lib-a-1-event.js b/src/game-lib-a-1-event.js index 60a2964..97ffa9c 100644 --- a/src/game-lib-a-1-event.js +++ b/src/game-lib-a-1-event.js @@ -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; } diff --git a/src/game-lib-system-storage.js b/src/game-lib-system-storage.js index 92678d2..369828d 100644 --- a/src/game-lib-system-storage.js +++ b/src/game-lib-system-storage.js @@ -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) {