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

@@ -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"