2017-01-10 17:04:30 +01:00
|
|
|
/**
|
|
|
|
* This component makes the parentEntity (ex. car) follow the path provided by the spline
|
|
|
|
* @param id String
|
|
|
|
* @param name String
|
2017-02-21 18:55:18 +01:00
|
|
|
* @param domElement
|
|
|
|
* @param domContainer
|
2017-01-11 16:09:06 +01:00
|
|
|
* @param editor GameLib.D3.API.Editor
|
2017-01-10 17:04:30 +01:00
|
|
|
* @param camera
|
2017-01-12 17:40:17 +01:00
|
|
|
* @param widthOffset
|
|
|
|
* @param heightOffset
|
|
|
|
* @param containerWidthOffset
|
|
|
|
* @param containerHeightOffset
|
2017-01-17 13:24:45 +01:00
|
|
|
* @param selectDelayMs
|
2017-01-10 17:04:30 +01:00
|
|
|
* @param parentEntity
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Input.Editor = function (
|
|
|
|
id,
|
|
|
|
name,
|
2017-02-21 18:55:18 +01:00
|
|
|
domElement,
|
|
|
|
domContainer,
|
2017-01-11 16:09:06 +01:00
|
|
|
editor,
|
2017-01-10 17:04:30 +01:00
|
|
|
camera,
|
2017-01-12 17:40:17 +01:00
|
|
|
widthOffset,
|
|
|
|
heightOffset,
|
|
|
|
containerWidthOffset,
|
|
|
|
containerHeightOffset,
|
2017-01-17 13:24:45 +01:00
|
|
|
selectDelayMs,
|
2017-01-10 17:04:30 +01:00
|
|
|
parentEntity
|
|
|
|
) {
|
|
|
|
GameLib.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.COMPONENT_INPUT_EDITOR,
|
|
|
|
{
|
2017-01-12 17:40:17 +01:00
|
|
|
'editor' : GameLib.D3.Editor,
|
|
|
|
'camera' : GameLib.D3.Camera
|
2017-01-10 17:04:30 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
parentEntity
|
|
|
|
);
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
2017-01-13 16:19:51 +01:00
|
|
|
name = 'Input Editor (' + this.id + ')';
|
2017-01-10 17:04:30 +01:00
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2017-02-21 18:55:18 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(domElement)) {
|
|
|
|
domElement = null;
|
2017-01-10 17:04:30 +01:00
|
|
|
}
|
2017-02-21 18:55:18 +01:00
|
|
|
this.domElement = domElement;
|
2017-01-10 17:04:30 +01:00
|
|
|
|
2017-02-21 18:55:18 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(domContainer)) {
|
|
|
|
domContainer = null;
|
2017-01-12 17:40:17 +01:00
|
|
|
}
|
2017-02-21 18:55:18 +01:00
|
|
|
this.domContainer = domContainer;
|
2017-01-12 17:40:17 +01:00
|
|
|
|
2017-01-13 16:19:51 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(editor)) {
|
|
|
|
editor = null;
|
|
|
|
}
|
|
|
|
this.editor = editor;
|
|
|
|
|
2017-01-10 17:04:30 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
|
|
|
camera = null;
|
|
|
|
}
|
|
|
|
this.camera = camera;
|
2017-01-12 17:40:17 +01:00
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(widthOffset)) {
|
|
|
|
widthOffset = 400;
|
|
|
|
}
|
|
|
|
this.widthOffset = widthOffset;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(heightOffset)) {
|
|
|
|
heightOffset = 0;
|
|
|
|
}
|
|
|
|
this.heightOffset = heightOffset;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(containerWidthOffset)) {
|
|
|
|
containerWidthOffset = 0;
|
|
|
|
}
|
|
|
|
this.containerWidthOffset = containerWidthOffset;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(containerHeightOffset)) {
|
|
|
|
containerHeightOffset = 80;
|
|
|
|
}
|
|
|
|
this.containerHeightOffset = containerHeightOffset;
|
2017-01-17 13:24:45 +01:00
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(selectDelayMs)) {
|
|
|
|
selectDelayMs = 300;
|
|
|
|
}
|
|
|
|
this.selectDelayMs = selectDelayMs;
|
2017-01-10 17:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.Input.Editor.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.Input.Editor.prototype.constructor = GameLib.D3.API.Input.Editor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.Input.Editor
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.API.Input.Editor}
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Input.Editor.FromObjectComponent = function(objectComponent) {
|
|
|
|
return new GameLib.D3.API.Input.Editor(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
2017-02-21 18:55:18 +01:00
|
|
|
objectComponent.domElement,
|
|
|
|
objectComponent.domContainer,
|
2017-01-12 17:40:17 +01:00
|
|
|
objectComponent.editor,
|
2017-01-10 17:04:30 +01:00
|
|
|
objectComponent.camera,
|
2017-01-12 17:40:17 +01:00
|
|
|
objectComponent.widthOffset,
|
|
|
|
objectComponent.heightOffset,
|
|
|
|
objectComponent.containerWidthOffset,
|
|
|
|
objectComponent.containerHeightOffset,
|
2017-01-17 13:24:45 +01:00
|
|
|
objectComponent.selectDelayMs,
|
2017-01-10 17:04:30 +01:00
|
|
|
objectComponent.parentEntity
|
|
|
|
);
|
|
|
|
};
|