mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-04 14:27:29 +08:00
Fix pin colors, input refactoring
This commit is contained in:
@@ -80,9 +80,9 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
${name ? html`
|
||||
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
|
||||
${name}
|
||||
${this.hasSubtitle && this.element.entity.FunctionReference.MemberParent ? html`
|
||||
${this.hasSubtitle && this.getTargetType().length > 0 ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
|
||||
Target is ${Utility.formatStringName(this.element.entity.FunctionReference.MemberParent.getName())}
|
||||
Target is ${Utility.formatStringName(this.getTargetType())}
|
||||
</div>
|
||||
`: nothing}
|
||||
</div>
|
||||
@@ -115,13 +115,17 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
return this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden())
|
||||
.map(pinEntity => {
|
||||
this.hasSubtitle = this.hasSubtitle || pinEntity.getDisplayName() === "Target"
|
||||
this.hasSubtitle = this.hasSubtitle || pinEntity.PinName === "self" && pinEntity.getDisplayName() === "Target"
|
||||
let pinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
|
||||
.newObject(pinEntity, undefined, this.element)
|
||||
return pinElement
|
||||
})
|
||||
}
|
||||
|
||||
getTargetType() {
|
||||
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NodeElement} node
|
||||
* @returns {NodeListOf<PinElement>}
|
||||
|
||||
@@ -5,11 +5,6 @@ import Utility from "../../Utility"
|
||||
|
||||
/** @typedef {import("lit").PropertyValues} PropertyValues */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../../element/PinElement").default<T>} PinElement
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @extends PinTemplate<T>
|
||||
@@ -104,7 +99,7 @@ export default class IInputPinTemplate extends PinTemplate {
|
||||
return html`
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${singleLine}" .selectOnFocus="${selectOnFocus}"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.entity.DefaultValue.toString())}">
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(this.element.getDefaultValue()?.toString() ?? "")}">
|
||||
</ueb-input>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -11,13 +11,16 @@ export default class InputTemplate extends ITemplate {
|
||||
getSelection().selectAllChildren(this.element)
|
||||
}
|
||||
}
|
||||
|
||||
#focusoutHandler = () => {
|
||||
this.blueprint.acknowledgeEditText(false)
|
||||
getSelection().removeAllRanges() // Deselect eventually selected text inside the input
|
||||
}
|
||||
|
||||
/** @param {InputEvent} e */
|
||||
#inputSingleLineHandler = e =>
|
||||
/** @type {HTMLElement} */(e.target).querySelectorAll("br").forEach(br => br.remove())
|
||||
|
||||
/** @param {KeyboardEvent} e */
|
||||
#onKeydownBlurOnEnterHandler = e => {
|
||||
if (e.code == "Enter" && !e.shiftKey) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import { html, nothing } from "lit"
|
||||
import ColorPickerWindowTemplate from "../ColorPickerWindowTemplate"
|
||||
import Configuration from "../../Configuration"
|
||||
import ElementFactory from "../../element/ElementFactory"
|
||||
@@ -48,9 +48,9 @@ export default class LinearColorPinTemplate extends PinTemplate {
|
||||
|
||||
renderInput() {
|
||||
return html`
|
||||
<span class="ueb-pin-input" data-linear-color="${this.element.defaultValue.toString()}"
|
||||
<span class="ueb-pin-input" data-linear-color="${this.element.getDefaultValue()?.toString() ?? nothing}"
|
||||
@click="${this.#launchColorPickerWindow}"
|
||||
style="--ueb-linear-color: rgba(${this.element.defaultValue.toString()})">
|
||||
style="--ueb-linear-color: rgba(${this.element.getDefaultValue()?.toString() ?? nothing})">
|
||||
</span>
|
||||
`
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
|
||||
@@ -17,7 +16,7 @@ export default class RealPinTemplate extends INumericPinTemplate {
|
||||
return html`
|
||||
<div class="ueb-pin-input">
|
||||
<ueb-input .singleLine="${true}"
|
||||
.innerText="${IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue() ?? 0))}">
|
||||
.innerText="${Utility.minDecimals(this.element.getDefaultValue() ?? 0)}">
|
||||
</ueb-input>
|
||||
</div>
|
||||
`
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import RotatorEntity from "../../entity/RotatorEntity"
|
||||
import Utility from "../../Utility"
|
||||
@@ -10,15 +9,15 @@ import Utility from "../../Utility"
|
||||
export default class RotatorPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getR() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0)
|
||||
}
|
||||
|
||||
#getP() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
setDefaultValue(values = [], rawValues = values) {
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
import Vector2DEntity from "../../entity/Vector2DEntity"
|
||||
|
||||
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
|
||||
|
||||
/**
|
||||
* @extends INumericPinTemplate<Vector2DEntity>
|
||||
*/
|
||||
export default class VectorInputPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getX() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
import { html } from "lit"
|
||||
import IInputPinTemplate from "./IInputPinTemplate"
|
||||
import INumericPinTemplate from "./INumericPinTemplate"
|
||||
import Utility from "../../Utility"
|
||||
import VectorEntity from "../../entity/VectorEntity"
|
||||
|
||||
/** @typedef {import("../../entity/LinearColorEntity").default} LinearColorEntity */
|
||||
|
||||
/**
|
||||
* @extends INumericPinTemplate<VectorEntity>
|
||||
*/
|
||||
export default class VectorPinTemplate extends INumericPinTemplate {
|
||||
|
||||
#getX() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
|
||||
}
|
||||
|
||||
#getY() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
|
||||
}
|
||||
|
||||
#getZ() {
|
||||
return IInputPinTemplate.stringFromUEToInput(Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0))
|
||||
return Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user