Refactoring WIP

This commit is contained in:
barsdeveloper
2025-02-04 23:11:46 +02:00
parent 0e2ecdf93e
commit 2f357818f4
23 changed files with 582 additions and 232 deletions

16
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Blueprintue",
"type": "firefox",
"request": "launch",
"reAttach": true,
"url": "http://127.0.0.1:8080/debug.html",
"tmpDir": "~/.tmp/"
},
]
}

356
dist/ueblueprint.js vendored
View File

@@ -117,9 +117,9 @@ class Configuration {
static mouseWheelZoomThreshold = 80 static mouseWheelZoomThreshold = 80
static nodeDragEventName = "ueb-node-drag" static nodeDragEventName = "ueb-node-drag"
static nodeDragGeneralEventName = "ueb-node-drag-general" static nodeDragGeneralEventName = "ueb-node-drag-general"
static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeRadius = 8 // px static nodeRadius = 8 // px
static nodeReflowEventName = "ueb-node-reflow" static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeUpdateEventName = "ueb-node-update"
static paths = { static paths = {
actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent", actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent",
addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate", addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate",
@@ -239,6 +239,7 @@ class Configuration {
timeline: "/Script/BlueprintGraph.K2Node_Timeline", timeline: "/Script/BlueprintGraph.K2Node_Timeline",
timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary", timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary",
transform: "/Script/CoreUObject.Transform", transform: "/Script/CoreUObject.Transform",
typedElementHandleLibrary: "/Script/TypedElementFramework.TypedElementHandleLibrary",
userDefinedEnum: "/Script/Engine.UserDefinedEnum", userDefinedEnum: "/Script/Engine.UserDefinedEnum",
variableGet: "/Script/BlueprintGraph.K2Node_VariableGet", variableGet: "/Script/BlueprintGraph.K2Node_VariableGet",
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet", variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
@@ -250,6 +251,7 @@ class Configuration {
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop", whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
} }
static pinInputWrapWidth = 145 // px static pinInputWrapWidth = 145 // px
static pinUpdateEventName = "ueb-pin-update"
static removeEventName = "ueb-element-delete" static removeEventName = "ueb-element-delete"
static scale = { static scale = {
[-12]: 0.133333, [-12]: 0.133333,
@@ -4006,7 +4008,7 @@ class VectorEntity extends IEntity {
} }
} }
const paths$1 = Configuration.paths; const paths$2 = Configuration.paths;
const sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/; const sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/;
const keyNameValue = { const keyNameValue = {
"A_AccentGrave": "à", "A_AccentGrave": "à",
@@ -4140,58 +4142,58 @@ function keyName(value) {
function nodeTitle(entity) { function nodeTitle(entity) {
let value; let value;
switch (entity.getType()) { switch (entity.getType()) {
case paths$1.addDelegate: case paths$2.addDelegate:
value ??= "Bind Event to "; value ??= "Bind Event to ";
case paths$1.clearDelegate: case paths$2.clearDelegate:
value ??= "Unbind all Events from "; value ??= "Unbind all Events from ";
case paths$1.removeDelegate: case paths$2.removeDelegate:
value ??= "Unbind Event from "; value ??= "Unbind Event from ";
return value + Utility.formatStringName( return value + Utility.formatStringName(
entity.DelegateReference?.MemberName?.toString().replace(/Delegate$/, "") ?? "None" entity.DelegateReference?.MemberName?.toString().replace(/Delegate$/, "") ?? "None"
) )
case paths$1.asyncAction: case paths$2.asyncAction:
if (entity.ProxyFactoryFunctionName) { if (entity.ProxyFactoryFunctionName) {
return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString()) return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString())
} }
case paths$1.actorBoundEvent: case paths$2.actorBoundEvent:
case paths$1.componentBoundEvent: case paths$2.componentBoundEvent:
return `${Utility.formatStringName(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})` return `${Utility.formatStringName(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})`
case paths$1.callDelegate: case paths$2.callDelegate:
return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}` return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}`
case paths$1.createDelegate: case paths$2.createDelegate:
return "Create Event" return "Create Event"
case paths$1.customEvent: case paths$2.customEvent:
if (entity.CustomFunctionName) { if (entity.CustomFunctionName) {
return entity.CustomFunctionName?.toString() return entity.CustomFunctionName?.toString()
} }
case paths$1.dynamicCast: case paths$2.dynamicCast:
if (!entity.TargetType) { if (!entity.TargetType) {
return "Bad cast node" // Target type not found return "Bad cast node" // Target type not found
} }
return `Cast To ${entity.TargetType?.getName()}` return `Cast To ${entity.TargetType?.getName()}`
case paths$1.enumLiteral: case paths$2.enumLiteral:
return `Literal enum ${entity.Enum?.getName()}` return `Literal enum ${entity.Enum?.getName()}`
case paths$1.event: case paths$2.event:
return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}` return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}`
case paths$1.executionSequence: case paths$2.executionSequence:
return "Sequence" return "Sequence"
case paths$1.forEachElementInEnum: case paths$2.forEachElementInEnum:
return `For Each ${entity.Enum?.getName()}` return `For Each ${entity.Enum?.getName()}`
case paths$1.forEachLoopWithBreak: case paths$2.forEachLoopWithBreak:
return "For Each Loop with Break" return "For Each Loop with Break"
case paths$1.functionEntry: case paths$2.functionEntry:
return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript" return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript"
? "Construction Script" ? "Construction Script"
: entity.FunctionReference?.MemberName?.toString() : entity.FunctionReference?.MemberName?.toString()
case paths$1.functionResult: case paths$2.functionResult:
return "Return Node" return "Return Node"
case paths$1.ifThenElse: case paths$2.ifThenElse:
return "Branch" return "Branch"
case paths$1.makeStruct: case paths$2.makeStruct:
if (entity.StructType) { if (entity.StructType) {
return `Make ${entity.StructType.getName()}` return `Make ${entity.StructType.getName()}`
} }
case paths$1.materialExpressionComponentMask: { case paths$2.materialExpressionComponentMask: {
const materialObject = entity.getMaterialSubobject(); const materialObject = entity.getMaterialSubobject();
if (materialObject) { if (materialObject) {
return `Mask ( ${Configuration.rgba return `Mask ( ${Configuration.rgba
@@ -4200,15 +4202,15 @@ function nodeTitle(entity) {
.join("")})` .join("")})`
} }
} }
case paths$1.materialExpressionConstant: case paths$2.materialExpressionConstant:
value ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue]; value ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue];
case paths$1.materialExpressionConstant2Vector: case paths$2.materialExpressionConstant2Vector:
value ??= [ value ??= [
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue, entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue,
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue, entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue,
]; ];
case paths$1.materialExpressionConstant3Vector: case paths$2.materialExpressionConstant3Vector:
case paths$1.materialExpressionConstant4Vector: case paths$2.materialExpressionConstant4Vector:
if (!value) { if (!value) {
const vector = entity.getCustomproperties() const vector = entity.getCustomproperties()
.find(pinEntity => pinEntity.PinName?.toString() == "Constant") .find(pinEntity => pinEntity.PinName?.toString() == "Constant")
@@ -4222,32 +4224,32 @@ function nodeTitle(entity) {
} }
value = undefined; value = undefined;
break break
case paths$1.materialExpressionFunctionInput: { case paths$2.materialExpressionFunctionInput: {
const materialObject = entity.getMaterialSubobject(); const materialObject = entity.getMaterialSubobject();
const inputName = materialObject?.InputName ?? "In"; const inputName = materialObject?.InputName ?? "In";
const inputType = materialObject?.InputType?.value.match(/^.+?_(\w+)$/)?.[1] ?? "Vector3"; const inputType = materialObject?.InputType?.value.match(/^.+?_(\w+)$/)?.[1] ?? "Vector3";
return `Input ${inputName} (${inputType})` return `Input ${inputName} (${inputType})`
} }
case paths$1.materialExpressionLogarithm: case paths$2.materialExpressionLogarithm:
return "Ln" return "Ln"
case paths$1.materialExpressionLogarithm10: case paths$2.materialExpressionLogarithm10:
return "Log10" return "Log10"
case paths$1.materialExpressionLogarithm2: case paths$2.materialExpressionLogarithm2:
return "Log2" return "Log2"
case paths$1.materialExpressionMaterialFunctionCall: case paths$2.materialExpressionMaterialFunctionCall:
const materialFunction = entity.getMaterialSubobject()?.MaterialFunction; const materialFunction = entity.getMaterialSubobject()?.MaterialFunction;
if (materialFunction) { if (materialFunction) {
return materialFunction.getName() return materialFunction.getName()
} }
break break
case paths$1.materialExpressionSquareRoot: case paths$2.materialExpressionSquareRoot:
return "Sqrt" return "Sqrt"
case paths$1.materialExpressionSubtract: case paths$2.materialExpressionSubtract:
const materialObject = entity.getMaterialSubobject(); const materialObject = entity.getMaterialSubobject();
if (materialObject) { if (materialObject) {
return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})` return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})`
} }
case paths$1.metasoundEditorGraphExternalNode: { case paths$2.metasoundEditorGraphExternalNode: {
const name = entity["ClassName"]?.["Name"]; const name = entity["ClassName"]?.["Name"];
if (name) { if (name) {
switch (name) { switch (name) {
@@ -4256,7 +4258,7 @@ function nodeTitle(entity) {
} }
} }
} }
case paths$1.niagaraNodeConvert: case paths$2.niagaraNodeConvert:
/** @type {String} */ /** @type {String} */
const targetType = (entity["AutowireMakeType"]?.["ClassStructOrEnum"] ?? "") const targetType = (entity["AutowireMakeType"]?.["ClassStructOrEnum"] ?? "")
.toString() .toString()
@@ -4264,11 +4266,11 @@ function nodeTitle(entity) {
?.[1] ?.[1]
?? ""; ?? "";
return `Make ${targetType}` return `Make ${targetType}`
case paths$1.pcgEditorGraphNodeInput: case paths$2.pcgEditorGraphNodeInput:
return "Input" return "Input"
case paths$1.pcgEditorGraphNodeOutput: case paths$2.pcgEditorGraphNodeOutput:
return "Output" return "Output"
case paths$1.spawnActorFromClass: case paths$2.spawnActorFromClass:
let className = entity.getCustomproperties() let className = entity.getCustomproperties()
.find(pinEntity => pinEntity.PinName.toString() == "ReturnValue") .find(pinEntity => pinEntity.PinName.toString() == "ReturnValue")
?.PinType ?.PinType
@@ -4278,13 +4280,13 @@ function nodeTitle(entity) {
className = null; className = null;
} }
return `SpawnActor ${Utility.formatStringName(className ?? "NONE")}` return `SpawnActor ${Utility.formatStringName(className ?? "NONE")}`
case paths$1.switchEnum: case paths$2.switchEnum:
return `Switch on ${entity.Enum?.getName() ?? "Enum"}` return `Switch on ${entity.Enum?.getName() ?? "Enum"}`
case paths$1.switchInteger: case paths$2.switchInteger:
return `Switch on Int` return `Switch on Int`
case paths$1.variableGet: case paths$2.variableGet:
return "" return ""
case paths$1.variableSet: case paths$2.variableSet:
return "SET" return "SET"
} }
const className = entity.getClass(); const className = entity.getClass();
@@ -4302,14 +4304,14 @@ function nodeTitle(entity) {
if (keyNameSymbol) { if (keyNameSymbol) {
const name = keyNameSymbol.toString(); const name = keyNameSymbol.toString();
let title = keyName(name) ?? Utility.formatStringName(name); let title = keyName(name) ?? Utility.formatStringName(name);
if (className === paths$1.inputDebugKey) { if (className === paths$2.inputDebugKey) {
title = "Debug Key " + title; title = "Debug Key " + title;
} else if (className === paths$1.getInputAxisKeyValue) { } else if (className === paths$2.getInputAxisKeyValue) {
title = "Get " + title; title = "Get " + title;
} }
return title return title
} }
if (className === paths$1.macro) { if (className === paths$2.macro) {
return Utility.formatStringName(entity.MacroGraphReference?.getMacroName()) return Utility.formatStringName(entity.MacroGraphReference?.getMacroName())
} }
const materialSubobject = entity.getMaterialSubobject(); const materialSubobject = entity.getMaterialSubobject();
@@ -4329,7 +4331,7 @@ function nodeTitle(entity) {
} }
const settingsObject = entity.getSettingsObject(); const settingsObject = entity.getSettingsObject();
if (settingsObject) { if (settingsObject) {
if (settingsObject.ExportPath?.valueOf()?.type === paths$1.pcgHiGenGridSizeSettings) { if (settingsObject.ExportPath?.valueOf()?.type === paths$2.pcgHiGenGridSizeSettings) {
return `Grid Size: ${( return `Grid Size: ${(
settingsObject.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00") settingsObject.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00")
?? settingsObject.HiGenGridSize?.toString().match(/^\w+$/)?.[0] ?? settingsObject.HiGenGridSize?.toString().match(/^\w+$/)?.[0]
@@ -4371,11 +4373,12 @@ function nodeTitle(entity) {
) )
} }
switch (memberParent) { switch (memberParent) {
case paths$1.blueprintGameplayTagLibrary: case paths$2.blueprintGameplayTagLibrary:
case paths$1.kismetMathLibrary: case paths$2.kismetMathLibrary:
case paths$1.kismetStringLibrary: case paths$2.kismetStringLibrary:
case paths$1.slateBlueprintLibrary: case paths$2.slateBlueprintLibrary:
case paths$1.timeManagementBlueprintLibrary: case paths$2.timeManagementBlueprintLibrary:
case paths$2.typedElementHandleLibrary:
const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/); const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/);
if (leadingLetter) { if (leadingLetter) {
// Some functions start with B or F (Like FCeil, FMax, BMin) // Some functions start with B or F (Like FCeil, FMax, BMin)
@@ -4386,6 +4389,7 @@ function nodeTitle(entity) {
case "BooleanAND": return "AND" case "BooleanAND": return "AND"
case "BooleanNAND": return "NAND" case "BooleanNAND": return "NAND"
case "BooleanOR": return "OR" case "BooleanOR": return "OR"
case "Equal": return "=="
case "Exp": return "e" case "Exp": return "e"
case "LineTraceSingle": return "Line Trace By Channel" case "LineTraceSingle": return "Line Trace By Channel"
case "Max": return "MAX" case "Max": return "MAX"
@@ -4459,7 +4463,7 @@ function nodeTitle(entity) {
return "^" return "^"
} }
break break
case paths$1.blueprintSetLibrary: case paths$2.blueprintSetLibrary:
{ {
const setOperationMatch = memberName.match(/Set_(\w+)/); const setOperationMatch = memberName.match(/Set_(\w+)/);
if (setOperationMatch) { if (setOperationMatch) {
@@ -4467,7 +4471,7 @@ function nodeTitle(entity) {
} }
} }
break break
case paths$1.blueprintMapLibrary: case paths$2.blueprintMapLibrary:
{ {
const setOperationMatch = memberName.match(/Map_(\w+)/); const setOperationMatch = memberName.match(/Map_(\w+)/);
if (setOperationMatch) { if (setOperationMatch) {
@@ -4475,7 +4479,7 @@ function nodeTitle(entity) {
} }
} }
break break
case paths$1.kismetArrayLibrary: case paths$2.kismetArrayLibrary:
{ {
const arrayOperationMath = memberName.match(/Array_(\w+)/); const arrayOperationMath = memberName.match(/Array_(\w+)/);
if (arrayOperationMath) { if (arrayOperationMath) {
@@ -5722,6 +5726,8 @@ class SimpleSerializationVectorEntity extends VectorEntity {
} }
} }
const paths$1 = Configuration.paths;
/** @template {IEntity} T */ /** @template {IEntity} T */
class PinEntity extends IEntity { class PinEntity extends IEntity {
@@ -5737,24 +5743,24 @@ class PinEntity extends IEntity {
"name": StringEntity, "name": StringEntity,
"real": NumberEntity, "real": NumberEntity,
"string": StringEntity, "string": StringEntity,
[Configuration.paths.linearColor]: LinearColorEntity, [paths$1.linearColor]: LinearColorEntity,
[Configuration.paths.niagaraBool]: BooleanEntity, [paths$1.niagaraBool]: BooleanEntity,
[Configuration.paths.niagaraFloat]: NumberEntity, [paths$1.niagaraFloat]: NumberEntity,
[Configuration.paths.niagaraPosition]: VectorEntity, [paths$1.niagaraPosition]: VectorEntity,
[Configuration.paths.rotator]: RotatorEntity, [paths$1.rotator]: RotatorEntity,
[Configuration.paths.vector]: VectorEntity, [paths$1.vector]: VectorEntity,
[Configuration.paths.vector2D]: Vector2DEntity, [paths$1.vector2D]: Vector2DEntity,
[Configuration.paths.vector4f]: Vector4DEntity, [paths$1.vector4f]: Vector4DEntity,
} }
static #alternativeTypeEntityMap = { static #alternativeTypeEntityMap = {
"enum": EnumDisplayValueEntity, "enum": EnumDisplayValueEntity,
"rg": RBSerializationVector2DEntity, "rg": RBSerializationVector2DEntity,
[Configuration.paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(), [paths$1.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(),
[Configuration.paths.rotator]: SimpleSerializationRotatorEntity, [paths$1.rotator]: SimpleSerializationRotatorEntity,
[Configuration.paths.vector]: SimpleSerializationVectorEntity, [paths$1.vector]: SimpleSerializationVectorEntity,
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity, [paths$1.vector2D]: SimpleSerializationVector2DEntity,
[Configuration.paths.vector3f]: SimpleSerializationVectorEntity, [paths$1.vector3f]: SimpleSerializationVectorEntity,
[Configuration.paths.vector4f]: SimpleSerializationVector4DEntity, [paths$1.vector4f]: SimpleSerializationVector4DEntity,
} }
static attributes = { static attributes = {
PinId: GuidEntity.withDefault(), PinId: GuidEntity.withDefault(),
@@ -5904,9 +5910,9 @@ class PinEntity extends IEntity {
case "rg": case "rg":
return "rg" return "rg"
case "rgb": case "rgb":
return Configuration.paths.vector return paths$1.vector
case "rgba": case "rgba":
return Configuration.paths.linearColor return paths$1.linearColor
default: default:
return subCategory return subCategory
} }
@@ -5942,14 +5948,14 @@ class PinEntity extends IEntity {
isEnum() { isEnum() {
const type = this.PinType.PinSubCategoryObject?.type; const type = this.PinType.PinSubCategoryObject?.type;
return type === Configuration.paths.enum return type === paths$1.enum
|| type === Configuration.paths.userDefinedEnum || type === paths$1.userDefinedEnum
|| type?.toLowerCase() === "enum" || type?.toLowerCase() === "enum"
} }
isExecution() { isExecution() {
return this.PinType.PinCategory.toString() === "exec" return this.PinType.PinCategory.toString() === "exec"
|| this.getType() === Configuration.paths.niagaraParameterMap || this.getType() === paths$1.niagaraParameterMap
} }
isHidden() { isHidden() {
@@ -7658,8 +7664,6 @@ class LinkTemplate extends IFromToPositionedTemplate {
this.blueprint.addGraphElement(knot); // Important: keep it before changing existing links this.blueprint.addGraphElement(knot); // Important: keep it before changing existing links
const inputPin = this.element.getInputPin(); const inputPin = this.element.getInputPin();
const outputPin = this.element.getOutputPin(); const outputPin = this.element.getOutputPin();
this.element.origin = null;
this.element.target = null;
const link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) const link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link"))
.newObject(outputPin, knotTemplate.inputPin); .newObject(outputPin, knotTemplate.inputPin);
this.blueprint.addGraphElement(link); this.blueprint.addGraphElement(link);
@@ -7785,24 +7789,28 @@ class LinkTemplate extends IFromToPositionedTemplate {
/** @param {PropertyValues} changedProperties */ /** @param {PropertyValues} changedProperties */
update(changedProperties) { update(changedProperties) {
super.update(changedProperties); super.update(changedProperties);
const referencePin = this.element.getOutputPin(true); const style = this.element.style;
if (referencePin) { if (changedProperties.has("color")) {
this.element.style.setProperty("--ueb-link-color-rgb", LinearColorEntity.printLinearColor(referencePin.color)); style.setProperty("--ueb-link-color-rgb", this.element.color?.toString() ?? "255, 255, 255");
} }
this.element.style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`); style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`);
this.element.style.setProperty("--ueb-link-start", `${Math.round(this.element.startPixels)}`); style.setProperty("--ueb-link-start", `${Math.round(this.element.startPixels)}`);
const mirrorV = (this.element.originY > this.element.targetY ? -1 : 1) // If from is below to => mirror const mirrorV = (this.element.originY > this.element.targetY ? -1 : 1) // If from is below to => mirror
* (this.element.originatesFromInput ? -1 : 1) // Unless fro refers to an input pin * (this.element.originatesFromInput ? -1 : 1) // Unless fro refers to an input pin
* (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1); * (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1);
const mirrorH = (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1); const mirrorH = (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1);
this.element.style.setProperty("--ueb-link-scale-y", `${mirrorV}`); style.setProperty("--ueb-link-scale-y", `${mirrorV}`);
this.element.style.setProperty("--ueb-link-scale-x", `${mirrorH}`); style.setProperty("--ueb-link-scale-x", `${mirrorH}`);
} }
render() { render() {
return x` return x`
<svg version="1.2" baseProfile="tiny" width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none"> <svg version="1.2" baseProfile="tiny" width="100%" height="100%" viewBox="0 0 100 100"
<path id="${this.#uniqueId}" fill="none" vector-effect="non-scaling-stroke" d="${this.element.svgPathD}" /> preserveAspectRatio="none"
>
<path id="${this.#uniqueId}" fill="none" vector-effect="non-scaling-stroke"
d="${this.element.svgPathD}"
/>
<use href="#${this.#uniqueId}" class="ueb-link-area" pointer-events="all" /> <use href="#${this.#uniqueId}" class="ueb-link-area" pointer-events="all" />
<use href="#${this.#uniqueId}" class="ueb-link-path" pointer-events="none" /> <use href="#${this.#uniqueId}" class="ueb-link-path" pointer-events="none" />
</svg> </svg>
@@ -7919,6 +7927,9 @@ class LinkElement extends IFromToPositionedElement {
converter: BooleanEntity.booleanConverter, converter: BooleanEntity.booleanConverter,
reflect: true, reflect: true,
}, },
color: {
type: LinearColorEntity,
},
svgPathD: { svgPathD: {
type: String, type: String,
attribute: false, attribute: false,
@@ -7951,6 +7962,29 @@ class LinkElement extends IFromToPositionedElement {
this.#setPin(pin, true); this.#setPin(pin, true);
} }
/** @param {UEBNodeUpdateEvent} e */
#nodeUpdateHandler = e => {
if (this.#origin.nodeElement === e.target) {
if (this.originNode != this.#origin.nodeElement.nodeTitle) {
this.originNode = this.#origin.nodeElement.nodeTitle;
}
this.setOriginLocation();
} else if (this.#target.nodeElement === e.target) {
if (this.targetNode != this.#target.nodeElement.nodeTitle) {
this.targetNode = this.#target.nodeElement.nodeTitle;
}
this.setTargetLocation();
} else {
throw new Error("Unexpected node update")
}
}
/** @param {UEBNodeUpdateEvent} e */
#pinUpdateHandler = e => {
const colorReferencePin = this.getOutputPin(true);
if (!this.color?.equals(colorReferencePin.color)) {
this.color = colorReferencePin.color;
}
}
#nodeDeleteHandler = () => this.remove() #nodeDeleteHandler = () => this.remove()
/** @param {UEBDragEvent} e */ /** @param {UEBDragEvent} e */
#nodeDragOriginHandler = e => this.addOriginLocation(...e.detail.value) #nodeDragOriginHandler = e => this.addOriginLocation(...e.detail.value)
@@ -7980,6 +8014,7 @@ class LinkElement extends IFromToPositionedElement {
this.targetNode = ""; this.targetNode = "";
this.targetPin = ""; this.targetPin = "";
this.originatesFromInput = false; this.originatesFromInput = false;
this.color = new LinearColorEntity();
this.startPercentage = 0; this.startPercentage = 0;
this.svgPathD = ""; this.svgPathD = "";
this.startPixels = 0; this.startPixels = 0;
@@ -8029,15 +8064,13 @@ class LinkElement extends IFromToPositionedElement {
} }
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement(); const nodeElement = getCurrentPin().getNodeElement();
nodeElement.removeEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler);
nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler); nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler);
nodeElement.removeEventListener( nodeElement.removeEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
); );
nodeElement.removeEventListener( getCurrentPin().removeEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler);
Configuration.nodeReflowEventName,
isTargetPin ? this.#nodeReflowTargetHandler : this.#nodeReflowOriginHandler
);
this.#unlinkPins(); this.#unlinkPins();
} }
if (isTargetPin) { if (isTargetPin) {
@@ -8051,20 +8084,20 @@ class LinkElement extends IFromToPositionedElement {
} }
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement(); const nodeElement = getCurrentPin().getNodeElement();
nodeElement.addEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler);
nodeElement.addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler);
nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler); nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler);
nodeElement.addEventListener( nodeElement.addEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
); );
nodeElement.addEventListener( getCurrentPin().addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler);
Configuration.nodeReflowEventName,
isTargetPin ? this.#nodeReflowTargetHandler : this.#nodeReflowOriginHandler
);
isTargetPin isTargetPin
? this.setTargetLocation() ? this.setTargetLocation()
: (this.setOriginLocation(), this.originatesFromInput = this.origin.isInputVisually()); : (this.setOriginLocation(), this.originatesFromInput = this.origin.isInputVisually());
this.#linkPins(); this.#linkPins();
} }
this.color = this.getOutputPin(true)?.color;
} }
#linkPins() { #linkPins() {
@@ -8900,14 +8933,14 @@ class NodeTemplate extends ISelectableDraggableTemplate {
} else { } else {
(pin.isInput() ? this.inputContainer : this.outputContainer).appendChild(this.createPinElement(pin)); (pin.isInput() ? this.inputContainer : this.outputContainer).appendChild(this.createPinElement(pin));
} }
this.element.acknowledgeReflow(); this.element.acknowledgeUpdate();
} }
} }
toggleAdvancedDisplayHandler = () => { toggleAdvancedDisplayHandler = () => {
this.element.toggleShowAdvancedPinDisplay(); this.element.toggleShowAdvancedPinDisplay();
this.element.requestUpdate(); this.element.requestUpdate();
this.element.updateComplete.then(() => this.element.acknowledgeReflow()); this.element.updateComplete.then(() => this.element.acknowledgeUpdate());
} }
/** @param {PinEntity<IEntity>} pinEntity */ /** @param {PinEntity<IEntity>} pinEntity */
@@ -8994,7 +9027,7 @@ class NodeTemplate extends ISelectableDraggableTemplate {
this.inputContainer = this.element.querySelector(".ueb-node-inputs"); this.inputContainer = this.element.querySelector(".ueb-node-inputs");
this.outputContainer = this.element.querySelector(".ueb-node-outputs"); this.outputContainer = this.element.querySelector(".ueb-node-outputs");
this.setupPins(); this.setupPins();
this.element.updateComplete.then(() => this.element.acknowledgeReflow()); this.element.updateComplete.then(() => this.element.acknowledgeUpdate());
} }
setupPins() { setupPins() {
@@ -9647,14 +9680,16 @@ class PinTemplate extends ITemplate {
// When connected, an input may drop its input fields which means the node has to reflow // When connected, an input may drop its input fields which means the node has to reflow
const node = this.element.nodeElement; const node = this.element.nodeElement;
this.element.requestUpdate(); this.element.requestUpdate();
this.element.updateComplete.then(() => node.acknowledgeReflow()); this.element.updateComplete.then(() => node.acknowledgeUpdate());
}
if (changedProperties.has("color")) {
this.element.style.setProperty("--ueb-pin-color-rgb", this.element.color.toString());
} }
} }
/** @param {PropertyValues} changedProperties */ /** @param {PropertyValues} changedProperties */
firstUpdated(changedProperties) { firstUpdated(changedProperties) {
super.firstUpdated(changedProperties); super.firstUpdated(changedProperties);
this.element.style.setProperty("--ueb-pin-color-rgb", this.element.entity.pinColor().cssText);
this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element; this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element;
this.#wrapperElement = this.element.querySelector(".ueb-pin-wrapper"); this.#wrapperElement = this.element.querySelector(".ueb-pin-wrapper");
} }
@@ -9769,10 +9804,61 @@ class EventNodeTemplate extends NodeTemplate {
/** @extends MinimalPinTemplate<KnotEntity> */ /** @extends MinimalPinTemplate<KnotEntity> */
class KnotPinTemplate extends MinimalPinTemplate { class KnotPinTemplate extends MinimalPinTemplate {
static #wildcardPinType = new PinTypeEntity({
PinCategory: new StringEntity("wildcard"),
PinSubCategoryObject: ObjectReferenceEntity.createNoneInstance(),
PinSubCategoryMemberReference: new FunctionReferenceEntity(),
})
/** @param {PinTypeEntity} type */
#setType(type) {
const oppositePin = this.getoppositePin();
this.element.entity.PinType.copyTypeFrom(type);
oppositePin.entity.PinType.copyTypeFrom(type);
this.element.updateType();
oppositePin.updateType();
}
render() { render() {
return this.element.isOutput() ? super.render() : x`` return this.element.isOutput() ? super.render() : x``
} }
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties);
if (changedProperties.has("isLinked")) {
const oppositePin = this.getoppositePin();
if (!this.element.isLinked && !oppositePin.isLinked) {
this.#setType(KnotPinTemplate.#wildcardPinType);
} else if (this.element.isLinked && this.element.pinType == "wildcard") {
const type = this.element
.getLinks()
.map(r => this.blueprint.getPin(r))
.find(p => p && p.pinType != "wildcard")
?.entity
.PinType;
if (type) {
/** @type {KnotPinTemplate[]} */
const propagated = [this];
for (let i = 0; i < propagated.length; ++i) {
let current = propagated[i];
current.#setType(type);
current = /** @type {KnotPinTemplate} */(current.getoppositePin().template);
current.#setType(type);
propagated.push(
...current.element.getLinks().map(r => (
/** @type {KnotPinTemplate} */(
this.blueprint.getPin(r).template
)
))
);
}
}
}
}
}
getoppositePin() { getoppositePin() {
const nodeTemplate = /** @type {KnotNodeTemplate} */(this.element.nodeElement.template); const nodeTemplate = /** @type {KnotNodeTemplate} */(this.element.nodeElement.template);
return this.element.isOutput() ? nodeTemplate.inputPin : nodeTemplate.outputPin return this.element.isOutput() ? nodeTemplate.inputPin : nodeTemplate.outputPin
@@ -9798,7 +9884,7 @@ class KnotNodeTemplate extends NodeTemplate {
return return
} }
this.#switchDirectionsVisually = value; this.#switchDirectionsVisually = value;
this.element.acknowledgeReflow(); this.element.acknowledgeUpdate();
} }
/** @type {PinElement} */ /** @type {PinElement} */
@@ -9819,17 +9905,6 @@ class KnotNodeTemplate extends NodeTemplate {
this.element.classList.add("ueb-node-style-minimal"); this.element.classList.add("ueb-node-style-minimal");
} }
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties);
if (!this.#inputPin.isLinked && !this.#outputPin.isLinked) {
this.#inputPin.entity.PinType.PinCategory.value = "wildcard";
this.#inputPin.updateColor();
this.#outputPin.entity.PinType.PinCategory.value = "wildcard";
this.#inputPin.updateColor();
}
}
render() { render() {
return x` return x`
<div class="ueb-node-border"></div> <div class="ueb-node-border"></div>
@@ -9988,9 +10063,10 @@ function nodeTemplateClass(nodeEntity) {
const memberName = nodeEntity.FunctionReference?.MemberName?.toString(); const memberName = nodeEntity.FunctionReference?.MemberName?.toString();
if ( if (
memberName && ( memberName && (
memberParent === paths.kismetMathLibrary memberParent === paths.kismetArrayLibrary
|| memberParent === paths.kismetArrayLibrary || memberParent === paths.kismetMathLibrary
|| memberParent === paths.kismetStringLibrary || memberParent === paths.kismetStringLibrary
|| memberParent === paths.typedElementHandleLibrary
)) { )) {
if (memberName.startsWith("Conv_")) { if (memberName.startsWith("Conv_")) {
return VariableConversionNodeTemplate return VariableConversionNodeTemplate
@@ -10017,6 +10093,7 @@ function nodeTemplateClass(nodeEntity) {
case "BMin": case "BMin":
case "CrossProduct2D": case "CrossProduct2D":
case "DotProduct2D": case "DotProduct2D":
case "Equal":
case "Exp": case "Exp":
case "FMax": case "FMax":
case "FMin": case "FMin":
@@ -10261,18 +10338,11 @@ class NodeElement extends ISelectableDraggableElement {
this.#redirectLinksBeforeRename(newName?.toString()); this.#redirectLinksBeforeRename(newName?.toString());
this.nodeTitle = newName?.toString(); this.nodeTitle = newName?.toString();
this.nodeDisplayName = nodeTitle(entity); this.nodeDisplayName = nodeTitle(entity);
this.acknowledgeUpdate();
} }
); );
} }
async getUpdateComplete() {
let result = await super.getUpdateComplete();
for (const pin of this.getPinElements()) {
result &&= await pin.updateComplete;
}
return result
}
/** @param {NodeElement} commentNode */ /** @param {NodeElement} commentNode */
bindToComment(commentNode) { bindToComment(commentNode) {
if (commentNode != this && !this.boundComments.includes(commentNode)) { if (commentNode != this && !this.boundComments.includes(commentNode)) {
@@ -10315,14 +10385,14 @@ class NodeElement extends ISelectableDraggableElement {
setNodeWidth(value) { setNodeWidth(value) {
this.entity.setNodeWidth(value); this.entity.setNodeWidth(value);
this.sizeX = value; this.sizeX = value;
this.acknowledgeReflow(); this.acknowledgeUpdate(true);
} }
/** @param {Number} value */ /** @param {Number} value */
setNodeHeight(value) { setNodeHeight(value) {
this.entity.setNodeHeight(value); this.entity.setNodeHeight(value);
this.sizeY = value; this.sizeY = value;
this.acknowledgeReflow(); this.acknowledgeUpdate(true);
} }
/** @param {IElement[]} nodesWhitelist */ /** @param {IElement[]} nodesWhitelist */
@@ -10345,11 +10415,13 @@ class NodeElement extends ISelectableDraggableElement {
super.setLocation(x, y, acknowledge); super.setLocation(x, y, acknowledge);
} }
acknowledgeReflow() { acknowledgeUpdate(resize = false) {
this.requestUpdate(); const event = new CustomEvent(Configuration.nodeUpdateEventName);
this.updateComplete.then(() => this.computeSizes()); if (resize) {
let reflowEvent = new CustomEvent(Configuration.nodeReflowEventName); this.requestUpdate();
this.dispatchEvent(reflowEvent); this.updateComplete.then(() => this.computeSizes());
}
this.dispatchEvent(event);
} }
setShowAdvancedPinDisplay(value) { setShowAdvancedPinDisplay(value) {
@@ -11411,7 +11483,6 @@ class Blueprint extends IElement {
nodesNames = new Map() nodesNames = new Map()
/** @type {Coordinates} */ /** @type {Coordinates} */
mousePosition = [0, 0] mousePosition = [0, 0]
waitingExpandUpdate = false
constructor() { constructor() {
super(); super();
@@ -12164,7 +12235,6 @@ class InputElement extends IElement {
this.singleLine = false; this.singleLine = false;
this.selectOnFocus = true; this.selectOnFocus = true;
this.blurOnEnter = true; this.blurOnEnter = true;
this.editable = true;
super.initialize({}, new InputTemplate()); super.initialize({}, new InputTemplate());
} }
@@ -12296,13 +12366,13 @@ class IInputPinTemplate extends PinTemplate {
} }
if (Self.canWrapInput && this.isInputRendered()) { if (Self.canWrapInput && this.isInputRendered()) {
this.element.addEventListener("input", this.#checkWrapHandler); this.element.addEventListener("input", this.#checkWrapHandler);
this.element.nodeElement.addEventListener(Configuration.nodeReflowEventName, this.#checkWrapHandler); this.element.nodeElement.addEventListener(Configuration.nodeUpdateEventName, this.#checkWrapHandler);
} }
} }
cleanup() { cleanup() {
super.cleanup(); super.cleanup();
this.element.nodeElement.removeEventListener(Configuration.nodeReflowEventName, this.#checkWrapHandler); this.element.nodeElement.removeEventListener(Configuration.nodeUpdateEventName, this.#checkWrapHandler);
this.element.removeEventListener("input", this.#checkWrapHandler); this.element.removeEventListener("input", this.#checkWrapHandler);
this.element.removeEventListener("input", this.#setInput); this.element.removeEventListener("input", this.#setInput);
this.element.removeEventListener("focusout", this.#setInput); this.element.removeEventListener("focusout", this.#setInput);
@@ -12330,7 +12400,7 @@ class IInputPinTemplate extends PinTemplate {
this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values); this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values);
} }
this.element.requestUpdate(); this.element.requestUpdate();
this.element.nodeElement.acknowledgeReflow(); this.element.updateComplete.then(() => this.element.nodeElement.acknowledgeUpdate());
} }
setDefaultValue(values = [], rawValues = values) { setDefaultValue(values = [], rawValues = values) {
@@ -13339,7 +13409,8 @@ class PinElement extends IElement {
fromAttribute: (value, type) => value fromAttribute: (value, type) => value
? LinearColorEntity.getLinearColorFromAnyFormat().parse(value) ? LinearColorEntity.getLinearColorFromAnyFormat().parse(value)
: null, : null,
toAttribute: (value, type) => value ? LinearColorEntity.printLinearColor(value) : null, /** @param {LinearColorEntity} value */
toAttribute: (value, type) => value?.toString() ?? "",
}, },
attribute: "data-color", attribute: "data-color",
reflect: true, reflect: true,
@@ -13391,10 +13462,11 @@ class PinElement extends IElement {
this.connectable = !entity.bNotConnectable?.valueOf(); this.connectable = !entity.bNotConnectable?.valueOf();
super.initialize(entity, template); super.initialize(entity, template);
this.pinId = this.entity.PinId; this.pinId = this.entity.PinId;
this.pinType = this.entity.getType(); this.updateType();
this.defaultValue = this.entity.getDefaultValue(); this.defaultValue = this.entity.getDefaultValue();
this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden"; this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden";
this.updateColor(); /** @type {LinearColorEntity} */
this.color = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString());
} }
setup() { setup() {
@@ -13402,8 +13474,13 @@ class PinElement extends IElement {
this.nodeElement = this.closest("ueb-node"); this.nodeElement = this.closest("ueb-node");
} }
updateColor() { updateType() {
this.color = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString()); this.pinType = this.entity.getType();
const newColor = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString());
if (!this.color?.equals(newColor)) {
this.color = newColor;
this.acknowledgeUpdate();
}
} }
createPinReference() { createPinReference() {
@@ -13581,6 +13658,11 @@ class PinElement extends IElement {
} }
return false return false
} }
acknowledgeUpdate() {
let event = new CustomEvent(Configuration.pinUpdateEventName);
this.dispatchEvent(event);
}
} }
class OrderedIndexArray { class OrderedIndexArray {

File diff suppressed because one or more lines are too long

View File

@@ -85,7 +85,6 @@ export default class Blueprint extends IElement {
nodesNames = new Map() nodesNames = new Map()
/** @type {Coordinates} */ /** @type {Coordinates} */
mousePosition = [0, 0] mousePosition = [0, 0]
waitingExpandUpdate = false
constructor() { constructor() {
super() super()

View File

@@ -93,9 +93,9 @@ export default class Configuration {
static mouseWheelZoomThreshold = 80 static mouseWheelZoomThreshold = 80
static nodeDragEventName = "ueb-node-drag" static nodeDragEventName = "ueb-node-drag"
static nodeDragGeneralEventName = "ueb-node-drag-general" static nodeDragGeneralEventName = "ueb-node-drag-general"
static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeRadius = 8 // px static nodeRadius = 8 // px
static nodeReflowEventName = "ueb-node-reflow" static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeUpdateEventName = "ueb-node-update"
static paths = { static paths = {
actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent", actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent",
addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate", addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate",
@@ -215,6 +215,7 @@ export default class Configuration {
timeline: "/Script/BlueprintGraph.K2Node_Timeline", timeline: "/Script/BlueprintGraph.K2Node_Timeline",
timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary", timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary",
transform: "/Script/CoreUObject.Transform", transform: "/Script/CoreUObject.Transform",
typedElementHandleLibrary: "/Script/TypedElementFramework.TypedElementHandleLibrary",
userDefinedEnum: "/Script/Engine.UserDefinedEnum", userDefinedEnum: "/Script/Engine.UserDefinedEnum",
variableGet: "/Script/BlueprintGraph.K2Node_VariableGet", variableGet: "/Script/BlueprintGraph.K2Node_VariableGet",
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet", variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
@@ -226,6 +227,7 @@ export default class Configuration {
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop", whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
} }
static pinInputWrapWidth = 145 // px static pinInputWrapWidth = 145 // px
static pinUpdateEventName = "ueb-pin-update"
static removeEventName = "ueb-element-delete" static removeEventName = "ueb-element-delete"
static scale = { static scale = {
[-12]: 0.133333, [-12]: 0.133333,

View File

@@ -88,9 +88,10 @@ export default function nodeTemplateClass(nodeEntity) {
const memberName = nodeEntity.FunctionReference?.MemberName?.toString() const memberName = nodeEntity.FunctionReference?.MemberName?.toString()
if ( if (
memberName && ( memberName && (
memberParent === paths.kismetMathLibrary memberParent === paths.kismetArrayLibrary
|| memberParent === paths.kismetArrayLibrary || memberParent === paths.kismetMathLibrary
|| memberParent === paths.kismetStringLibrary || memberParent === paths.kismetStringLibrary
|| memberParent === paths.typedElementHandleLibrary
)) { )) {
if (memberName.startsWith("Conv_")) { if (memberName.startsWith("Conv_")) {
return VariableConversionNodeTemplate return VariableConversionNodeTemplate
@@ -117,6 +118,7 @@ export default function nodeTemplateClass(nodeEntity) {
case "BMin": case "BMin":
case "CrossProduct2D": case "CrossProduct2D":
case "DotProduct2D": case "DotProduct2D":
case "Equal":
case "Exp": case "Exp":
case "FMax": case "FMax":
case "FMin": case "FMin":

View File

@@ -375,6 +375,7 @@ export default function nodeTitle(entity) {
case paths.kismetStringLibrary: case paths.kismetStringLibrary:
case paths.slateBlueprintLibrary: case paths.slateBlueprintLibrary:
case paths.timeManagementBlueprintLibrary: case paths.timeManagementBlueprintLibrary:
case paths.typedElementHandleLibrary:
const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/) const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/)
if (leadingLetter) { if (leadingLetter) {
// Some functions start with B or F (Like FCeil, FMax, BMin) // Some functions start with B or F (Like FCeil, FMax, BMin)
@@ -385,6 +386,7 @@ export default function nodeTitle(entity) {
case "BooleanAND": return "AND" case "BooleanAND": return "AND"
case "BooleanNAND": return "NAND" case "BooleanNAND": return "NAND"
case "BooleanOR": return "OR" case "BooleanOR": return "OR"
case "Equal": return "=="
case "Exp": return "e" case "Exp": return "e"
case "LineTraceSingle": return "Line Trace By Channel" case "LineTraceSingle": return "Line Trace By Channel"
case "Max": return "MAX" case "Max": return "MAX"

View File

@@ -5,6 +5,7 @@ import Utility from "../Utility.js"
import BooleanEntity from "../entity/BooleanEntity.js" import BooleanEntity from "../entity/BooleanEntity.js"
import LinkTemplate from "../template/LinkTemplate.js" import LinkTemplate from "../template/LinkTemplate.js"
import IFromToPositionedElement from "./IFromToPositionedElement.js" import IFromToPositionedElement from "./IFromToPositionedElement.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
/** @extends {IFromToPositionedElement<Object, LinkTemplate>} */ /** @extends {IFromToPositionedElement<Object, LinkTemplate>} */
export default class LinkElement extends IFromToPositionedElement { export default class LinkElement extends IFromToPositionedElement {
@@ -43,6 +44,9 @@ export default class LinkElement extends IFromToPositionedElement {
converter: BooleanEntity.booleanConverter, converter: BooleanEntity.booleanConverter,
reflect: true, reflect: true,
}, },
color: {
type: LinearColorEntity,
},
svgPathD: { svgPathD: {
type: String, type: String,
attribute: false, attribute: false,
@@ -75,6 +79,29 @@ export default class LinkElement extends IFromToPositionedElement {
this.#setPin(pin, true) this.#setPin(pin, true)
} }
/** @param {UEBNodeUpdateEvent} e */
#nodeUpdateHandler = e => {
if (this.#origin.nodeElement === e.target) {
if (this.originNode != this.#origin.nodeElement.nodeTitle) {
this.originNode = this.#origin.nodeElement.nodeTitle
}
this.setOriginLocation()
} else if (this.#target.nodeElement === e.target) {
if (this.targetNode != this.#target.nodeElement.nodeTitle) {
this.targetNode = this.#target.nodeElement.nodeTitle
}
this.setTargetLocation()
} else {
throw new Error("Unexpected node update")
}
}
/** @param {UEBNodeUpdateEvent} e */
#pinUpdateHandler = e => {
const colorReferencePin = this.getOutputPin(true)
if (!this.color?.equals(colorReferencePin.color)) {
this.color = colorReferencePin.color
}
}
#nodeDeleteHandler = () => this.remove() #nodeDeleteHandler = () => this.remove()
/** @param {UEBDragEvent} e */ /** @param {UEBDragEvent} e */
#nodeDragOriginHandler = e => this.addOriginLocation(...e.detail.value) #nodeDragOriginHandler = e => this.addOriginLocation(...e.detail.value)
@@ -104,6 +131,7 @@ export default class LinkElement extends IFromToPositionedElement {
this.targetNode = "" this.targetNode = ""
this.targetPin = "" this.targetPin = ""
this.originatesFromInput = false this.originatesFromInput = false
this.color = new LinearColorEntity()
this.startPercentage = 0 this.startPercentage = 0
this.svgPathD = "" this.svgPathD = ""
this.startPixels = 0 this.startPixels = 0
@@ -153,15 +181,13 @@ export default class LinkElement extends IFromToPositionedElement {
} }
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement() const nodeElement = getCurrentPin().getNodeElement()
nodeElement.removeEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler)
nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler) nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler)
nodeElement.removeEventListener( nodeElement.removeEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
) )
nodeElement.removeEventListener( getCurrentPin().removeEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
Configuration.nodeReflowEventName,
isTargetPin ? this.#nodeReflowTargetHandler : this.#nodeReflowOriginHandler
)
this.#unlinkPins() this.#unlinkPins()
} }
if (isTargetPin) { if (isTargetPin) {
@@ -175,20 +201,20 @@ export default class LinkElement extends IFromToPositionedElement {
} }
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement() const nodeElement = getCurrentPin().getNodeElement()
nodeElement.addEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler)
nodeElement.addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler) nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler)
nodeElement.addEventListener( nodeElement.addEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
) )
nodeElement.addEventListener( getCurrentPin().addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
Configuration.nodeReflowEventName,
isTargetPin ? this.#nodeReflowTargetHandler : this.#nodeReflowOriginHandler
)
isTargetPin isTargetPin
? this.setTargetLocation() ? this.setTargetLocation()
: (this.setOriginLocation(), this.originatesFromInput = this.origin.isInputVisually()) : (this.setOriginLocation(), this.originatesFromInput = this.origin.isInputVisually())
this.#linkPins() this.#linkPins()
} }
this.color = this.getOutputPin(true)?.color
} }
#linkPins() { #linkPins() {

View File

@@ -138,18 +138,11 @@ export default class NodeElement extends ISelectableDraggableElement {
this.#redirectLinksBeforeRename(newName?.toString()) this.#redirectLinksBeforeRename(newName?.toString())
this.nodeTitle = newName?.toString() this.nodeTitle = newName?.toString()
this.nodeDisplayName = nodeTitle(entity) this.nodeDisplayName = nodeTitle(entity)
this.acknowledgeUpdate()
} }
) )
} }
async getUpdateComplete() {
let result = await super.getUpdateComplete()
for (const pin of this.getPinElements()) {
result &&= await pin.updateComplete
}
return result
}
/** @param {NodeElement} commentNode */ /** @param {NodeElement} commentNode */
bindToComment(commentNode) { bindToComment(commentNode) {
if (commentNode != this && !this.boundComments.includes(commentNode)) { if (commentNode != this && !this.boundComments.includes(commentNode)) {
@@ -192,14 +185,14 @@ export default class NodeElement extends ISelectableDraggableElement {
setNodeWidth(value) { setNodeWidth(value) {
this.entity.setNodeWidth(value) this.entity.setNodeWidth(value)
this.sizeX = value this.sizeX = value
this.acknowledgeReflow() this.acknowledgeUpdate(true)
} }
/** @param {Number} value */ /** @param {Number} value */
setNodeHeight(value) { setNodeHeight(value) {
this.entity.setNodeHeight(value) this.entity.setNodeHeight(value)
this.sizeY = value this.sizeY = value
this.acknowledgeReflow() this.acknowledgeUpdate(true)
} }
/** @param {IElement[]} nodesWhitelist */ /** @param {IElement[]} nodesWhitelist */
@@ -222,11 +215,13 @@ export default class NodeElement extends ISelectableDraggableElement {
super.setLocation(x, y, acknowledge) super.setLocation(x, y, acknowledge)
} }
acknowledgeReflow() { acknowledgeUpdate(resize = false) {
this.requestUpdate() const event = new CustomEvent(Configuration.nodeUpdateEventName)
this.updateComplete.then(() => this.computeSizes()) if (resize) {
let reflowEvent = new CustomEvent(Configuration.nodeReflowEventName) this.requestUpdate()
this.dispatchEvent(reflowEvent) this.updateComplete.then(() => this.computeSizes())
}
this.dispatchEvent(event)
} }
setShowAdvancedPinDisplay(value) { setShowAdvancedPinDisplay(value) {

View File

@@ -44,7 +44,8 @@ export default class PinElement extends IElement {
fromAttribute: (value, type) => value fromAttribute: (value, type) => value
? LinearColorEntity.getLinearColorFromAnyFormat().parse(value) ? LinearColorEntity.getLinearColorFromAnyFormat().parse(value)
: null, : null,
toAttribute: (value, type) => value ? LinearColorEntity.printLinearColor(value) : null, /** @param {LinearColorEntity} value */
toAttribute: (value, type) => value?.toString() ?? "",
}, },
attribute: "data-color", attribute: "data-color",
reflect: true, reflect: true,
@@ -96,10 +97,11 @@ export default class PinElement extends IElement {
this.connectable = !entity.bNotConnectable?.valueOf() this.connectable = !entity.bNotConnectable?.valueOf()
super.initialize(entity, template) super.initialize(entity, template)
this.pinId = this.entity.PinId this.pinId = this.entity.PinId
this.pinType = this.entity.getType() this.updateType()
this.defaultValue = this.entity.getDefaultValue() this.defaultValue = this.entity.getDefaultValue()
this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden" this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden"
this.updateColor() /** @type {LinearColorEntity} */
this.color = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString())
} }
setup() { setup() {
@@ -107,8 +109,13 @@ export default class PinElement extends IElement {
this.nodeElement = this.closest("ueb-node") this.nodeElement = this.closest("ueb-node")
} }
updateColor() { updateType() {
this.color = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString()) this.pinType = this.entity.getType()
const newColor = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString())
if (!this.color?.equals(newColor)) {
this.color = newColor
this.acknowledgeUpdate()
}
} }
createPinReference() { createPinReference() {
@@ -289,4 +296,9 @@ export default class PinElement extends IElement {
} }
return false return false
} }
acknowledgeUpdate() {
let event = new CustomEvent(Configuration.pinUpdateEventName)
this.dispatchEvent(event)
}
} }

View File

@@ -34,6 +34,8 @@ import Vector2DEntity from "./Vector2DEntity.js"
import Vector4DEntity from "./Vector4DEntity.js" import Vector4DEntity from "./Vector4DEntity.js"
import VectorEntity from "./VectorEntity.js" import VectorEntity from "./VectorEntity.js"
const paths = Configuration.paths
/** @template {IEntity} T */ /** @template {IEntity} T */
export default class PinEntity extends IEntity { export default class PinEntity extends IEntity {
@@ -49,24 +51,24 @@ export default class PinEntity extends IEntity {
"name": StringEntity, "name": StringEntity,
"real": NumberEntity, "real": NumberEntity,
"string": StringEntity, "string": StringEntity,
[Configuration.paths.linearColor]: LinearColorEntity, [paths.linearColor]: LinearColorEntity,
[Configuration.paths.niagaraBool]: BooleanEntity, [paths.niagaraBool]: BooleanEntity,
[Configuration.paths.niagaraFloat]: NumberEntity, [paths.niagaraFloat]: NumberEntity,
[Configuration.paths.niagaraPosition]: VectorEntity, [paths.niagaraPosition]: VectorEntity,
[Configuration.paths.rotator]: RotatorEntity, [paths.rotator]: RotatorEntity,
[Configuration.paths.vector]: VectorEntity, [paths.vector]: VectorEntity,
[Configuration.paths.vector2D]: Vector2DEntity, [paths.vector2D]: Vector2DEntity,
[Configuration.paths.vector4f]: Vector4DEntity, [paths.vector4f]: Vector4DEntity,
} }
static #alternativeTypeEntityMap = { static #alternativeTypeEntityMap = {
"enum": EnumDisplayValueEntity, "enum": EnumDisplayValueEntity,
"rg": RBSerializationVector2DEntity, "rg": RBSerializationVector2DEntity,
[Configuration.paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(), [paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(),
[Configuration.paths.rotator]: SimpleSerializationRotatorEntity, [paths.rotator]: SimpleSerializationRotatorEntity,
[Configuration.paths.vector]: SimpleSerializationVectorEntity, [paths.vector]: SimpleSerializationVectorEntity,
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity, [paths.vector2D]: SimpleSerializationVector2DEntity,
[Configuration.paths.vector3f]: SimpleSerializationVectorEntity, [paths.vector3f]: SimpleSerializationVectorEntity,
[Configuration.paths.vector4f]: SimpleSerializationVector4DEntity, [paths.vector4f]: SimpleSerializationVector4DEntity,
} }
static attributes = { static attributes = {
PinId: GuidEntity.withDefault(), PinId: GuidEntity.withDefault(),
@@ -216,9 +218,9 @@ export default class PinEntity extends IEntity {
case "rg": case "rg":
return "rg" return "rg"
case "rgb": case "rgb":
return Configuration.paths.vector return paths.vector
case "rgba": case "rgba":
return Configuration.paths.linearColor return paths.linearColor
default: default:
return subCategory return subCategory
} }
@@ -254,14 +256,14 @@ export default class PinEntity extends IEntity {
isEnum() { isEnum() {
const type = this.PinType.PinSubCategoryObject?.type const type = this.PinType.PinSubCategoryObject?.type
return type === Configuration.paths.enum return type === paths.enum
|| type === Configuration.paths.userDefinedEnum || type === paths.userDefinedEnum
|| type?.toLowerCase() === "enum" || type?.toLowerCase() === "enum"
} }
isExecution() { isExecution() {
return this.PinType.PinCategory.toString() === "exec" return this.PinType.PinCategory.toString() === "exec"
|| this.getType() === Configuration.paths.niagaraParameterMap || this.getType() === paths.niagaraParameterMap
} }
isHidden() { isHidden() {

View File

@@ -1,7 +1,6 @@
import { html, nothing } from "lit" import { html, nothing } from "lit"
import Configuration from "../Configuration.js" import Configuration from "../Configuration.js"
import ElementFactory from "../element/ElementFactory.js" import ElementFactory from "../element/ElementFactory.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
import KnotEntity from "../entity/objects/KnotEntity.js" import KnotEntity from "../entity/objects/KnotEntity.js"
import KeyboardShortcut from "../input/keyboard/KeyboardShortcut.js" import KeyboardShortcut from "../input/keyboard/KeyboardShortcut.js"
import MouseClick from "../input/mouse/MouseClick.js" import MouseClick from "../input/mouse/MouseClick.js"
@@ -53,8 +52,6 @@ export default class LinkTemplate extends IFromToPositionedTemplate {
this.blueprint.addGraphElement(knot) // Important: keep it before changing existing links this.blueprint.addGraphElement(knot) // Important: keep it before changing existing links
const inputPin = this.element.getInputPin() const inputPin = this.element.getInputPin()
const outputPin = this.element.getOutputPin() const outputPin = this.element.getOutputPin()
this.element.origin = null
this.element.target = null
const link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) const link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link"))
.newObject(outputPin, knotTemplate.inputPin) .newObject(outputPin, knotTemplate.inputPin)
this.blueprint.addGraphElement(link) this.blueprint.addGraphElement(link)
@@ -181,24 +178,28 @@ export default class LinkTemplate extends IFromToPositionedTemplate {
/** @param {PropertyValues} changedProperties */ /** @param {PropertyValues} changedProperties */
update(changedProperties) { update(changedProperties) {
super.update(changedProperties) super.update(changedProperties)
const referencePin = this.element.getOutputPin(true) const style = this.element.style
if (referencePin) { if (changedProperties.has("color")) {
this.element.style.setProperty("--ueb-link-color-rgb", LinearColorEntity.printLinearColor(referencePin.color)) style.setProperty("--ueb-link-color-rgb", this.element.color?.toString() ?? "255, 255, 255")
} }
this.element.style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`) style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`)
this.element.style.setProperty("--ueb-link-start", `${Math.round(this.element.startPixels)}`) style.setProperty("--ueb-link-start", `${Math.round(this.element.startPixels)}`)
const mirrorV = (this.element.originY > this.element.targetY ? -1 : 1) // If from is below to => mirror const mirrorV = (this.element.originY > this.element.targetY ? -1 : 1) // If from is below to => mirror
* (this.element.originatesFromInput ? -1 : 1) // Unless fro refers to an input pin * (this.element.originatesFromInput ? -1 : 1) // Unless fro refers to an input pin
* (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1) * (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1)
const mirrorH = (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1) const mirrorH = (this.element.origin?.isInputVisually() && this.element.target?.isInputVisually() ? -1 : 1)
this.element.style.setProperty("--ueb-link-scale-y", `${mirrorV}`) style.setProperty("--ueb-link-scale-y", `${mirrorV}`)
this.element.style.setProperty("--ueb-link-scale-x", `${mirrorH}`) style.setProperty("--ueb-link-scale-x", `${mirrorH}`)
} }
render() { render() {
return html` return html`
<svg version="1.2" baseProfile="tiny" width="100%" height="100%" viewBox="0 0 100 100" preserveAspectRatio="none"> <svg version="1.2" baseProfile="tiny" width="100%" height="100%" viewBox="0 0 100 100"
<path id="${this.#uniqueId}" fill="none" vector-effect="non-scaling-stroke" d="${this.element.svgPathD}" /> preserveAspectRatio="none"
>
<path id="${this.#uniqueId}" fill="none" vector-effect="non-scaling-stroke"
d="${this.element.svgPathD}"
/>
<use href="#${this.#uniqueId}" class="ueb-link-area" pointer-events="all" /> <use href="#${this.#uniqueId}" class="ueb-link-area" pointer-events="all" />
<use href="#${this.#uniqueId}" class="ueb-link-path" pointer-events="none" /> <use href="#${this.#uniqueId}" class="ueb-link-path" pointer-events="none" />
</svg> </svg>

View File

@@ -14,7 +14,7 @@ export default class KnotNodeTemplate extends NodeTemplate {
return return
} }
this.#switchDirectionsVisually = value this.#switchDirectionsVisually = value
this.element.acknowledgeReflow() this.element.acknowledgeUpdate()
} }
/** @type {PinElement} */ /** @type {PinElement} */
@@ -35,17 +35,6 @@ export default class KnotNodeTemplate extends NodeTemplate {
this.element.classList.add("ueb-node-style-minimal") this.element.classList.add("ueb-node-style-minimal")
} }
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties)
if (!this.#inputPin.isLinked && !this.#outputPin.isLinked) {
this.#inputPin.entity.PinType.PinCategory.value = "wildcard"
this.#inputPin.updateColor()
this.#outputPin.entity.PinType.PinCategory.value = "wildcard"
this.#inputPin.updateColor()
}
}
render() { render() {
return html` return html`
<div class="ueb-node-border"></div> <div class="ueb-node-border"></div>

View File

@@ -31,14 +31,14 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
} else { } else {
(pin.isInput() ? this.inputContainer : this.outputContainer).appendChild(this.createPinElement(pin)) (pin.isInput() ? this.inputContainer : this.outputContainer).appendChild(this.createPinElement(pin))
} }
this.element.acknowledgeReflow() this.element.acknowledgeUpdate()
} }
} }
toggleAdvancedDisplayHandler = () => { toggleAdvancedDisplayHandler = () => {
this.element.toggleShowAdvancedPinDisplay() this.element.toggleShowAdvancedPinDisplay()
this.element.requestUpdate() this.element.requestUpdate()
this.element.updateComplete.then(() => this.element.acknowledgeReflow()) this.element.updateComplete.then(() => this.element.acknowledgeUpdate())
} }
/** @param {PinEntity<IEntity>} pinEntity */ /** @param {PinEntity<IEntity>} pinEntity */
@@ -125,7 +125,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
this.inputContainer = this.element.querySelector(".ueb-node-inputs") this.inputContainer = this.element.querySelector(".ueb-node-inputs")
this.outputContainer = this.element.querySelector(".ueb-node-outputs") this.outputContainer = this.element.querySelector(".ueb-node-outputs")
this.setupPins() this.setupPins()
this.element.updateComplete.then(() => this.element.acknowledgeReflow()) this.element.updateComplete.then(() => this.element.acknowledgeUpdate())
} }
setupPins() { setupPins() {

View File

@@ -78,13 +78,13 @@ export default class IInputPinTemplate extends PinTemplate {
} }
if (Self.canWrapInput && this.isInputRendered()) { if (Self.canWrapInput && this.isInputRendered()) {
this.element.addEventListener("input", this.#checkWrapHandler) this.element.addEventListener("input", this.#checkWrapHandler)
this.element.nodeElement.addEventListener(Configuration.nodeReflowEventName, this.#checkWrapHandler) this.element.nodeElement.addEventListener(Configuration.nodeUpdateEventName, this.#checkWrapHandler)
} }
} }
cleanup() { cleanup() {
super.cleanup() super.cleanup()
this.element.nodeElement.removeEventListener(Configuration.nodeReflowEventName, this.#checkWrapHandler) this.element.nodeElement.removeEventListener(Configuration.nodeUpdateEventName, this.#checkWrapHandler)
this.element.removeEventListener("input", this.#checkWrapHandler) this.element.removeEventListener("input", this.#checkWrapHandler)
this.element.removeEventListener("input", this.#setInput) this.element.removeEventListener("input", this.#setInput)
this.element.removeEventListener("focusout", this.#setInput) this.element.removeEventListener("focusout", this.#setInput)
@@ -112,7 +112,7 @@ export default class IInputPinTemplate extends PinTemplate {
this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values) this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values)
} }
this.element.requestUpdate() this.element.requestUpdate()
this.element.nodeElement.acknowledgeReflow() this.element.updateComplete.then(() => this.element.nodeElement.acknowledgeUpdate())
} }
setDefaultValue(values = [], rawValues = values) { setDefaultValue(values = [], rawValues = values) {

View File

@@ -1,13 +1,68 @@
import { html } from "lit" import { html } from "lit"
import FunctionReferenceEntity from "../../entity/FunctionReferenceEntity.js"
import ObjectReferenceEntity from "../../entity/ObjectReferenceEntity.js"
import PinTypeEntity from "../../entity/PinTypeEntity.js"
import StringEntity from "../../entity/StringEntity.js"
import MinimalPinTemplate from "./MinimalPinTemplate.js" import MinimalPinTemplate from "./MinimalPinTemplate.js"
/** @extends MinimalPinTemplate<KnotEntity> */ /** @extends MinimalPinTemplate<KnotEntity> */
export default class KnotPinTemplate extends MinimalPinTemplate { export default class KnotPinTemplate extends MinimalPinTemplate {
static #wildcardPinType = new PinTypeEntity({
PinCategory: new StringEntity("wildcard"),
PinSubCategoryObject: ObjectReferenceEntity.createNoneInstance(),
PinSubCategoryMemberReference: new FunctionReferenceEntity(),
})
/** @param {PinTypeEntity} type */
#setType(type) {
const oppositePin = this.getoppositePin()
this.element.entity.PinType.copyTypeFrom(type)
oppositePin.entity.PinType.copyTypeFrom(type)
this.element.updateType()
oppositePin.updateType()
}
render() { render() {
return this.element.isOutput() ? super.render() : html`` return this.element.isOutput() ? super.render() : html``
} }
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties)
if (changedProperties.has("isLinked")) {
const oppositePin = this.getoppositePin()
if (!this.element.isLinked && !oppositePin.isLinked) {
this.#setType(KnotPinTemplate.#wildcardPinType)
} else if (this.element.isLinked && this.element.pinType == "wildcard") {
const type = this.element
.getLinks()
.map(r => this.blueprint.getPin(r))
.find(p => p && p.pinType != "wildcard")
?.entity
.PinType
if (type) {
/** @type {KnotPinTemplate[]} */
const propagated = [this]
for (let i = 0; i < propagated.length; ++i) {
let current = propagated[i]
current.#setType(type)
current = /** @type {KnotPinTemplate} */(current.getoppositePin().template)
current.#setType(type)
propagated.push(
...current.element.getLinks().map(r => (
/** @type {KnotPinTemplate} */(
this.blueprint.getPin(r).template
)
))
)
}
}
}
}
}
getoppositePin() { getoppositePin() {
const nodeTemplate = /** @type {KnotNodeTemplate} */(this.element.nodeElement.template) const nodeTemplate = /** @type {KnotNodeTemplate} */(this.element.nodeElement.template)
return this.element.isOutput() ? nodeTemplate.inputPin : nodeTemplate.outputPin return this.element.isOutput() ? nodeTemplate.inputPin : nodeTemplate.outputPin

View File

@@ -159,14 +159,16 @@ export default class PinTemplate extends ITemplate {
// When connected, an input may drop its input fields which means the node has to reflow // When connected, an input may drop its input fields which means the node has to reflow
const node = this.element.nodeElement const node = this.element.nodeElement
this.element.requestUpdate() this.element.requestUpdate()
this.element.updateComplete.then(() => node.acknowledgeReflow()) this.element.updateComplete.then(() => node.acknowledgeUpdate())
}
if (changedProperties.has("color")) {
this.element.style.setProperty("--ueb-pin-color-rgb", this.element.color.toString())
} }
} }
/** @param {PropertyValues} changedProperties */ /** @param {PropertyValues} changedProperties */
firstUpdated(changedProperties) { firstUpdated(changedProperties) {
super.firstUpdated(changedProperties) super.firstUpdated(changedProperties)
this.element.style.setProperty("--ueb-pin-color-rgb", this.element.entity.pinColor().cssText)
this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element this.#iconElement = this.element.querySelector(".ueb-pin-icon svg") ?? this.element
this.#wrapperElement = this.element.querySelector(".ueb-pin-wrapper") this.#wrapperElement = this.element.querySelector(".ueb-pin-wrapper")
} }

