This commit is contained in:
barsdeveloper
2024-10-14 23:19:10 +02:00
parent 8b38173204
commit 404a2aed4f
13 changed files with 127 additions and 86 deletions

View File

@@ -740,11 +740,6 @@ ueb-pin[data-connectable=false] .ueb-pin-icon {
visibility: hidden;
}
.ueb-node-style-event ueb-pin[data-type=delegate] .ueb-pin-icon {
width: 11px;
height: 11px;
}
.ueb-node-inputs .ueb-pin-icon {
margin-right: 6px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

69
dist/ueblueprint.js vendored
View File

@@ -980,7 +980,7 @@ class SVGIcon {
`
static delegate = x`
<svg viewBox="-2 -2 32 32" xmlns="http://www.w3.org/2000/svg">
<svg width="11" height="11" viewBox="-2 -2 32 32" xmlns="http://www.w3.org/2000/svg">
<rect class="ueb-pin-tofill" fill="black" width="28" height="28" rx="4" stroke="currentColor" stroke-width="5" />
</svg>
`
@@ -8719,7 +8719,7 @@ 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
}
@@ -8742,6 +8742,10 @@ class NodeTemplate extends ISelectableDraggableTemplate {
}
}
getPinElements() {
return this.element.getPinElements()
}
createPinElements() {
return this.element.getPinEntities()
.filter(v => !v.isHidden())
@@ -8756,14 +8760,6 @@ class NodeTemplate extends ISelectableDraggableTemplate {
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
}
/**
* @param {NodeElement} node
* @returns {NodeListOf<PinElement>}
*/
getPinElements(node) {
return node.querySelectorAll("ueb-pin")
}
linksChanged() { }
}
@@ -9330,12 +9326,12 @@ 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) {
@@ -9419,6 +9415,7 @@ class MinimalPinTemplate extends PinTemplate {
class EventNodeTemplate extends NodeTemplate {
static nodeStyleClasses = [...super.nodeStyleClasses, "ueb-node-style-event"]
#delegatePinElement
/** @param {PropertyValues} changedProperties */
firstUpdated(changedProperties) {
@@ -9450,22 +9447,32 @@ 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)
)
]
}
}
@@ -9545,17 +9552,9 @@ 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() {

File diff suppressed because one or more lines are too long

View File

@@ -67,7 +67,7 @@ export default class SVGIcon {
`
static delegate = html`
<svg viewBox="-2 -2 32 32" xmlns="http://www.w3.org/2000/svg">
<svg width="11" height="11" viewBox="-2 -2 32 32" xmlns="http://www.w3.org/2000/svg">
<rect class="ueb-pin-tofill" fill="black" width="28" height="28" rx="4" stroke="currentColor" stroke-width="5" />
</svg>
`

View File

@@ -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)
)
]
}
}

View File

@@ -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() {

View File

@@ -137,7 +137,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,6 +160,10 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
}
}
getPinElements() {
return this.element.getPinElements()
}
createPinElements() {
return this.element.getPinEntities()
.filter(v => !v.isHidden())
@@ -174,13 +178,5 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
}
/**
* @param {NodeElement} node
* @returns {NodeListOf<PinElement>}
*/
getPinElements(node) {
return node.querySelectorAll("ueb-pin")
}
linksChanged() { }
}

View File

