Flip Flop node info added and minor adjustments

This commit is contained in:
barsdeveloper
2023-04-16 13:37:15 +02:00
parent a82f61ac4a
commit c1bbbfef90
11 changed files with 137 additions and 49 deletions

View File

@@ -244,6 +244,27 @@ const tests = [
delegate: false,
development: false,
},
{
name: "Flip Flop",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_MacroInstance Name="K2Node_MacroInstance_5"
MacroGraphReference=(MacroGraph=/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop"',GraphBlueprint=/Script/Engine.Blueprint'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros"',GraphGuid=BFFFAAE4434E166F549665AD1AA89B60)
NodePosX=-48
NodePosY=48
NodeGuid=267CBD7BDA9243E0916C518E03EA7F8E
CustomProperties Pin (PinId=CF77C07A39514336BF1F33B71FA6F31A,PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=ABD456E3A9E541FCA849DBC7460338A0,PinName="A",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=1E4BC9A55AA247CA8B9B2BA0F4159D07,PinName="B",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=0A09A61366D142C8A0564EC3C173DB79,PinName="IsA",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,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
color: Configuration.nodeColors.gray,
icon: SVGIcon.flipflop,
pins: 4,
pinName: ["A", "B", "IsA"],
delegate: false,
development: false,
},
]
/** @type {Blueprint} */

81
dist/ueblueprint.js vendored
View File

@@ -114,10 +114,12 @@ class Configuration {
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",
dynamicCast: "/Script/BlueprintGraph.K2Node_DynamicCast",
edGraphPinDeprecated: "/Script/Engine.EdGraphPin_Deprecated",
enum: "/Script/CoreUObject.Enum",
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
event: "/Script/BlueprintGraph.K2Node_Event",
executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence",
flipflop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop",
forEachElementInEnum: "/Script/BlueprintGraph.K2Node_ForEachElementInEnum",
forEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoop",
forEachLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",
@@ -197,12 +199,13 @@ class Configuration {
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
static smoothScrollTime = 1000 // ms
static stringEscapedCharacters = /['"\\]/g
static subObjectAttributeNamePrefix = "#SubObject"
/** @param {ObjectEntity} objectEntity */
static subObjectAttributeNameFromEntity = objectEntity =>
"#SubObject" + (objectEntity.Class.type ? "_" + objectEntity.Class.type : "") + "_" + objectEntity.Name
static subObjectAttributeNameFromEntity = (objectEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly && objectEntity.Class.type ? "_" + objectEntity.Class.type : "") + "_" + objectEntity.Name
/** @param {ObjectReferenceEntity} objectReferenceEntity */
static subObjectAttributeNameFromReference = objectReferenceEntity =>
"#SubObject_" + objectReferenceEntity.type + "_" + objectReferenceEntity.path
static subObjectAttributeNameFromReference = (objectReferenceEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly ? "_" + objectReferenceEntity.type : "") + "_" + objectReferenceEntity.path
static trackingMouseEventName = {
begin: "ueb-tracking-mouse-begin",
end: "ueb-tracking-mouse-end",
@@ -804,6 +807,11 @@ class Utility {
.toLowerCase()
}
/** @param {String} pathValue */
static getNameFromPath(pathValue) {
return pathValue.match(/[^\.\/]+$/)?.[0] ?? ""
}
/** @param {LinearColorEntity} value */
static printLinearColor(value) {
return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}`
@@ -1356,7 +1364,7 @@ class ObjectReferenceEntity extends IEntity {
}
getName() {
return this.path.match(/[^\.\/]+$/)?.[0] ?? ""
return Utility.getNameFromPath(this.path)
}
}
@@ -2020,6 +2028,7 @@ class SimpleSerializationVectorEntity extends VectorEntity {
/**
* @typedef {import("./IEntity.js").AnyValue} AnyValue
* @typedef {import("./ObjectEntity.js").default} ObjectEntity
* @typedef {import("lit").CSSResult} CSSResult
*/
@@ -2147,6 +2156,11 @@ class PinEntity extends IEntity {
/** @type {Boolean} */ this.bOrphanedPin;
}
/** @param {ObjectEntity} objectEntity */
static fromLegacyObject(objectEntity) {
return new PinEntity(objectEntity, true)
}
getType() {
const subCategory = this.PinType.PinSubCategoryObject;
if (this.PinType.PinCategory === "struct" || this.PinType.PinCategory === "object") {
@@ -2388,6 +2402,14 @@ class SVGIcon {
</svg>
`
static flipflop = y`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2L10 14" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M6 2L2 14" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M6 2L10 14" stroke="white" stroke-opacity="0.5" stroke-width="2" stroke-linecap="round"/>
</svg>
`
static forEachLoop = y`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 2C1.8 2 0 3.8 0 6V9C0 11.2 2 13 4 13H10V11H5C3.2 11 2 9.7 2 8V7C2 5.63882 2.76933 4.53408 4 4.14779V2ZM12 4C13.8 4 14 5.3 14 7V8C14 8.8 13.7 9.5 13.3 10L15.2 11.4C15.7 10.7 16 9.9 16 9V6C16 3.8 14.2 2 12 2V4Z" fill="white" />
@@ -2836,11 +2858,6 @@ class ObjectEntity extends IEntity {
CustomProperties: {
type: [new UnionType(PinEntity, UnknownPinEntity)],
},
// Legacy
Pins: {
type: [ObjectReferenceEntity],
inlined: true,
},
}
static nameRegex = /^(\w+?)(?:_(\d+))?$/
@@ -2941,12 +2958,34 @@ class ObjectEntity extends IEntity {
/** @type {IntegerEntity?} */ this.ErrorType;
/** @type {String?} */ this.ErrorMsg;
/** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties;
// Legacy
/** @type {ObjectReferenceEntity[]} */ this.Pins;
// Legacy objects transform into pins
if (this["Pins"] instanceof Array) {
this["Pins"]
.forEach(
/** @param {ObjectReferenceEntity} objectReference */
objectReference => {
const pinObject = this[Configuration.subObjectAttributeNameFromReference(objectReference, true)];
if (pinObject) {
const pinEntity = PinEntity.fromLegacyObject(pinObject);
pinEntity.LinkedTo = [];
this.CustomProperties.push(pinEntity);
}
});
}
// Legacy path names
if (this.Class.type && !this.Class.type.startsWith("/")) {
const nodeType = Object.keys(Configuration.nodeType)
.find(type => Utility.getNameFromPath(Configuration.nodeType[type]) === this.Class.type);
if (nodeType) {
this.Class.type = Configuration.nodeType[nodeType];
}
}
}
getClass() {
return this.Class.path
return this.Class.path ? this.Class.path : this.Class.type
}
getType() {
@@ -3226,6 +3265,8 @@ class ObjectEntity extends IEntity {
case Configuration.nodeType.executionSequence:
case Configuration.nodeType.multiGate:
return SVGIcon.sequence
case Configuration.nodeType.flipflop:
return SVGIcon.flipflop
case Configuration.nodeType.forEachElementInEnum:
case Configuration.nodeType.forLoop:
case Configuration.nodeType.forLoopWithBreak:
@@ -4325,10 +4366,10 @@ class ObjectSerializer extends Serializer {
key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key)
)
+ entity.CustomProperties.map(pin =>
this.attributeSeparator
+ moreIndentation
moreIndentation
+ attributeKeyPrinter("CustomProperties ")
+ SerializerFactory.getSerializer(PinEntity).doWrite(pin, insideString)
+ this.attributeSeparator
)
.join("")
+ indentation + "End Object";
@@ -7910,15 +7951,7 @@ class NodeElement extends ISelectableDraggableElement {
/** @returns {PinEntity[]} */
getPinEntities() {
if (this.entity.CustomProperties.length > 0) {
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
}
// Legacy nodes attempt to find pin entities
if (this.entity.Pins) {
return this.entity.Pins.map(objectReference =>
new UnknownPinEntity(this.entity[Configuration.subObjectAttributeNameFromReference(objectReference)])
)
}
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
}
setLocation(x = 0, y = 0, acknowledge = true) {

File diff suppressed because one or more lines are too long

View File

@@ -90,10 +90,12 @@ export default class Configuration {
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",
dynamicCast: "/Script/BlueprintGraph.K2Node_DynamicCast",
edGraphPinDeprecated: "/Script/Engine.EdGraphPin_Deprecated",
enum: "/Script/CoreUObject.Enum",
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
event: "/Script/BlueprintGraph.K2Node_Event",
executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence",
flipflop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop",
forEachElementInEnum: "/Script/BlueprintGraph.K2Node_ForEachElementInEnum",
forEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoop",
forEachLoopWithBreak: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",
@@ -173,12 +175,13 @@ export default class Configuration {
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
static smoothScrollTime = 1000 // ms
static stringEscapedCharacters = /['"\\]/g
static subObjectAttributeNamePrefix = "#SubObject"
/** @param {ObjectEntity} objectEntity */
static subObjectAttributeNameFromEntity = objectEntity =>
"#SubObject" + (objectEntity.Class.type ? "_" + objectEntity.Class.type : "") + "_" + objectEntity.Name
static subObjectAttributeNameFromEntity = (objectEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly && objectEntity.Class.type ? "_" + objectEntity.Class.type : "") + "_" + objectEntity.Name
/** @param {ObjectReferenceEntity} objectReferenceEntity */
static subObjectAttributeNameFromReference = objectReferenceEntity =>
"#SubObject_" + objectReferenceEntity.type + "_" + objectReferenceEntity.path
static subObjectAttributeNameFromReference = (objectReferenceEntity, nameOnly = false) =>
this.subObjectAttributeNamePrefix + (!nameOnly ? "_" + objectReferenceEntity.type : "") + "_" + objectReferenceEntity.path
static trackingMouseEventName = {
begin: "ueb-tracking-mouse-begin",
end: "ueb-tracking-mouse-end",

View File

@@ -107,6 +107,14 @@ export default class SVGIcon {
</svg>
`
static flipflop = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 2L10 14" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M6 2L2 14" stroke="white" stroke-width="2" stroke-linecap="round"/>
<path d="M6 2L10 14" stroke="white" stroke-opacity="0.5" stroke-width="2" stroke-linecap="round"/>
</svg>
`
static forEachLoop = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 2C1.8 2 0 3.8 0 6V9C0 11.2 2 13 4 13H10V11H5C3.2 11 2 9.7 2 8V7C2 5.63882 2.76933 4.53408 4 4.14779V2ZM12 4C13.8 4 14 5.3 14 7V8C14 8.8 13.7 9.5 13.3 10L15.2 11.4C15.7 10.7 16 9.9 16 9V6C16 3.8 14.2 2 12 2V4Z" fill="white" />

View File

@@ -353,6 +353,11 @@ export default class Utility {
.toLowerCase()
}
/** @param {String} pathValue */
static getNameFromPath(pathValue) {
return pathValue.match(/[^\.\/]+$/)?.[0] ?? ""
}
/** @param {LinearColorEntity} value */
static printLinearColor(value) {
return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}`

View File

@@ -280,15 +280,7 @@ export default class NodeElement extends ISelectableDraggableElement {
/** @returns {PinEntity[]} */
getPinEntities() {
if (this.entity.CustomProperties.length > 0) {
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
}
// Legacy nodes attempt to find pin entities
if (this.entity.Pins) {
return this.entity.Pins.map(objectReference =>
new UnknownPinEntity(this.entity[Configuration.subObjectAttributeNameFromReference(objectReference)])
)
}
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
}
setLocation(x = 0, y = 0, acknowledge = true) {

View File

@@ -201,11 +201,6 @@ export default class ObjectEntity extends IEntity {
CustomProperties: {
type: [new UnionType(PinEntity, UnknownPinEntity)],
},
// Legacy
Pins: {
type: [ObjectReferenceEntity],
inlined: true,
},
}
static nameRegex = /^(\w+?)(?:_(\d+))?$/
@@ -306,12 +301,34 @@ export default class ObjectEntity extends IEntity {
/** @type {IntegerEntity?} */ this.ErrorType
/** @type {String?} */ this.ErrorMsg
/** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties
// Legacy
/** @type {ObjectReferenceEntity[]} */ this.Pins
// Legacy objects transform into pins
if (this["Pins"] instanceof Array) {
this["Pins"]
.forEach(
/** @param {ObjectReferenceEntity} objectReference */
objectReference => {
const pinObject = this[Configuration.subObjectAttributeNameFromReference(objectReference, true)]
if (pinObject) {
const pinEntity = PinEntity.fromLegacyObject(pinObject)
pinEntity.LinkedTo = []
this.CustomProperties.push(pinEntity)
}
})
}
// Legacy path names
if (this.Class.type && !this.Class.type.startsWith("/")) {
const nodeType = Object.keys(Configuration.nodeType)
.find(type => Utility.getNameFromPath(Configuration.nodeType[type]) === this.Class.type)
if (nodeType) {
this.Class.type = Configuration.nodeType[nodeType]
}
}
}
getClass() {
return this.Class.path
return this.Class.path ? this.Class.path : this.Class.type
}
getType() {
@@ -591,6 +608,8 @@ export default class ObjectEntity extends IEntity {
case Configuration.nodeType.executionSequence:
case Configuration.nodeType.multiGate:
return SVGIcon.sequence
case Configuration.nodeType.flipflop:
return SVGIcon.flipflop
case Configuration.nodeType.forEachElementInEnum:
case Configuration.nodeType.forLoop:
case Configuration.nodeType.forLoopWithBreak:

View File

@@ -1,3 +1,4 @@
import Utility from "../Utility.js"
import IEntity from "./IEntity.js"
export default class ObjectReferenceEntity extends IEntity {
@@ -27,6 +28,6 @@ export default class ObjectReferenceEntity extends IEntity {
}
getName() {
return this.path.match(/[^\.\/]+$/)?.[0] ?? ""
return Utility.getNameFromPath(this.path)
}
}

View File

@@ -23,6 +23,7 @@ import VectorEntity from "./VectorEntity.js"
/**
* @typedef {import("./IEntity.js").AnyValue} AnyValue
* @typedef {import("./ObjectEntity.js").default} ObjectEntity
* @typedef {import("lit").CSSResult} CSSResult
*/
@@ -150,6 +151,11 @@ export default class PinEntity extends IEntity {
/** @type {Boolean} */ this.bOrphanedPin
}
/** @param {ObjectEntity} objectEntity */
static fromLegacyObject(objectEntity) {
return new PinEntity(objectEntity, true)
}
getType() {
const subCategory = this.PinType.PinSubCategoryObject
if (this.PinType.PinCategory === "struct" || this.PinType.PinCategory === "object") {

View File

@@ -91,10 +91,10 @@ export default class ObjectSerializer extends Serializer {
key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key)
)
+ entity.CustomProperties.map(pin =>
this.attributeSeparator
+ moreIndentation
moreIndentation
+ attributeKeyPrinter("CustomProperties ")
+ SerializerFactory.getSerializer(PinEntity).doWrite(pin, insideString)
+ this.attributeSeparator
)
.join("")
+ indentation + "End Object"