cast meets gui
parent
050a7854b2
commit
ee53a76cf0
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__ = "Tue Dec 05 2017 13:01:04 GMT+0100 (CET)";
|
var __DATE__ = "Tue Dec 05 2017 17:00:21 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +158,7 @@ GameLib.Event.TOUCH_CANCEL = 0x4c;
|
||||||
GameLib.Event.GET_REMOTE_API_URL = 0x4d;
|
GameLib.Event.GET_REMOTE_API_URL = 0x4d;
|
||||||
GameLib.Event.COMPONENT_TYPES_UPDATE = 0x4e;
|
GameLib.Event.COMPONENT_TYPES_UPDATE = 0x4e;
|
||||||
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
|
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
|
||||||
//GameLib.Event.GET_CODER_IMPLEMENTATION = 0x50;
|
GameLib.Event.CAST_SOURCE_CHANGED = 0x50;
|
||||||
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
|
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
|
||||||
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
|
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
|
||||||
GameLib.Event.GET_SCENE = 0x53;
|
GameLib.Event.GET_SCENE = 0x53;
|
||||||
|
@ -278,7 +278,7 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0x4d : return 'get_remote_api_url';
|
case 0x4d : return 'get_remote_api_url';
|
||||||
case 0x4e : return 'component_types_update';
|
case 0x4e : return 'component_types_update';
|
||||||
case 0x4f : return 'delayed_instance_encountered';
|
case 0x4f : return 'delayed_instance_encountered';
|
||||||
case 0x50 : return 'unused';//'get_coder_implementation';
|
case 0x50 : return 'cast_source_changed';
|
||||||
case 0x51 : return 'animation_mesh_added';
|
case 0x51 : return 'animation_mesh_added';
|
||||||
case 0x52 : return 'animation_mesh_removed';
|
case 0x52 : return 'animation_mesh_removed';
|
||||||
case 0x53 : return 'get_scene';
|
case 0x53 : return 'get_scene';
|
||||||
|
@ -1699,7 +1699,7 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
};
|
};
|
||||||
case 0x17 : return {
|
case 0x17 : return {
|
||||||
name : 'GameLib.Mouse',
|
name : 'GameLib.Mouse',
|
||||||
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
runtime : GameLib.Component.DEFAULT_RUNTIME,
|
||||||
constructor : GameLib.Mouse
|
constructor : GameLib.Mouse
|
||||||
};
|
};
|
||||||
case 0x18 : return {
|
case 0x18 : return {
|
||||||
|
@ -2530,6 +2530,8 @@ GameLib.API.Canvas.FromObject = function(objectCanvas) {
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param castType
|
* @param castType
|
||||||
|
* @param source
|
||||||
|
* @param sourceProperties
|
||||||
* @param roomId
|
* @param roomId
|
||||||
* @param peer
|
* @param peer
|
||||||
* @param serverIp
|
* @param serverIp
|
||||||
|
@ -2541,6 +2543,8 @@ GameLib.API.Cast = function(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
castType,
|
castType,
|
||||||
|
source,
|
||||||
|
sourceProperties,
|
||||||
roomId,
|
roomId,
|
||||||
peer,
|
peer,
|
||||||
serverIp,
|
serverIp,
|
||||||
|
@ -2563,6 +2567,16 @@ GameLib.API.Cast = function(
|
||||||
}
|
}
|
||||||
this.castType = castType;
|
this.castType = castType;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(source)) {
|
||||||
|
source = null;
|
||||||
|
}
|
||||||
|
this.source = source;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(sourceProperties)) {
|
||||||
|
sourceProperties = null;
|
||||||
|
}
|
||||||
|
this.sourceProperties = sourceProperties;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
||||||
roomId = 'default';
|
roomId = 'default';
|
||||||
}
|
}
|
||||||
|
@ -2593,6 +2607,12 @@ GameLib.API.Cast = function(
|
||||||
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
|
||||||
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
|
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
|
||||||
|
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ROOM = 0x1;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_PEER = 0x2;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ALL = 0x3;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an API Cast from an Object Cast
|
* Creates an API Cast from an Object Cast
|
||||||
* @param objectCast
|
* @param objectCast
|
||||||
|
@ -2604,6 +2624,8 @@ GameLib.API.Cast.FromObject = function(objectCast) {
|
||||||
objectCast.id,
|
objectCast.id,
|
||||||
objectCast.name,
|
objectCast.name,
|
||||||
objectCast.castType,
|
objectCast.castType,
|
||||||
|
objectCast.source,
|
||||||
|
objectCast.sourceProperties,
|
||||||
objectCast.roomId,
|
objectCast.roomId,
|
||||||
objectCast.peer,
|
objectCast.peer,
|
||||||
objectCast.serverIp,
|
objectCast.serverIp,
|
||||||
|
@ -4631,6 +4653,8 @@ GameLib.Cast = function(
|
||||||
apiCast.id,
|
apiCast.id,
|
||||||
apiCast.name,
|
apiCast.name,
|
||||||
apiCast.castType,
|
apiCast.castType,
|
||||||
|
apiCast.source,
|
||||||
|
apiCast.sourceProperties,
|
||||||
apiCast.roomId,
|
apiCast.roomId,
|
||||||
apiCast.peer,
|
apiCast.peer,
|
||||||
apiCast.serverIp,
|
apiCast.serverIp,
|
||||||
|
@ -4638,9 +4662,12 @@ GameLib.Cast = function(
|
||||||
apiCast.parentEntity
|
apiCast.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.connected = false;
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
{
|
{
|
||||||
|
source : GameLib.Component,
|
||||||
peer : GameLib.Component
|
peer : GameLib.Component
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -4650,11 +4677,6 @@ GameLib.Cast = function(
|
||||||
GameLib.Cast.prototype = Object.create(GameLib.API.Cast.prototype);
|
GameLib.Cast.prototype = Object.create(GameLib.API.Cast.prototype);
|
||||||
GameLib.Cast.prototype.constructor = GameLib.Cast;
|
GameLib.Cast.prototype.constructor = GameLib.Cast;
|
||||||
|
|
||||||
GameLib.Cast.CAST_TYPE_ROOM = 0x1;
|
|
||||||
GameLib.Cast.CAST_TYPE_PEER = 0x2;
|
|
||||||
GameLib.Cast.CAST_TYPE_ALL = 0x3;
|
|
||||||
GameLib.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
|
||||||
|
|
||||||
GameLib.Cast.prototype.createInstance = function() {
|
GameLib.Cast.prototype.createInstance = function() {
|
||||||
|
|
||||||
this.instance = true;
|
this.instance = true;
|
||||||
|
@ -4666,11 +4688,34 @@ GameLib.Cast.prototype.createInstance = function() {
|
||||||
* Updates the instance with the current state
|
* Updates the instance with the current state
|
||||||
*/
|
*/
|
||||||
GameLib.Cast.prototype.updateInstance = function(property) {
|
GameLib.Cast.prototype.updateInstance = function(property) {
|
||||||
|
if (property === 'source') {
|
||||||
|
if (this.source !== null) {
|
||||||
|
this.sourceProperties = Object.keys(this.source).reduce(
|
||||||
|
function(result, propertyId) {
|
||||||
|
|
||||||
};
|
if (typeof this.source[propertyId] !== 'function') {
|
||||||
|
result[propertyId] = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.Cast.prototype.remove = function() {
|
}.bind(this),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.sourceProperties = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.CAST_SOURCE_CHANGED,
|
||||||
|
{
|
||||||
|
component:this
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'sourceProperties') {
|
||||||
|
console.log(this.sourceProperties);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4683,6 +4728,8 @@ GameLib.Cast.prototype.toApiObject = function() {
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.castType,
|
this.castType,
|
||||||
|
GameLib.Utils.IdOrNull(this.source),
|
||||||
|
this.sourceProperties,
|
||||||
this.roomId,
|
this.roomId,
|
||||||
GameLib.Utils.IdOrNull(this.peer),
|
GameLib.Utils.IdOrNull(this.peer),
|
||||||
this.serverIp,
|
this.serverIp,
|
||||||
|
@ -24300,7 +24347,7 @@ GameLib.Mouse.prototype.toApiObject = function() {
|
||||||
* @returns {GameLib.Mouse}
|
* @returns {GameLib.Mouse}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.Mouse.prototype.FromObject = function(objectMouse) {
|
GameLib.Mouse.FromObject = function(objectMouse) {
|
||||||
return new GameLib.Mouse(
|
return new GameLib.Mouse(
|
||||||
GameLib.API.Mouse.FromObject(objectMouse)
|
GameLib.API.Mouse.FromObject(objectMouse)
|
||||||
);
|
);
|
||||||
|
@ -26485,6 +26532,8 @@ GameLib.System.GUI = function(
|
||||||
|
|
||||||
this.meshSelectionObjects = {};
|
this.meshSelectionObjects = {};
|
||||||
|
|
||||||
|
this.sourceChangedSubscription = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
||||||
|
@ -26633,7 +26682,12 @@ GameLib.System.GUI.prototype.start = function() {
|
||||||
this.componentRemovedSubscription = this.subscribe(
|
this.componentRemovedSubscription = this.subscribe(
|
||||||
GameLib.Event.REMOVE_COMPONENT,
|
GameLib.Event.REMOVE_COMPONENT,
|
||||||
this.removeComponent
|
this.removeComponent
|
||||||
)
|
);
|
||||||
|
|
||||||
|
this.sourceChangedSubscription = this.subscribe(
|
||||||
|
GameLib.Event.CAST_SOURCE_CHANGED,
|
||||||
|
this.castSourceChanged
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.onChange = function(property, subProperty, affected) {
|
GameLib.System.GUI.prototype.onChange = function(property, subProperty, affected) {
|
||||||
|
@ -27053,6 +27107,38 @@ GameLib.System.GUI.prototype.buildColorControl = function(folder, componentTempl
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.buildObjectControl = function(folder, componentTemplate, property) {
|
||||||
|
|
||||||
|
var object = componentTemplate.template[property];
|
||||||
|
|
||||||
|
if (object === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'sourceProperties') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Object.keys(object).map(
|
||||||
|
function(propertyId) {
|
||||||
|
folder.add(
|
||||||
|
object,
|
||||||
|
propertyId
|
||||||
|
).name(property + '.' + propertyId).listen().onChange(
|
||||||
|
function(value) {
|
||||||
|
componentTemplate.affected.map(
|
||||||
|
function(component){
|
||||||
|
component.sourceProperties[propertyId] = value;
|
||||||
|
component.updateInstance('sourceProperties');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, property) {
|
GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, property) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27060,14 +27146,19 @@ GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemp
|
||||||
*/
|
*/
|
||||||
var constructors = null;
|
var constructors = null;
|
||||||
|
|
||||||
if (componentTemplate.template[property]) {
|
|
||||||
constructors = componentTemplate.template[property].constructor;
|
|
||||||
} else {
|
|
||||||
if (componentTemplate.template.linkedObjects[property]) {
|
if (componentTemplate.template.linkedObjects[property]) {
|
||||||
constructors = componentTemplate.template.linkedObjects[property];
|
constructors = componentTemplate.template.linkedObjects[property];
|
||||||
|
} else {
|
||||||
|
if (componentTemplate.template[property]) {
|
||||||
|
constructors = componentTemplate.template[property].constructor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!constructors) {
|
||||||
|
console.log('cannot determine constructor');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var object = componentTemplate.template;
|
var object = componentTemplate.template;
|
||||||
|
|
||||||
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
||||||
|
@ -27145,7 +27236,19 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
grain = object.grain;
|
grain = object.grain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'systemType') {
|
if (property === 'componentType') {
|
||||||
|
|
||||||
|
var readOnly = {
|
||||||
|
componentType : GameLib.Component.GetComponentInfo(object[property]).name
|
||||||
|
};
|
||||||
|
|
||||||
|
controllers.push(
|
||||||
|
folder.add(
|
||||||
|
readOnly,
|
||||||
|
'componentType'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (property === 'systemType') {
|
||||||
controllers.push(
|
controllers.push(
|
||||||
folder.add(
|
folder.add(
|
||||||
object,
|
object,
|
||||||
|
@ -27162,6 +27265,19 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
} else if (property === 'castType') {
|
||||||
|
controllers.push(
|
||||||
|
folder.add(
|
||||||
|
object,
|
||||||
|
property,
|
||||||
|
{
|
||||||
|
'room': GameLib.API.Cast.CAST_TYPE_ROOM,
|
||||||
|
'peer': GameLib.API.Cast.CAST_TYPE_PEER ,
|
||||||
|
'all': GameLib.API.Cast.CAST_TYPE_ALL,
|
||||||
|
'all but peer': GameLib.API.Cast.CAST_TYPE_ALL_BUT_PEER
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
} else if (property === 'opacityType') {
|
} else if (property === 'opacityType') {
|
||||||
controllers.push(
|
controllers.push(
|
||||||
folder.add(
|
folder.add(
|
||||||
|
@ -28194,8 +28310,7 @@ GameLib.System.GUI.prototype.buildGUI = function(data) {
|
||||||
) {
|
) {
|
||||||
this.buildSelectControl(folder, componentTemplate, templateProperty)
|
this.buildSelectControl(folder, componentTemplate, templateProperty)
|
||||||
} else {
|
} else {
|
||||||
//TODO: maybe start including some other types of objects
|
this.buildObjectControl(folder, componentTemplate, templateProperty);
|
||||||
//console.log('ignored : ' + templateProperty);
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -28274,6 +28389,10 @@ GameLib.System.GUI.prototype.newEntity = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.castSourceChanged = function(data) {
|
||||||
|
this.buildGUI(null);
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.stop = function() {
|
GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.stop.call(this);
|
GameLib.System.prototype.stop.call(this);
|
||||||
|
@ -28298,6 +28417,8 @@ GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
this.componentRemovedSubscription.remove();
|
this.componentRemovedSubscription.remove();
|
||||||
|
|
||||||
|
this.sourceChangedSubscription.remove();
|
||||||
|
|
||||||
this.guis = [];
|
this.guis = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31130,6 +31251,8 @@ GameLib.System.Socket = function(
|
||||||
|
|
||||||
this.totalTime = 0;
|
this.totalTime = 0;
|
||||||
|
|
||||||
|
this.castComponents = [];
|
||||||
|
|
||||||
this.instanceCreatedSubscription = null;
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
this.removeComponentSubscription = null;
|
this.removeComponentSubscription = null;
|
||||||
|
@ -31164,15 +31287,41 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
this.beforeRender.bind(this)
|
this.beforeRender.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.castComponents.map(
|
||||||
|
function(castComponent) {
|
||||||
|
this.connect(castComponent);
|
||||||
|
}.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the socket server
|
||||||
|
* @param castComponent
|
||||||
|
*/
|
||||||
|
GameLib.System.Socket.prototype.connect = function(castComponent) {
|
||||||
|
console.log(castComponent.name + ' is connecting to the server ' + castComponent.serverIp);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from the socket server
|
||||||
|
* @param castComponent
|
||||||
|
*/
|
||||||
|
GameLib.System.Socket.prototype.disconnect = function(castComponent) {
|
||||||
|
console.log(castComponent.name + ' is disconnecting from server ' + castComponent.serverIp);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From now on we want to track everything about a component, only from the systems that are active
|
* From now on we want to track everything about a component, only from the systems that are active
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
||||||
if (data.component instanceof GameLib.Cast) {
|
if (data.component instanceof GameLib.Cast) {
|
||||||
this.castComponents.push(data.component);
|
|
||||||
|
this.connect(data.component);
|
||||||
|
|
||||||
|
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31216,6 +31365,21 @@ GameLib.System.Socket.prototype.stop = function() {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
this.beforeRenderSubscription.remove();
|
this.beforeRenderSubscription.remove();
|
||||||
|
|
||||||
|
this.castComponents = this.castComponents.reduce(
|
||||||
|
function(result, castComponent) {
|
||||||
|
|
||||||
|
if (!this.disconnect(castComponent)) {
|
||||||
|
result.push(castComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.castComponents.length !== '0') {
|
||||||
|
console.warn(this.castComponents.length + ' connections still open after socket system stopped');
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,7 +94,7 @@ GameLib.Event.TOUCH_CANCEL = 0x4c;
|
||||||
GameLib.Event.GET_REMOTE_API_URL = 0x4d;
|
GameLib.Event.GET_REMOTE_API_URL = 0x4d;
|
||||||
GameLib.Event.COMPONENT_TYPES_UPDATE = 0x4e;
|
GameLib.Event.COMPONENT_TYPES_UPDATE = 0x4e;
|
||||||
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
|
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
|
||||||
//GameLib.Event.GET_CODER_IMPLEMENTATION = 0x50;
|
GameLib.Event.CAST_SOURCE_CHANGED = 0x50;
|
||||||
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
|
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
|
||||||
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
|
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
|
||||||
GameLib.Event.GET_SCENE = 0x53;
|
GameLib.Event.GET_SCENE = 0x53;
|
||||||
|
@ -214,7 +214,7 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0x4d : return 'get_remote_api_url';
|
case 0x4d : return 'get_remote_api_url';
|
||||||
case 0x4e : return 'component_types_update';
|
case 0x4e : return 'component_types_update';
|
||||||
case 0x4f : return 'delayed_instance_encountered';
|
case 0x4f : return 'delayed_instance_encountered';
|
||||||
case 0x50 : return 'unused';//'get_coder_implementation';
|
case 0x50 : return 'cast_source_changed';
|
||||||
case 0x51 : return 'animation_mesh_added';
|
case 0x51 : return 'animation_mesh_added';
|
||||||
case 0x52 : return 'animation_mesh_removed';
|
case 0x52 : return 'animation_mesh_removed';
|
||||||
case 0x53 : return 'get_scene';
|
case 0x53 : return 'get_scene';
|
||||||
|
|
|
@ -398,7 +398,7 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
};
|
};
|
||||||
case 0x17 : return {
|
case 0x17 : return {
|
||||||
name : 'GameLib.Mouse',
|
name : 'GameLib.Mouse',
|
||||||
runtime : GameLib.Component.GRAPHICS_RUNTIME,
|
runtime : GameLib.Component.DEFAULT_RUNTIME,
|
||||||
constructor : GameLib.Mouse
|
constructor : GameLib.Mouse
|
||||||
};
|
};
|
||||||
case 0x18 : return {
|
case 0x18 : return {
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* @param id
|
* @param id
|
||||||
* @param name
|
* @param name
|
||||||
* @param castType
|
* @param castType
|
||||||
|
* @param source
|
||||||
|
* @param sourceProperties
|
||||||
* @param roomId
|
* @param roomId
|
||||||
* @param peer
|
* @param peer
|
||||||
* @param serverIp
|
* @param serverIp
|
||||||
|
@ -14,6 +16,8 @@ GameLib.API.Cast = function(
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
castType,
|
castType,
|
||||||
|
source,
|
||||||
|
sourceProperties,
|
||||||
roomId,
|
roomId,
|
||||||
peer,
|
peer,
|
||||||
serverIp,
|
serverIp,
|
||||||
|
@ -36,6 +40,16 @@ GameLib.API.Cast = function(
|
||||||
}
|
}
|
||||||
this.castType = castType;
|
this.castType = castType;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(source)) {
|
||||||
|
source = null;
|
||||||
|
}
|
||||||
|
this.source = source;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(sourceProperties)) {
|
||||||
|
sourceProperties = null;
|
||||||
|
}
|
||||||
|
this.sourceProperties = sourceProperties;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
if (GameLib.Utils.UndefinedOrNull(roomId)) {
|
||||||
roomId = 'default';
|
roomId = 'default';
|
||||||
}
|
}
|
||||||
|
@ -66,6 +80,12 @@ GameLib.API.Cast = function(
|
||||||
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.API.Cast.prototype = Object.create(GameLib.Component.prototype);
|
||||||
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
|
GameLib.API.Cast.prototype.constructor = GameLib.API.Cast;
|
||||||
|
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ROOM = 0x1;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_PEER = 0x2;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ALL = 0x3;
|
||||||
|
GameLib.API.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an API Cast from an Object Cast
|
* Creates an API Cast from an Object Cast
|
||||||
* @param objectCast
|
* @param objectCast
|
||||||
|
@ -77,6 +97,8 @@ GameLib.API.Cast.FromObject = function(objectCast) {
|
||||||
objectCast.id,
|
objectCast.id,
|
||||||
objectCast.name,
|
objectCast.name,
|
||||||
objectCast.castType,
|
objectCast.castType,
|
||||||
|
objectCast.source,
|
||||||
|
objectCast.sourceProperties,
|
||||||
objectCast.roomId,
|
objectCast.roomId,
|
||||||
objectCast.peer,
|
objectCast.peer,
|
||||||
objectCast.serverIp,
|
objectCast.serverIp,
|
||||||
|
|
|
@ -25,6 +25,8 @@ GameLib.Cast = function(
|
||||||
apiCast.id,
|
apiCast.id,
|
||||||
apiCast.name,
|
apiCast.name,
|
||||||
apiCast.castType,
|
apiCast.castType,
|
||||||
|
apiCast.source,
|
||||||
|
apiCast.sourceProperties,
|
||||||
apiCast.roomId,
|
apiCast.roomId,
|
||||||
apiCast.peer,
|
apiCast.peer,
|
||||||
apiCast.serverIp,
|
apiCast.serverIp,
|
||||||
|
@ -32,9 +34,12 @@ GameLib.Cast = function(
|
||||||
apiCast.parentEntity
|
apiCast.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.connected = false;
|
||||||
|
|
||||||
GameLib.Component.call(
|
GameLib.Component.call(
|
||||||
this,
|
this,
|
||||||
{
|
{
|
||||||
|
source : GameLib.Component,
|
||||||
peer : GameLib.Component
|
peer : GameLib.Component
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -44,11 +49,6 @@ GameLib.Cast = function(
|
||||||
GameLib.Cast.prototype = Object.create(GameLib.API.Cast.prototype);
|
GameLib.Cast.prototype = Object.create(GameLib.API.Cast.prototype);
|
||||||
GameLib.Cast.prototype.constructor = GameLib.Cast;
|
GameLib.Cast.prototype.constructor = GameLib.Cast;
|
||||||
|
|
||||||
GameLib.Cast.CAST_TYPE_ROOM = 0x1;
|
|
||||||
GameLib.Cast.CAST_TYPE_PEER = 0x2;
|
|
||||||
GameLib.Cast.CAST_TYPE_ALL = 0x3;
|
|
||||||
GameLib.Cast.CAST_TYPE_ALL_BUT_PEER = 0x4;
|
|
||||||
|
|
||||||
GameLib.Cast.prototype.createInstance = function() {
|
GameLib.Cast.prototype.createInstance = function() {
|
||||||
|
|
||||||
this.instance = true;
|
this.instance = true;
|
||||||
|
@ -60,11 +60,34 @@ GameLib.Cast.prototype.createInstance = function() {
|
||||||
* Updates the instance with the current state
|
* Updates the instance with the current state
|
||||||
*/
|
*/
|
||||||
GameLib.Cast.prototype.updateInstance = function(property) {
|
GameLib.Cast.prototype.updateInstance = function(property) {
|
||||||
|
if (property === 'source') {
|
||||||
|
if (this.source !== null) {
|
||||||
|
this.sourceProperties = Object.keys(this.source).reduce(
|
||||||
|
function(result, propertyId) {
|
||||||
|
|
||||||
};
|
if (typeof this.source[propertyId] !== 'function') {
|
||||||
|
result[propertyId] = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
GameLib.Cast.prototype.remove = function() {
|
}.bind(this),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.sourceProperties = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.CAST_SOURCE_CHANGED,
|
||||||
|
{
|
||||||
|
component:this
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'sourceProperties') {
|
||||||
|
console.log(this.sourceProperties);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,6 +100,8 @@ GameLib.Cast.prototype.toApiObject = function() {
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.castType,
|
this.castType,
|
||||||
|
GameLib.Utils.IdOrNull(this.source),
|
||||||
|
this.sourceProperties,
|
||||||
this.roomId,
|
this.roomId,
|
||||||
GameLib.Utils.IdOrNull(this.peer),
|
GameLib.Utils.IdOrNull(this.peer),
|
||||||
this.serverIp,
|
this.serverIp,
|
||||||
|
|
|
@ -67,7 +67,7 @@ GameLib.Mouse.prototype.toApiObject = function() {
|
||||||
* @returns {GameLib.Mouse}
|
* @returns {GameLib.Mouse}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.Mouse.prototype.FromObject = function(objectMouse) {
|
GameLib.Mouse.FromObject = function(objectMouse) {
|
||||||
return new GameLib.Mouse(
|
return new GameLib.Mouse(
|
||||||
GameLib.API.Mouse.FromObject(objectMouse)
|
GameLib.API.Mouse.FromObject(objectMouse)
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,6 +36,8 @@ GameLib.System.GUI = function(
|
||||||
|
|
||||||
this.meshSelectionObjects = {};
|
this.meshSelectionObjects = {};
|
||||||
|
|
||||||
|
this.sourceChangedSubscription = null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
GameLib.System.GUI.prototype = Object.create(GameLib.System.prototype);
|
||||||
|
@ -184,7 +186,12 @@ GameLib.System.GUI.prototype.start = function() {
|
||||||
this.componentRemovedSubscription = this.subscribe(
|
this.componentRemovedSubscription = this.subscribe(
|
||||||
GameLib.Event.REMOVE_COMPONENT,
|
GameLib.Event.REMOVE_COMPONENT,
|
||||||
this.removeComponent
|
this.removeComponent
|
||||||
)
|
);
|
||||||
|
|
||||||
|
this.sourceChangedSubscription = this.subscribe(
|
||||||
|
GameLib.Event.CAST_SOURCE_CHANGED,
|
||||||
|
this.castSourceChanged
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.onChange = function(property, subProperty, affected) {
|
GameLib.System.GUI.prototype.onChange = function(property, subProperty, affected) {
|
||||||
|
@ -604,6 +611,38 @@ GameLib.System.GUI.prototype.buildColorControl = function(folder, componentTempl
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.buildObjectControl = function(folder, componentTemplate, property) {
|
||||||
|
|
||||||
|
var object = componentTemplate.template[property];
|
||||||
|
|
||||||
|
if (object === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (property === 'sourceProperties') {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Object.keys(object).map(
|
||||||
|
function(propertyId) {
|
||||||
|
folder.add(
|
||||||
|
object,
|
||||||
|
propertyId
|
||||||
|
).name(property + '.' + propertyId).listen().onChange(
|
||||||
|
function(value) {
|
||||||
|
componentTemplate.affected.map(
|
||||||
|
function(component){
|
||||||
|
component.sourceProperties[propertyId] = value;
|
||||||
|
component.updateInstance('sourceProperties');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, property) {
|
GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemplate, property) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -611,14 +650,19 @@ GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemp
|
||||||
*/
|
*/
|
||||||
var constructors = null;
|
var constructors = null;
|
||||||
|
|
||||||
if (componentTemplate.template[property]) {
|
|
||||||
constructors = componentTemplate.template[property].constructor;
|
|
||||||
} else {
|
|
||||||
if (componentTemplate.template.linkedObjects[property]) {
|
if (componentTemplate.template.linkedObjects[property]) {
|
||||||
constructors = componentTemplate.template.linkedObjects[property];
|
constructors = componentTemplate.template.linkedObjects[property];
|
||||||
|
} else {
|
||||||
|
if (componentTemplate.template[property]) {
|
||||||
|
constructors = componentTemplate.template[property].constructor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!constructors) {
|
||||||
|
console.log('cannot determine constructor');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var object = componentTemplate.template;
|
var object = componentTemplate.template;
|
||||||
|
|
||||||
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
||||||
|
@ -696,7 +740,19 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
grain = object.grain;
|
grain = object.grain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property === 'systemType') {
|
if (property === 'componentType') {
|
||||||
|
|
||||||
|
var readOnly = {
|
||||||
|
componentType : GameLib.Component.GetComponentInfo(object[property]).name
|
||||||
|
};
|
||||||
|
|
||||||
|
controllers.push(
|
||||||
|
folder.add(
|
||||||
|
readOnly,
|
||||||
|
'componentType'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (property === 'systemType') {
|
||||||
controllers.push(
|
controllers.push(
|
||||||
folder.add(
|
folder.add(
|
||||||
object,
|
object,
|
||||||
|
@ -713,6 +769,19 @@ GameLib.System.GUI.prototype.buildControl = function(folder, componentTemplate,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
} else if (property === 'castType') {
|
||||||
|
controllers.push(
|
||||||
|
folder.add(
|
||||||
|
object,
|
||||||
|
property,
|
||||||
|
{
|
||||||
|
'room': GameLib.API.Cast.CAST_TYPE_ROOM,
|
||||||
|
'peer': GameLib.API.Cast.CAST_TYPE_PEER ,
|
||||||
|
'all': GameLib.API.Cast.CAST_TYPE_ALL,
|
||||||
|
'all but peer': GameLib.API.Cast.CAST_TYPE_ALL_BUT_PEER
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
} else if (property === 'opacityType') {
|
} else if (property === 'opacityType') {
|
||||||
controllers.push(
|
controllers.push(
|
||||||
folder.add(
|
folder.add(
|
||||||
|
@ -1745,8 +1814,7 @@ GameLib.System.GUI.prototype.buildGUI = function(data) {
|
||||||
) {
|
) {
|
||||||
this.buildSelectControl(folder, componentTemplate, templateProperty)
|
this.buildSelectControl(folder, componentTemplate, templateProperty)
|
||||||
} else {
|
} else {
|
||||||
//TODO: maybe start including some other types of objects
|
this.buildObjectControl(folder, componentTemplate, templateProperty);
|
||||||
//console.log('ignored : ' + templateProperty);
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1825,6 +1893,10 @@ GameLib.System.GUI.prototype.newEntity = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.GUI.prototype.castSourceChanged = function(data) {
|
||||||
|
this.buildGUI(null);
|
||||||
|
};
|
||||||
|
|
||||||
GameLib.System.GUI.prototype.stop = function() {
|
GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.stop.call(this);
|
GameLib.System.prototype.stop.call(this);
|
||||||
|
@ -1849,6 +1921,8 @@ GameLib.System.GUI.prototype.stop = function() {
|
||||||
|
|
||||||
this.componentRemovedSubscription.remove();
|
this.componentRemovedSubscription.remove();
|
||||||
|
|
||||||
|
this.sourceChangedSubscription.remove();
|
||||||
|
|
||||||
this.guis = [];
|
this.guis = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ GameLib.System.Socket = function(
|
||||||
|
|
||||||
this.totalTime = 0;
|
this.totalTime = 0;
|
||||||
|
|
||||||
|
this.castComponents = [];
|
||||||
|
|
||||||
this.instanceCreatedSubscription = null;
|
this.instanceCreatedSubscription = null;
|
||||||
|
|
||||||
this.removeComponentSubscription = null;
|
this.removeComponentSubscription = null;
|
||||||
|
@ -47,15 +49,41 @@ GameLib.System.Socket.prototype.start = function() {
|
||||||
this.beforeRender.bind(this)
|
this.beforeRender.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.castComponents.map(
|
||||||
|
function(castComponent) {
|
||||||
|
this.connect(castComponent);
|
||||||
|
}.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to the socket server
|
||||||
|
* @param castComponent
|
||||||
|
*/
|
||||||
|
GameLib.System.Socket.prototype.connect = function(castComponent) {
|
||||||
|
console.log(castComponent.name + ' is connecting to the server ' + castComponent.serverIp);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disconnect from the socket server
|
||||||
|
* @param castComponent
|
||||||
|
*/
|
||||||
|
GameLib.System.Socket.prototype.disconnect = function(castComponent) {
|
||||||
|
console.log(castComponent.name + ' is disconnecting from server ' + castComponent.serverIp);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From now on we want to track everything about a component, only from the systems that are active
|
* From now on we want to track everything about a component, only from the systems that are active
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
GameLib.System.Socket.prototype.instanceCreated = function(data) {
|
||||||
if (data.component instanceof GameLib.Cast) {
|
if (data.component instanceof GameLib.Cast) {
|
||||||
this.castComponents.push(data.component);
|
|
||||||
|
this.connect(data.component);
|
||||||
|
|
||||||
|
GameLib.Utils.PushUnique(this.castComponents, data.component);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,4 +127,19 @@ GameLib.System.Socket.prototype.stop = function() {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
this.beforeRenderSubscription.remove();
|
this.beforeRenderSubscription.remove();
|
||||||
|
|
||||||
|
this.castComponents = this.castComponents.reduce(
|
||||||
|
function(result, castComponent) {
|
||||||
|
|
||||||
|
if (!this.disconnect(castComponent)) {
|
||||||
|
result.push(castComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.castComponents.length !== '0') {
|
||||||
|
console.warn(this.castComponents.length + ' connections still open after socket system stopped');
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue