mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
Fix missing values and update schedules
This commit is contained in:
@@ -184,6 +184,10 @@ export default class PinElement extends IElement {
|
||||
return this.entity.LinkedTo ?? []
|
||||
}
|
||||
|
||||
getDefaultValue(maybeCreate = false) {
|
||||
return this.defaultValue = this.entity.getDefaultValue(maybeCreate)
|
||||
}
|
||||
|
||||
/** @param {T} value */
|
||||
setDefaultValue(value) {
|
||||
this.entity.DefaultValue = value
|
||||
|
||||
@@ -59,7 +59,7 @@ export default class PinEntity extends IEntity {
|
||||
new CalculatedType(
|
||||
/** @param {PinEntity} pinEntity */
|
||||
pinEntity => new TypeInitialization(
|
||||
PinEntity.getEntityType(pinEntity.getType(), true) ?? String,
|
||||
pinEntity.getEntityType(true) ?? String,
|
||||
false,
|
||||
undefined,
|
||||
true
|
||||
@@ -76,13 +76,6 @@ export default class PinEntity extends IEntity {
|
||||
bOrphanedPin: false,
|
||||
}
|
||||
|
||||
static getEntityType(typeString, alternative = false) {
|
||||
const [entity, alternativeEntity] = [this.#typeEntityMap[typeString], this.#alternativeTypeEntityMap[typeString]]
|
||||
return alternative && alternativeEntity !== undefined
|
||||
? alternativeEntity
|
||||
: entity
|
||||
}
|
||||
|
||||
constructor(values = {}, suppressWarns = false) {
|
||||
super(values, suppressWarns)
|
||||
/** @type {GuidEntity} */ this.PinId
|
||||
@@ -125,6 +118,15 @@ export default class PinEntity extends IEntity {
|
||||
return this.PinType.PinCategory
|
||||
}
|
||||
|
||||
getEntityType(alternative = false) {
|
||||
const typeString = this.getType()
|
||||
const entity = PinEntity.#typeEntityMap[typeString]
|
||||
const alternativeEntity = PinEntity.#alternativeTypeEntityMap[typeString]
|
||||
return alternative && alternativeEntity !== undefined
|
||||
? alternativeEntity
|
||||
: entity
|
||||
}
|
||||
|
||||
getDisplayName() {
|
||||
let matchResult = null
|
||||
if (
|
||||
@@ -152,7 +154,10 @@ export default class PinEntity extends IEntity {
|
||||
this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat
|
||||
}
|
||||
|
||||
getDefaultValue() {
|
||||
getDefaultValue(maybeCreate = false) {
|
||||
if (this.DefaultValue === undefined && maybeCreate) {
|
||||
this.DefaultValue = new (this.getEntityType(true))()
|
||||
}
|
||||
return this.DefaultValue
|
||||
}
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ export default class TypeInitialization {
|
||||
if (value === undefined) {
|
||||
if (type instanceof Array) {
|
||||
value = []
|
||||
} else if (serialized) {
|
||||
value = ""
|
||||
} else {
|
||||
value = () => TypeInitialization.sanitize(new type())
|
||||
}
|
||||
|
||||
@@ -69,7 +69,9 @@ export default class BlueprintTemplate extends ITemplate {
|
||||
render() {
|
||||
return html`
|
||||
<div class="ueb-viewport-header">
|
||||
<div class="ueb-viewport-zoom">${this.element.zoom == 0 ? "1:1" : this.element.zoom}</div>
|
||||
<div class="ueb-viewport-zoom">
|
||||
Zoom ${this.element.zoom == 0 ? "1:1" : (this.element.zoom > 0 ? "+" : "") + this.element.zoom}
|
||||
</div>
|
||||
</div>
|
||||
<div class="ueb-viewport-overlay"></div>
|
||||
<div class="ueb-viewport-body">
|
||||
@@ -100,6 +102,17 @@ export default class BlueprintTemplate extends ITemplate {
|
||||
this.element.viewportElement.scroll(Configuration.expandGridSize, Configuration.expandGridSize)
|
||||
}
|
||||
|
||||
/** @param {Map} changedProperties */
|
||||
willUpdate(changedProperties) {
|
||||
super.willUpdate(changedProperties)
|
||||
if (this.element.headerElement && changedProperties.has("zoom")) {
|
||||
this.element.headerElement.classList.add("ueb-zoom-changed")
|
||||
this.element.headerElement.addEventListener(
|
||||
"animationend",
|
||||
() => this.element.headerElement.classList.remove("ueb-zoom-changed")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {Map} changedProperties */
|
||||
updated(changedProperties) {
|
||||
|
||||
@@ -79,10 +79,10 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
${name ? html`
|
||||
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
|
||||
${name}
|
||||
${this.#hasTargetInputNode ? html`
|
||||
${this.#hasTargetInputNode && this.element.entity.FunctionReference.MemberParent ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
|
||||
Target is ${Utility.formatStringName(this.element.entity.FunctionReference.MemberParent.getName())}
|
||||
</div>
|
||||
</div>
|
||||
`: nothing}
|
||||
</div>
|
||||
` : nothing}
|
||||
|
||||
@@ -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>
|
||||
`
|
||||
|
||||
@@ -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>
|
||||
`
|
||||
|
||||
@@ -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>
|
||||
`
|
||||
|
||||
@@ -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>
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user