mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 23:37:30 +08:00
Merge remote-tracking branch 'origin/master' into mirrored-object-reference-fix
This commit is contained in:
@@ -7,6 +7,7 @@ import NodeTemplate from "./NodeTemplate.js"
|
||||
export default class EventNodeTemplate extends NodeTemplate {
|
||||
|
||||
static nodeStyleClasses = [...super.nodeStyleClasses, "ueb-node-style-event"]
|
||||
#delegatePinElement
|
||||
|
||||
/** @param {PropertyValues} changedProperties */
|
||||
firstUpdated(changedProperties) {
|
||||
@@ -38,21 +39,31 @@ export default class EventNodeTemplate extends NodeTemplate {
|
||||
`
|
||||
}
|
||||
|
||||
getPinElements() {
|
||||
return this.element.getPinElements().filter(v => v.entity.PinType.PinCategory?.toString() !== "delegate")
|
||||
}
|
||||
|
||||
createDelegatePinElement() {
|
||||
const pin = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")).newObject(
|
||||
this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory?.toString() === "delegate"),
|
||||
new MinimalPinTemplate(),
|
||||
this.element
|
||||
)
|
||||
pin.template.isNameRendered = false
|
||||
return pin
|
||||
if (!this.#delegatePinElement) {
|
||||
this.#delegatePinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
|
||||
.newObject(
|
||||
this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory?.toString() === "delegate"),
|
||||
new MinimalPinTemplate(),
|
||||
this.element
|
||||
)
|
||||
this.#delegatePinElement.template.isNameRendered = false
|
||||
}
|
||||
return this.#delegatePinElement
|
||||
}
|
||||
|
||||
createPinElements() {
|
||||
return this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden() && v.PinType.PinCategory?.toString() !== "delegate")
|
||||
.map(pinEntity => /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
|
||||
.newObject(pinEntity, undefined, this.element)
|
||||
)
|
||||
return [
|
||||
this.createDelegatePinElement(),
|
||||
...this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden() && v.PinType.PinCategory?.toString() !== "delegate")
|
||||
.map(pinEntity => /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
|
||||
.newObject(pinEntity, undefined, this.element)
|
||||
)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,17 +54,9 @@ export default class KnotNodeTemplate extends NodeTemplate {
|
||||
}
|
||||
|
||||
setupPins() {
|
||||
this.element.getPinElements().forEach(
|
||||
p => /** @type {HTMLElement} */(this.element.querySelector(".ueb-node-border")).appendChild(p)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NodeElement} node
|
||||
* @returns {NodeListOf<PinElement>}
|
||||
*/
|
||||
getPinElements(node) {
|
||||
return node.querySelectorAll("ueb-pin")
|
||||
for (const p of this.getPinElements()) {
|
||||
/** @type {HTMLElement} */(this.element.querySelector(".ueb-node-border")).appendChild(p)
|
||||
}
|
||||
}
|
||||
|
||||
createPinElements() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { html, nothing } from "lit"
|
||||
import SVGIcon from "../../SVGIcon.js"
|
||||
import Utility from "../../Utility.js"
|
||||
import nodeSubtitle from "../../decoding/nodeSubtitle.js"
|
||||
import ElementFactory from "../../element/ElementFactory.js"
|
||||
import SVGIcon from "../../SVGIcon.js"
|
||||
import ISelectableDraggableTemplate from "../ISelectableDraggableTemplate.js"
|
||||
|
||||
/** @extends {ISelectableDraggableTemplate<NodeElement>} */
|
||||
@@ -9,7 +9,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
|
||||
static nodeStyleClasses = ["ueb-node-style-default"]
|
||||
|
||||
#hasSubtitle = false
|
||||
#subtitle
|
||||
|
||||
/** @type {() => PinEntity<IEntity>} */
|
||||
pinInserter
|
||||
@@ -55,6 +55,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
/** @param {NodeElement} element */
|
||||
initialize(element) {
|
||||
super.initialize(element)
|
||||
this.#subtitle = nodeSubtitle(element.entity)
|
||||
this.element.classList.add(.../** @type {typeof NodeTemplate} */(this.constructor).nodeStyleClasses)
|
||||
this.element.style.setProperty("--ueb-node-color", this.getColor().cssText)
|
||||
this.pinInserter = this.element.entity.additionalPinInserter()
|
||||
@@ -113,10 +114,8 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
${name ? html`
|
||||
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
|
||||
${name}
|
||||
${this.#hasSubtitle && this.getTargetType().length > 0 ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
|
||||
Target is ${Utility.formatStringName(this.getTargetType())}
|
||||
</div>
|
||||
${this.#subtitle ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">${this.#subtitle}</div>
|
||||
`: nothing}
|
||||
</div>
|
||||
` : nothing}
|
||||
@@ -137,7 +136,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
this.element.nodeNameElement = /** @type {HTMLElement} */(this.element.querySelector(".ueb-node-name-text"))
|
||||
let hasInput = false
|
||||
let hasOutput = false
|
||||
for (const p of this.element.getPinElements()) {
|
||||
for (const p of this.getPinElements()) {
|
||||
if (p === this.defaultPin) {
|
||||
continue
|
||||
}
|
||||
@@ -160,26 +159,14 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
getPinElements() {
|
||||
return this.element.getPinElements()
|
||||
}
|
||||
|
||||
createPinElements() {
|
||||
return this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden())
|
||||
.map(pinEntity => {
|
||||
this.#hasSubtitle = this.#hasSubtitle
|
||||
|| pinEntity.PinName.toString() === "self" && pinEntity.pinTitle() === "Target"
|
||||
return this.createPinElement(pinEntity)
|
||||
})
|
||||
}
|
||||
|
||||
getTargetType() {
|
||||
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {NodeElement} node
|
||||
* @returns {NodeListOf<PinElement>}
|
||||
*/
|
||||
getPinElements(node) {
|
||||
return node.querySelectorAll("ueb-pin")
|
||||
.map(pinEntity => this.createPinElement(pinEntity))
|
||||
}
|
||||
|
||||
linksChanged() { }
|
||||
|
||||
@@ -110,12 +110,12 @@ export default class PinTemplate extends ITemplate {
|
||||
return SVGIcon.pcgStackPin
|
||||
}
|
||||
}
|
||||
switch (this.element.entity.PinType?.ContainerType?.serialize()) {
|
||||
switch (this.element.entity.PinType.ContainerType?.toString()) {
|
||||
case "Array": return SVGIcon.arrayPin
|
||||
case "Set": return SVGIcon.setPin
|
||||
case "Map": return SVGIcon.mapPin
|
||||
}
|
||||
if (this.element.entity.PinType?.PinCategory?.toString().toLocaleLowerCase() === "delegate") {
|
||||
if (this.element.entity.PinType.PinCategory?.toString().toLocaleLowerCase() === "delegate") {
|
||||
return SVGIcon.delegate
|
||||
}
|
||||
if (this.element.nodeElement?.template instanceof VariableOperationNodeTemplate) {
|
||||
|
||||
Reference in New Issue
Block a user