View File

@@ -93,7 +93,7 @@ export default class BlueprintFixture {
}) })
webserver.listen(this.#port, "127.0.0.1", async () => { webserver.listen(this.#port, "127.0.0.1", async () => {
console.log(`Server started on http://127.0.0.1:${this.#port}`) console.log(`Server started on http://127.0.0.1:${this.#port}`)
const url = `http://127.0.0.1:${this.#port}/empty.html` const url = `http://127.0.0.1:${this.#port}/debug.html`
try { try {
await this.checkServerReady(url) await this.checkServerReady(url)
BlueprintFixture.server = webserver BlueprintFixture.server = webserver
@@ -111,7 +111,7 @@ export default class BlueprintFixture {
} }
async setup() { async setup() {
const url = `http://127.0.0.1:${this.#port}/empty.html` const url = `http://127.0.0.1:${this.#port}/debug.html`
for (let i = 0; i < 1E4; ++i) { for (let i = 0; i < 1E4; ++i) {
try { try {
await this.page.goto(url, { waitUntil: "domcontentloaded" }) await this.page.goto(url, { waitUntil: "domcontentloaded" })

View File

@@ -62,11 +62,9 @@ export function testNode(testData) {
if (testData.color) { if (testData.color) {
test( test(
`${testData.name}: Has correct color`, `${testData.name}: Has correct color`,
async ({ blueprintPage }) => { async ({ blueprintPage }) =>
expect( expect(await blueprintPage.node.evaluate(node => node.entity.nodeColor().toString()))
await blueprintPage.node.evaluate(node => node.entity.nodeColor().toString()) .toBe(testData.color.toString())
).toBe(testData.color.toString())
}
) )
} }

135
tests/linking3.spec.js Executable file
View File

@@ -0,0 +1,135 @@
import { expect, test } from "./fixtures/test.js"
test("Linking 3", async ({ blueprintPage }) => {
const source = String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_25" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_25'"
NodePosX=976
NodePosY=288
NodeGuid=CF9256F15B564DB0B289FDB4704A2290
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_8 47E4D9AF4CD414564F484A96E876E80B,),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_27" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_27'"
NodePosX=1232
NodePosY=288
NodeGuid=43A2EF73BD644DD382666D7AC1FB6075
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_8 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_35 47E4D9AF4CD414564F484A96E876E80B,),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_8" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_8'"
NodePosX=1120
NodePosY=288
NodeGuid=E3B195FA61CC499A9B34F07F5F5A6CCE
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_25 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_27 47E4D9AF4CD414564F484A96E876E80B,K2Node_Knot_38 47E4D9AF4CD414564F484A96E876E80B,K2Node_Knot_40 47E4D9AF4CD414564F484A96E876E80B,),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_35" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_35'"
NodePosX=1376
NodePosY=288
NodeGuid=60EA1A96C0B544C1A23FE8E43E93C5A9
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_27 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_38" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_38'"
NodePosX=1232
NodePosY=336
NodeGuid=C85E3544423E44F4A7097FB732C2EA9F
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_8 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_39 47E4D9AF4CD414564F484A96E876E80B,),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_39" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_39'"
NodePosX=1376
NodePosY=336
NodeGuid=EBFD7E66E2564FB6B72CD6B9609F2584
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_38 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,)
End Object
Begin Object Class=/Script/BlueprintGraph.K2Node_Knot Name="K2Node_Knot_40" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_40'"
NodePosX=1232
NodePosY=384
NodeGuid=DE79DE02C598433FA7F3ED8EB016E9E2
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_8 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_41 47E4D9AF4CD414564F484A96E876E80B,),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_41" ExportPath="/Script/BlueprintGraph.K2Node_Knot'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_Knot_41'"
NodePosX=1376
NodePosY=384
NodeGuid=033ED30A27A7469CA482FDE433792DD8
CustomProperties Pin (PinId=47E4D9AF4CD414564F484A96E876E80B,PinName="InputPin",PinType.PinCategory="wildcard",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,LinkedTo=(K2Node_Knot_40 009095D54E2C15EBBB57DC9098EC7D8B,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=009095D54E2C15EBBB57DC9098EC7D8B,PinName="OutputPin",Direction="EGPD_Output",PinType.PinCategory="wildcard",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,)
End Object
Begin Object Class="/Script/BlueprintGraph.K2Node_VariableGet" Name="K2Node_VariableGet_131" ExportPath=/Script/BlueprintGraph.K2Node_VariableGet'"/Game/StarterContent/Blueprints/Blueprint_WallSconce.Blueprint_WallSconce:UserConstructionScript.K2Node_VariableGet_131"'
VariableReference=(MemberName="Color",MemberGuid=AAEC3E9C476A2187972DDE8D142A814B,bSelfContext=True)
NodePosX=768
NodePosY=272
NodeGuid=5BE70A964537A1F13BE2489B0DC06370
CustomProperties Pin (PinId=E11890DA93464F48A6221977085C4549,PinName="Color",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject=/Script/CoreUObject.ScriptStruct'"/Script/CoreUObject.LinearColor"',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=506366A2BD594C01A714D4B3A4B67508,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject=/Script/Engine.BlueprintGeneratedClass'"/Game/StarterContent/Blueprints/Blueprint_WallSconce.Blueprint_WallSconce_C"',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=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`
const nodes = blueprintPage.blueprintLocator.locator("ueb-node")
const knots = blueprintPage.blueprintLocator.locator('ueb-node[data-type="/Script/BlueprintGraph.K2Node_Knot"]')
const links = blueprintPage.blueprintLocator.locator("ueb-link")
const mouse = blueprintPage.page.mouse
const wildcardColor = "128, 120, 120"
const blueColor = "0, 88, 200"
/** @type {(i: Number) => Locator<NodeElement>} */
const getNode = i => blueprintPage.blueprintLocator.locator("ueb-node").nth(i)
const link = async (origin, target) => {
await origin.hover()
await mouse.down()
await mouse.move(100, 100, { steps: 4 })
await target.hover()
await mouse.up()
}
/** @param {NodeElement} n */
const getKnotColors = n => {
const template = /** @type {KnotNodeTemplate} */(n.template)
return [
template.inputPin.entity.pinColor().toString(),
template.inputPin.color.toString(),
template.outputPin.entity.pinColor().toString(),
template.outputPin.color.toString(),
]
}
await expect(nodes).toHaveCount(0)
await expect(knots).toHaveCount(0)
await expect(links).toHaveCount(0)
await blueprintPage.paste(source)
await blueprintPage.blueprintLocator.evaluate(b => b.template.centerContentInViewport(false))
await expect(nodes).toHaveCount(9)
await expect(knots).toHaveCount(8)
await expect(links).toHaveCount(7)
const knotsCount = await knots.count()
for (let i = 0; i < knotsCount; ++i) {
expect(await knots.nth(i).evaluate(getKnotColors)).toEqual(Array(4).fill(wildcardColor))
}
const linksCount = await links.count()
for (let i = 0; i < linksCount; ++i) {
/** @type {Locator<LinkElement>} */
const link = links.nth(i)
expect(await link.evaluate(l => l.color.toString())).toEqual(wildcardColor)
}
await link(blueprintPage.blueprintLocator.locator("ueb-pin").getByText("Color", { exact: true }), knots.nth(0))
await expect(links).toHaveCount(8)
for (let i = 0; i < knotsCount; ++i) {
expect(await knots.nth(i).evaluate(getKnotColors)).toEqual(Array(4).fill(blueColor))
}
for (let i = 0; i < linksCount; ++i) {
/** @type {Locator<LinkElement>} */
const link = links.nth(i)
expect(await link.evaluate(l => l.color.toString())).toEqual(blueColor)
}
await links.evaluateAll(ls => ls.forEach(l => l.remove()))
for (let i = 0; i < knotsCount; ++i) {
expect(await knots.nth(i).evaluate(getKnotColors)).toEqual(Array(4).fill(wildcardColor))
}
await expect(links).toHaveCount(0)
})

View File

@@ -0,0 +1,31 @@
import { expect, testNode } from "./fixtures/test.js"
testNode({
name: "Equal",
title: "==",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_14" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Game/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_14'"
bDefaultsToPureFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/TypedElementFramework.TypedElementHandleLibrary'",MemberName="Equal")
NodePosX=3632
NodePosY=-2288
NodeGuid=A103141723D244F581A0A9F8E92896F8
CustomProperties Pin (PinId=39C4587583EA4432932FA978AA918C44,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nTyped Element Handle Library Riferimento Oggetto",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/TypedElementFramework.TypedElementHandleLibrary'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/TypedElementFramework.Default__TypedElementHandleLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=5159BBDAFA644C7DA8AAEC25138286AB,PinName="LHS",PinToolTip="LHS\nScript Typed Element Handle Struttura (by ref)",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/TypedElementFramework.ScriptTypedElementHandle'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=8E09436509C24857B9593EBAA9420160,PinName="RHS",PinToolTip="RHS\nScript Typed Element Handle Struttura (by ref)",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/TypedElementFramework.ScriptTypedElementHandle'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=True,PinType.bIsConst=True,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=True,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=BEACF29085B844F0B99626653E16673D,PinName="ReturnValue",PinToolTip="Return Value\nBooleano\n\nQuesti due handle sono uguali?",Direction="EGPD_Output",PinType.PinCategory="bool",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,DefaultValue="false",AutogeneratedDefaultValue="false",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
size: [9, 4],
pins: 3,
delegate: false,
development: false,
variadic: false,
additionalTest: async (node, pins) => {
expect(await pins[0].evaluate(pin => pin.color.toString())).toEqual("0, 88, 200")
expect(await pins[1].evaluate(pin => pin.color.toString())).toEqual("0, 88, 200")
expect(await pins[2].evaluate(pin => pin.color.toString())).toEqual("146, 0, 0")
expect(await node.evaluate(node => node.classList.contains("ueb-node-style-glass"))).toBeTruthy()
expect(await node.evaluate(node => node.classList.contains("ueb-node-style-default"))).toBeFalsy()
}
})

View File

@@ -7,6 +7,7 @@
*/ */
/** /**
* @typedef {CustomEvent<{ value: Coordinates }>} UEBDragEvent * @typedef {CustomEvent<{ value: Coordinates }>} UEBDragEvent
* @typedef {CustomEvent} UEBNodeUpdateEvent
*/ */
/** @typedef {typeof import("./js/entity/IEntity.js").default} IEntityConstructor */ /** @typedef {typeof import("./js/entity/IEntity.js").default} IEntityConstructor */
/** /**