Fix missing values and update schedules

This commit is contained in:
barsdeveloper
2022-12-18 10:38:37 +01:00
parent d9216d0d40
commit 42b4cfd47b
16 changed files with 201 additions and 88 deletions

View File

@@ -8,13 +8,18 @@ import INumericInputPinTemplate from "./INumericInputPinTemplate"
export default class IntInputPinTemplate extends INumericInputPinTemplate {
setDefaultValue(values = [], rawValues = values) {
this.element.setDefaultValue(new IntegerEntity(values[0]))
const integer = this.element.getDefaultValue(true)
if (!(integer instanceof IntegerEntity)) {
throw new TypeError("Expected DefaultValue to be a IntegerEntity")
}
integer.value = values[0]
this.element.requestUpdate("DefaultValue", integer)
}
renderInput() {
return html`
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}" .innerText="${this.element.entity.DefaultValue?.toString() ?? "0"}">
<ueb-input .singleLine="${true}" .innerText="${this.element.getDefaultValue()?.toString() ?? "0"}">
</ueb-input>
</div>
`

View File

@@ -17,7 +17,7 @@ export default class RealInputPinTemplate extends INumericPinTemplate {
return html`
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.DefaultValue))}">
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.DefaultValue ?? 0))}">
</ueb-input>
</div>
`

View File

@@ -2,20 +2,34 @@ import { html } from "lit"
import IInputPinTemplate from "./IInputPinTemplate"
import INumericPinTemplate from "./INumericInputPinTemplate"
import RotatorEntity from "../../entity/RotatorEntity"
import Utility from "../../Utility"
/** @typedef {import("../../entity/RotatorEntity").default} Rotator */
/** @extends INumericPinTemplate<Rotator> */
export default class RotatorInputPinTemplate extends INumericPinTemplate {
#getR() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0))
}
#getP() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0))
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
}
setDefaultValue(values = [], rawValues = values) {
if (!(this.element.entity.DefaultValue instanceof RotatorEntity)) {
throw new TypeError("Expected DefaultValue to be a VectorEntity")
const rotator = this.element.getDefaultValue(true)
if (!(rotator instanceof RotatorEntity)) {
throw new TypeError("Expected DefaultValue to be a RotatorEntity")
}
let rotator = this.element.entity.DefaultValue
rotator.R = values[0] // Roll
rotator.P = values[1] // Pitch
rotator.Y = values[2] // Yaw
this.element.requestUpdate("DefaultValue", rotator)
}
renderInput() {
@@ -23,18 +37,15 @@ export default class RotatorInputPinTemplate extends INumericPinTemplate {
<div class="ueb-pin-input-wrapper">
<span class="ueb-pin-input-label">X</span>
<div class="ueb-pin-input">
<span class="ueb-pin-input-content ueb-pin-input-x" role="textbox" contenteditable="true"
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.getDefaultValue().R.toString())}"></span>
<ueb-input .singleLine="${true}" .innerText="${this.#getR()}"></ueb-input>
</div>
<span class="ueb-pin-input-label">Y</span>
<div class="ueb-pin-input">
<span class="ueb-pin-input-content ueb-pin-input-y" role="textbox" contenteditable="true"
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.getDefaultValue().P.toString())}"></span>
<ueb-input .singleLine="${true}" .innerText="${this.#getP()}"></ueb-input>
</div>
<span class="ueb-pin-input-label">Z</span>
<div class="ueb-pin-input">
<span class="ueb-pin-input-content ueb-pin-input-z" role="textbox" contenteditable="true"
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.getDefaultValue().Y.toString())}"></span>
<ueb-input .singleLine="${true}" .innerText="${this.#getY()}"></ueb-input>
</div>
</div>
`

View File

@@ -7,23 +7,35 @@ import VectorEntity from "../../entity/VectorEntity"
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
/**
* @template {VectorEntity} T
* @extends INumericPinTemplate<T>
* @extends INumericPinTemplate<VectorEntity>
*/
export default class VectorInputPinTemplate extends INumericPinTemplate {
#getX() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
}
#getY() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
}
#getZ() {
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0))
}
/**
* @param {Number[]} values
* @param {String[]} rawValues
*/
setDefaultValue(values, rawValues) {
if (!(this.element.entity.DefaultValue instanceof VectorEntity)) {
const vector = this.element.getDefaultValue(true)
if (!(vector instanceof VectorEntity)) {
throw new TypeError("Expected DefaultValue to be a VectorEntity")
}
let vector = this.element.entity.DefaultValue
vector.X = values[0]
vector.Y = values[1]
vector.Z = values[2]
this.element.requestUpdate("DefaultValue", vector)
}
renderInput() {
@@ -31,21 +43,15 @@ export default class VectorInputPinTemplate extends INumericPinTemplate {
<div class="ueb-pin-input-wrapper">
<span class="ueb-pin-input-label">X</span>
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.getDefaultValue().X))}">
</ueb-input>
<ueb-input .singleLine="${true}" .innerText="${this.#getX()}"></ueb-input>
</div>
<span class="ueb-pin-input-label">Y</span>
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.getDefaultValue().Y))}">
</ueb-input>
<ueb-input .singleLine="${true}" .innerText="${this.#getY()}"></ueb-input>
</div>
<span class="ueb-pin-input-label">Z</span>
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.entity.getDefaultValue().Z))}">
</ueb-input>
<ueb-input .singleLine="${true}" .innerText="${this.#getZ()}"></ueb-input>
</div>
</div>
`