2017-01-13 16:19:51 +01:00
|
|
|
/**
|
2017-06-16 15:49:53 +02:00
|
|
|
* Custom Code Component
|
|
|
|
* @param id
|
|
|
|
* @param name
|
2017-01-13 16:19:51 +01:00
|
|
|
* @param parentEntity
|
2017-06-16 15:49:53 +02:00
|
|
|
* @param code
|
|
|
|
* @param domElementId
|
2017-01-13 16:19:51 +01:00
|
|
|
* @param args
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.CustomCode = function (
|
|
|
|
id,
|
|
|
|
name,
|
2017-06-16 15:49:53 +02:00
|
|
|
parentEntity,
|
2017-01-13 16:19:51 +01:00
|
|
|
code,
|
|
|
|
domElementId,
|
|
|
|
args
|
|
|
|
) {
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'CustomCode (' + this.id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2017-06-16 15:49:53 +02:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
|
|
|
parentEntity = null;
|
|
|
|
}
|
|
|
|
this.parentEntity = parentEntity;
|
|
|
|
|
2017-01-13 16:19:51 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(code)) {
|
|
|
|
code = '';
|
|
|
|
}
|
|
|
|
this.code = code;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(domElementId)) {
|
|
|
|
domElementId = "CustomCode_" + this.id;
|
|
|
|
}
|
|
|
|
this.domElementId = domElementId;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(args)) {
|
|
|
|
args = [];
|
|
|
|
}
|
|
|
|
this.args = args;
|
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.CustomCode.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.CustomCode.prototype.constructor = GameLib.D3.API.CustomCode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.CustomCode
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.API.CustomCode}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.API.CustomCode.FromObject = function(objectComponent) {
|
2017-01-13 16:19:51 +01:00
|
|
|
return new GameLib.D3.API.CustomCode(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
2017-06-16 15:49:53 +02:00
|
|
|
objectComponent.parentEntity,
|
2017-01-13 16:19:51 +01:00
|
|
|
objectComponent.code,
|
|
|
|
objectComponent.domElementId,
|
|
|
|
objectComponent.args
|
|
|
|
);
|
|
|
|
};
|