@@ -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) {

View File

@@ -85,11 +85,6 @@ ueb-pin[data-connectable="false"] .ueb-pin-icon {
visibility: hidden;
}
.ueb-node-style-event ueb-pin[data-type="delegate"] .ueb-pin-icon {
width: 11px;
height: 11px;
}
.ueb-node-inputs .ueb-pin-icon {
margin-right: 6px;
}

53
tests/issues.spec.js Normal file
View File

@@ -0,0 +1,53 @@
import { expect, test } from "./fixtures/test.js"
test.beforeEach(async ({ blueprintPage }) => {
await blueprintPage.removeNodes()
})
test("Issue 27", async ({ blueprintPage }) => {
await blueprintPage.paste(String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CustomEvent Name="K2Node_CustomEvent_0" ExportPath="/Script/BlueprintGraph.K2Node_CustomEvent'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment:EventGraph.K2Node_CustomEvent_0'"
CustomFunctionName="CustomEvent"
NodePosX=1984
NodePosY=1600
ErrorType=3
NodeGuid=8955D806490FF62840F229BD64AC0F8B
CustomProperties Pin (PinId=DA10B1984E92B126FB09CE9D0F767D2E,PinName="OutputDelegate",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent="/Script/Engine.BlueprintGeneratedClass'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment_C'",MemberName="CustomEvent",MemberGuid=8955D806490FF62840F229BD64AC0F8B),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_7 6014BE7344D4B71DCD1CC39ACD1DB9EE,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=A52A36F047563A99081BB3ADC0C688CB,PinName="then",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=E88FACB54D1595FDCF2A0BAABA7969CE,PinName="Actor",Direction="EGPD_Output",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.Actor'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=8183CC924CB230BE8E6DE1963A4145BE,PinName="EndPlayReason",Direction="EGPD_Output",PinType.PinCategory="byte",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Enum'/Script/Engine.EEndPlayReason'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="Destroyed",AutogeneratedDefaultValue="Destroyed",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties UserDefinedPin (PinName="Actor",PinType=(PinCategory="object",PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.Actor'"),DesiredPinDirection=EGPD_Output)
CustomProperties UserDefinedPin (PinName="EndPlayReason",PinType=(PinCategory="byte",PinSubCategoryObject="/Script/CoreUObject.Enum'/Script/Engine.EEndPlayReason'"),DesiredPinDirection=EGPD_Output,PinDefaultValue="Destroyed")
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_AssignDelegate Name="K2Node_AssignDelegate_0" ExportPath="/Script/BlueprintGraph.K2Node_AssignDelegate'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment:EventGraph.K2Node_AssignDelegate_0'"
DelegateReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.Actor'",MemberName="OnEndPlay")
NodePosX=2240
NodePosY=1584
NodeGuid=AD2E460940AE6B07C5FE518E111B2909
CustomProperties Pin (PinId=86FA158D4EBB8E99A0063BBFB5CAFA7D,PinName="execute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=98DFCE7B49E479343BD765BE8D9CF13A,PinName="then",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=9EEC18F94EE45E5F2DEBCC950A1059E7,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "BaseMCDelegateSelfPinName", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.Actor'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=3C0089524CDDA9E63853BEA28156FACD,PinName="Delegate",PinFriendlyName=NSLOCTEXT("K2Node", "PinFriendlyDelegatetName", "Event"),PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent="/Script/CoreUObject.Package'/Script/Engine'",MemberName="ActorEndPlaySignature__DelegateSignature"),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Knot_7 424DC49B456B27D825A8F690E6CAA096,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_7" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment:EventGraph.K2Node_Knot_7'"
NodePosX=2160
NodePosY=1648
NodeGuid=A98222664329B5AA6D32FCBFC43C062C
CustomProperties Pin (PinId=6014BE7344D4B71DCD1CC39ACD1DB9EE,PinName="InputPin",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent="/Script/Engine.BlueprintGeneratedClass'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment_C'",MemberName="CustomEvent",MemberGuid=8955D806490FF62840F229BD64AC0F8B),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CustomEvent_0 DA10B1984E92B126FB09CE9D0F767D2E,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=424DC49B456B27D825A8F690E6CAA096,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="delegate",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(MemberParent="/Script/Engine.BlueprintGeneratedClass'/Game/Examples/BallShooter/Blueprints/BallShooterEnvironment.BallShooterEnvironment_C'",MemberName="CustomEvent",MemberGuid=8955D806490FF62840F229BD64AC0F8B),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_AssignDelegate_0 3C0089524CDDA9E63853BEA28156FACD,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`)
const eventNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(0)
const knotNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(2)
const assignNode = await blueprintPage.blueprintLocator.locator("ueb-node").nth(1)
const pin1 = eventNode.locator("ueb-pin").nth(0)
const pin2A = knotNode.locator("ueb-pin").nth(0)
const pin2B = knotNode.locator("ueb-pin").nth(1)
const pin3 = assignNode.locator("ueb-pin").nth(2)
expect(await pin1.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await pin2A.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await pin2B.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await pin3.evaluate(/** @param {PinElement} pin */ pin => pin.isLinked)).toBeTruthy()
expect(await blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2)
})