gui system fixes
parent
6e2dbf188d
commit
3ca6ec73fd
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
||||||
var __DATE__ = "Sun Dec 10 2017 19:38:30 GMT+0100 (CET)";
|
var __DATE__ = "Mon Dec 11 2017 11:04:04 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25412,8 +25412,8 @@ GameLib.SocketsRuntime.prototype.createInstance = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.SocketsRuntime.prototype.connect = function(serverIp, port, protocol) {
|
GameLib.SocketsRuntime.prototype.connect = function(server) {
|
||||||
var connection = new WebSocket('ws://' + serverIp + ':' + port , protocol);
|
var connection = new WebSocket(server.protocol + '://' + server.ip + ':' + server.port , server.protocols);
|
||||||
this.connections.push(connection);
|
this.connections.push(connection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27334,16 +27334,83 @@ GameLib.System.GUI = function(
|
||||||
|
|
||||||
this.sourceChangedSubscription = null;
|
this.sourceChangedSubscription = null;
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
|
this.removeComponentSubscription = null;
|
||||||
|
|
||||||
|
this.windowResizeSubscription = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
||||||
GameLib.System.GUI.prototype.constructor = GameLib.System.GUI;
|
GameLib.System.GUI.prototype.constructor = GameLib.System.GUI;
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.windowResize = function(data) {
|
||||||
|
var gui = this.guis[0];
|
||||||
|
gui.instance.domElement.getElementsByTagName('ul')[0].style.maxHeight = data.height - 93 + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.initialize = function(gui) {
|
||||||
|
|
||||||
|
var length = this.guis.length;
|
||||||
|
|
||||||
|
gui.instance.domElement.style.position = 'absolute';
|
||||||
|
gui.instance.domElement.style.top = length * 34 + 'px';
|
||||||
|
gui.instance.domElement.style.right = '0px';
|
||||||
|
|
||||||
|
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.instanceCreated = function(data) {
|
||||||
|
if (data.component instanceof GameLib.GUI) {
|
||||||
|
GameLib.Utils.PushUnique(this.guis, data.component);
|
||||||
|
this.initialize(data.component);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.removeComponent = function(data) {
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.GUI) {
|
||||||
|
var index = this.guis.indexOf(data.component);
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
console.warn('gui system out of sync');
|
||||||
|
} else {
|
||||||
|
var gui = this.guis[index];
|
||||||
|
|
||||||
|
gui.domElement.instance.parentElement.removeChild(gui.instance.domElement);
|
||||||
|
|
||||||
|
this.guis.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.start = function() {
|
GameLib.System.GUI.prototype.start = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.start.call(this);
|
GameLib.System.prototype.start.call(this);
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.INSTANCE_CREATED,
|
||||||
|
this.instanceCreated.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.removeComponentSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.REMOVE_COMPONENT,
|
||||||
|
this.removeComponent.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
this.windowResize.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.GUI);
|
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.GUI);
|
||||||
|
this.guis.map(
|
||||||
|
function(gui){
|
||||||
|
this.initialize(gui);
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add some GUI behaviour
|
* Add some GUI behaviour
|
||||||
|
@ -27450,10 +27517,6 @@ GameLib.System.GUI.prototype.start = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.guis.map(function(gui){
|
|
||||||
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.buildGUISubscription = this.subscribe(
|
this.buildGUISubscription = this.subscribe(
|
||||||
GameLib.Event.BUILD_GUI,
|
GameLib.Event.BUILD_GUI,
|
||||||
this.buildGUI
|
this.buildGUI
|
||||||
|
@ -29258,6 +29321,12 @@ GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
this.destinationChangedSubscription.remove();
|
this.destinationChangedSubscription.remove();
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription.remove();
|
||||||
|
|
||||||
|
this.removeComponentSubscription.remove();
|
||||||
|
|
||||||
|
this.windowResizeSubscription.remove();
|
||||||
|
|
||||||
this.guis = [];
|
this.guis = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32094,6 +32163,8 @@ GameLib.System.Socket = function(
|
||||||
|
|
||||||
this.receiveComponents = [];
|
this.receiveComponents = [];
|
||||||
|
|
||||||
|
this.servers = [];
|
||||||
|
|
||||||
this.instanceCreatedSubscription = null;
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
this.removeComponentSubscription = null;
|
this.removeComponentSubscription = null;
|
||||||
|
@ -32113,6 +32184,7 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
|
|
||||||
this.castComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_CAST);
|
this.castComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_CAST);
|
||||||
this.receiveComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_RECEIVE);
|
this.receiveComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_RECEIVE);
|
||||||
|
this.servers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SERVER);
|
||||||
|
|
||||||
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||||
GameLib.Event.INSTANCE_CREATED,
|
GameLib.Event.INSTANCE_CREATED,
|
||||||
|
@ -32129,18 +32201,6 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
this.beforeRender.bind(this)
|
this.beforeRender.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.castComponents.map(
|
|
||||||
function(castComponent) {
|
|
||||||
this.connect(castComponent);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.receiveComponents.map(
|
|
||||||
function(receiveComponent) {
|
|
||||||
this.connect(receiveComponent);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32167,18 +32227,16 @@ GameLib.System.Socket.prototype.disconnect = function(socketComponent) {
|
||||||
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
||||||
|
|
||||||
if (data.component instanceof GameLib.Socket.Cast) {
|
if (data.component instanceof GameLib.Socket.Cast) {
|
||||||
|
|
||||||
this.connect(data.component);
|
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.component instanceof GameLib.Socket.Receive) {
|
if (data.component instanceof GameLib.Socket.Receive) {
|
||||||
|
|
||||||
this.connect(data.component);
|
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.receiveComponents, data.component);
|
GameLib.Utils.PushUnique(this.receiveComponents, data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.Server) {
|
||||||
|
GameLib.Utils.PushUnique(this.servers, data.component);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32211,6 +32269,18 @@ GameLib.System.Socket.prototype.removeComponent = function(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.Server) {
|
||||||
|
|
||||||
|
index = this.servers.indexOf(data.component);
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
this.servers.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
console.log('Socket System out of Server Component sync')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32234,34 +32304,19 @@ GameLib.System.Socket.prototype.stop = function() {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
this.beforeRenderSubscription.remove();
|
this.beforeRenderSubscription.remove();
|
||||||
|
|
||||||
this.castComponents = this.castComponents.reduce(
|
this.servers = this.servers.reduce(
|
||||||
function(result, castComponent) {
|
function(result, serverComponent) {
|
||||||
|
|
||||||
if (!this.disconnect(castComponent)) {
|
if (!serverComponent.disconnect()) {
|
||||||
result.push(castComponent);
|
result.push(serverComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.castComponents.length !== 0) {
|
if (this.servers.length !== 0) {
|
||||||
console.warn(this.castComponents.length + ' cast connections still open after socket system stopped');
|
console.warn(this.servers.length + ' connections still open after socket system stopped');
|
||||||
}
|
|
||||||
|
|
||||||
this.receiveComponents = this.receiveComponents.reduce(
|
|
||||||
function(result, receiveComponent) {
|
|
||||||
|
|
||||||
if (!this.disconnect(receiveComponent)) {
|
|
||||||
result.push(receiveComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.receiveComponents.length !== 0) {
|
|
||||||
console.warn(this.receiveComponents.length + ' receive connections still open after socket system stopped');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -32775,13 +32830,6 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
|
|
||||||
__system.loadComponent(apiUrl, dependencies, includeDependencies, clientCallback, clientErrorCallback);
|
__system.loadComponent(apiUrl, dependencies, includeDependencies, clientCallback, clientErrorCallback);
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.LOAD_PROGRESS,
|
|
||||||
{
|
|
||||||
loaded : __system.loaded.length,
|
|
||||||
toProcess : dependencies.length
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameLib.Event.Emit(
|
// GameLib.Event.Emit(
|
||||||
|
@ -32791,10 +32839,31 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.LOAD_PROGRESS,
|
||||||
|
{
|
||||||
|
loading : __system.loading.length,
|
||||||
|
loaded : __system.loaded.length
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (__system.onComponentLoaded) {
|
if (__system.onComponentLoaded) {
|
||||||
__system.onComponentLoaded(runtimeComponent);
|
__system.onComponentLoaded(runtimeComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (__system.loading.length === __system.loaded.length) {
|
||||||
|
|
||||||
|
console.log('loaded ' + __system.loaded.length + ' components');
|
||||||
|
|
||||||
|
if (clientCallback) {
|
||||||
|
clientCallback({
|
||||||
|
components : __system.loaded
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}(this);
|
}(this);
|
||||||
|
|
|
@ -44,8 +44,8 @@ GameLib.SocketsRuntime.prototype.createInstance = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.SocketsRuntime.prototype.connect = function(serverIp, port, protocol) {
|
GameLib.SocketsRuntime.prototype.connect = function(server) {
|
||||||
var connection = new WebSocket('ws://' + serverIp + ':' + port , protocol);
|
var connection = new WebSocket(server.protocol + '://' + server.ip + ':' + server.port , server.protocols);
|
||||||
this.connections.push(connection);
|
this.connections.push(connection);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,16 +38,83 @@ GameLib.System.GUI = function(
|
||||||
|
|
||||||
this.sourceChangedSubscription = null;
|
this.sourceChangedSubscription = null;
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
|
this.removeComponentSubscription = null;
|
||||||
|
|
||||||
|
this.windowResizeSubscription = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
||||||
GameLib.System.GUI.prototype.constructor = GameLib.System.GUI;
|
GameLib.System.GUI.prototype.constructor = GameLib.System.GUI;
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.windowResize = function(data) {
|
||||||
|
var gui = this.guis[0];
|
||||||
|
gui.instance.domElement.getElementsByTagName('ul')[0].style.maxHeight = data.height - 93 + 'px';
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.initialize = function(gui) {
|
||||||
|
|
||||||
|
var length = this.guis.length;
|
||||||
|
|
||||||
|
gui.instance.domElement.style.position = 'absolute';
|
||||||
|
gui.instance.domElement.style.top = length * 34 + 'px';
|
||||||
|
gui.instance.domElement.style.right = '0px';
|
||||||
|
|
||||||
|
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.instanceCreated = function(data) {
|
||||||
|
if (data.component instanceof GameLib.GUI) {
|
||||||
|
GameLib.Utils.PushUnique(this.guis, data.component);
|
||||||
|
this.initialize(data.component);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.removeComponent = function(data) {
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.GUI) {
|
||||||
|
var index = this.guis.indexOf(data.component);
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
console.warn('gui system out of sync');
|
||||||
|
} else {
|
||||||
|
var gui = this.guis[index];
|
||||||
|
|
||||||
|
gui.domElement.instance.parentElement.removeChild(gui.instance.domElement);
|
||||||
|
|
||||||
|
this.guis.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.start = function() {
|
GameLib.System.GUI.prototype.start = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.start.call(this);
|
GameLib.System.prototype.start.call(this);
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.INSTANCE_CREATED,
|
||||||
|
this.instanceCreated.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.removeComponentSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.REMOVE_COMPONENT,
|
||||||
|
this.removeComponent.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.windowResizeSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.WINDOW_RESIZE,
|
||||||
|
this.windowResize.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.GUI);
|
this.guis = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.GUI);
|
||||||
|
this.guis.map(
|
||||||
|
function(gui){
|
||||||
|
this.initialize(gui);
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add some GUI behaviour
|
* Add some GUI behaviour
|
||||||
|
@ -154,10 +221,6 @@ GameLib.System.GUI.prototype.start = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.guis.map(function(gui){
|
|
||||||
gui.domElement.instance.parentElement.appendChild(gui.instance.domElement);
|
|
||||||
});
|
|
||||||
|
|
||||||
this.buildGUISubscription = this.subscribe(
|
this.buildGUISubscription = this.subscribe(
|
||||||
GameLib.Event.BUILD_GUI,
|
GameLib.Event.BUILD_GUI,
|
||||||
this.buildGUI
|
this.buildGUI
|
||||||
|
@ -1962,6 +2025,12 @@ GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
this.destinationChangedSubscription.remove();
|
this.destinationChangedSubscription.remove();
|
||||||
|
|
||||||
|
this.instanceCreatedSubscription.remove();
|
||||||
|
|
||||||
|
this.removeComponentSubscription.remove();
|
||||||
|
|
||||||
|
this.windowResizeSubscription.remove();
|
||||||
|
|
||||||
this.guis = [];
|
this.guis = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ GameLib.System.Socket = function(
|
||||||
|
|
||||||
this.receiveComponents = [];
|
this.receiveComponents = [];
|
||||||
|
|
||||||
|
this.servers = [];
|
||||||
|
|
||||||
this.instanceCreatedSubscription = null;
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
this.removeComponentSubscription = null;
|
this.removeComponentSubscription = null;
|
||||||
|
@ -36,6 +38,7 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
|
|
||||||
this.castComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_CAST);
|
this.castComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_CAST);
|
||||||
this.receiveComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_RECEIVE);
|
this.receiveComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SOCKET_RECEIVE);
|
||||||
|
this.servers = GameLib.EntityManager.Instance.queryComponents(GameLib.Component.SERVER);
|
||||||
|
|
||||||
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||||
GameLib.Event.INSTANCE_CREATED,
|
GameLib.Event.INSTANCE_CREATED,
|
||||||
|
@ -52,18 +55,6 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
this.beforeRender.bind(this)
|
this.beforeRender.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.castComponents.map(
|
|
||||||
function(castComponent) {
|
|
||||||
this.connect(castComponent);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.receiveComponents.map(
|
|
||||||
function(receiveComponent) {
|
|
||||||
this.connect(receiveComponent);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,18 +81,16 @@ GameLib.System.Socket.prototype.disconnect = function(socketComponent) {
|
||||||
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
||||||
|
|
||||||
if (data.component instanceof GameLib.Socket.Cast) {
|
if (data.component instanceof GameLib.Socket.Cast) {
|
||||||
|
|
||||||
this.connect(data.component);
|
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.component instanceof GameLib.Socket.Receive) {
|
if (data.component instanceof GameLib.Socket.Receive) {
|
||||||
|
|
||||||
this.connect(data.component);
|
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.receiveComponents, data.component);
|
GameLib.Utils.PushUnique(this.receiveComponents, data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.Server) {
|
||||||
|
GameLib.Utils.PushUnique(this.servers, data.component);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +123,18 @@ GameLib.System.Socket.prototype.removeComponent = function(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.Server) {
|
||||||
|
|
||||||
|
index = this.servers.indexOf(data.component);
|
||||||
|
|
||||||
|
if (index !== -1) {
|
||||||
|
this.servers.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
console.log('Socket System out of Server Component sync')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,34 +158,19 @@ GameLib.System.Socket.prototype.stop = function() {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
this.beforeRenderSubscription.remove();
|
this.beforeRenderSubscription.remove();
|
||||||
|
|
||||||
this.castComponents = this.castComponents.reduce(
|
this.servers = this.servers.reduce(
|
||||||
function(result, castComponent) {
|
function(result, serverComponent) {
|
||||||
|
|
||||||
if (!this.disconnect(castComponent)) {
|
if (!serverComponent.disconnect()) {
|
||||||
result.push(castComponent);
|
result.push(serverComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.castComponents.length !== 0) {
|
if (this.servers.length !== 0) {
|
||||||
console.warn(this.castComponents.length + ' cast connections still open after socket system stopped');
|
console.warn(this.servers.length + ' connections still open after socket system stopped');
|
||||||
}
|
|
||||||
|
|
||||||
this.receiveComponents = this.receiveComponents.reduce(
|
|
||||||
function(result, receiveComponent) {
|
|
||||||
|
|
||||||
if (!this.disconnect(receiveComponent)) {
|
|
||||||
result.push(receiveComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
}.bind(this),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.receiveComponents.length !== 0) {
|
|
||||||
console.warn(this.receiveComponents.length + ' receive connections still open after socket system stopped');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -507,13 +507,6 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
|
|
||||||
__system.loadComponent(apiUrl, dependencies, includeDependencies, clientCallback, clientErrorCallback);
|
__system.loadComponent(apiUrl, dependencies, includeDependencies, clientCallback, clientErrorCallback);
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.LOAD_PROGRESS,
|
|
||||||
{
|
|
||||||
loaded : __system.loaded.length,
|
|
||||||
toProcess : dependencies.length
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameLib.Event.Emit(
|
// GameLib.Event.Emit(
|
||||||
|
@ -523,10 +516,31 @@ GameLib.System.Storage.prototype.loadComponent = function(apiUrl, toProcess, inc
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.LOAD_PROGRESS,
|
||||||
|
{
|
||||||
|
loading : __system.loading.length,
|
||||||
|
loaded : __system.loaded.length
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (__system.onComponentLoaded) {
|
if (__system.onComponentLoaded) {
|
||||||
__system.onComponentLoaded(runtimeComponent);
|
__system.onComponentLoaded(runtimeComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (__system.loading.length === __system.loaded.length) {
|
||||||
|
|
||||||
|
console.log('loaded ' + __system.loaded.length + ' components');
|
||||||
|
|
||||||
|
if (clientCallback) {
|
||||||
|
clientCallback({
|
||||||
|
components : __system.loaded
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}(this);
|
}(this);
|
||||||
|
|
Loading…
Reference in New Issue