mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 06:57:28 +08:00
Various fixes
This commit is contained in:
@@ -80,6 +80,7 @@ export default class Configuration {
|
||||
static nodeReflowEventName = "ueb-node-reflow"
|
||||
static nodeType = {
|
||||
addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate",
|
||||
blueprint: "/Script/Engine.Blueprint",
|
||||
callArrayFunction: "/Script/BlueprintGraph.K2Node_CallArrayFunction",
|
||||
callFunction: "/Script/BlueprintGraph.K2Node_CallFunction",
|
||||
comment: "/Script/UnrealEd.EdGraphNode_Comment",
|
||||
@@ -90,6 +91,7 @@ export default class Configuration {
|
||||
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
|
||||
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",
|
||||
dynamicCast: "/Script/BlueprintGraph.K2Node_DynamicCast",
|
||||
edGraph: "/Script/Engine.EdGraph",
|
||||
edGraphPinDeprecated: "/Script/Engine.EdGraphPin_Deprecated",
|
||||
enum: "/Script/CoreUObject.Enum",
|
||||
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
|
||||
|
||||
@@ -3,6 +3,7 @@ import Configuration from "./Configuration.js"
|
||||
import UnionType from "./entity/UnionType.js"
|
||||
|
||||
/**
|
||||
* @typedef {import("./Blueprint.js").default} Blueprint
|
||||
* @typedef {import("./entity/IEntity.js").AnyValue} AnyValue
|
||||
* @typedef {import("./entity/IEntity.js").AnyValueConstructor<*>} AnyValueConstructor
|
||||
* @typedef {import("./entity/IEntity.js").AttributeInformation} TypeInformation
|
||||
@@ -413,6 +414,16 @@ export default class Utility {
|
||||
element.dispatchEvent(event)
|
||||
}
|
||||
|
||||
/** @param {Blueprint} blueprint */
|
||||
static async copy(blueprint) {
|
||||
const event = new ClipboardEvent("copy", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
clipboardData: new DataTransfer(),
|
||||
})
|
||||
blueprint.dispatchEvent(event)
|
||||
}
|
||||
|
||||
static animate(from, to, intervalSeconds, callback, timingFunction = x => {
|
||||
const v = x ** 3.5
|
||||
return v / (v + ((1 - x) ** 3.5))
|
||||
|
||||
@@ -280,7 +280,7 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
|
||||
/** @returns {PinEntity[]} */
|
||||
getPinEntities() {
|
||||
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
|
||||
return this.entity.getPinEntities()
|
||||
}
|
||||
|
||||
setLocation(x = 0, y = 0, acknowledge = true) {
|
||||
|
||||
@@ -258,6 +258,23 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
constructor(values, suppressWarns = false) {
|
||||
let keys = Object.keys(values)
|
||||
if (keys.some(k => k.startsWith(Configuration.subObjectAttributeNamePrefix))) {
|
||||
let subObjectsValues = keys
|
||||
.filter(k => k.startsWith(Configuration.subObjectAttributeNamePrefix))
|
||||
.reduce(
|
||||
(acc, k) => {
|
||||
acc[k] = values[k]
|
||||
return acc
|
||||
},
|
||||
{}
|
||||
)
|
||||
// Reorder sub objects to be the first entries
|
||||
values = {
|
||||
...subObjectsValues,
|
||||
...values,
|
||||
}
|
||||
}
|
||||
super(values, suppressWarns)
|
||||
/** @type {ObjectReferenceEntity} */ this.Class
|
||||
/** @type {String} */ this.Name
|
||||
@@ -302,7 +319,7 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @type {String?} */ this.ErrorMsg
|
||||
/** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties
|
||||
|
||||
// Legacy objects transform into pins
|
||||
// Legacy nodes cleanup
|
||||
if (this["Pins"] instanceof Array) {
|
||||
this["Pins"]
|
||||
.forEach(
|
||||
@@ -315,15 +332,13 @@ export default class ObjectEntity extends IEntity {
|
||||
this.CustomProperties.push(pinEntity)
|
||||
}
|
||||
})
|
||||
delete this["Pins"]
|
||||
}
|
||||
|
||||
// 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]
|
||||
}
|
||||
this.Class.sanitize()
|
||||
if (this.MacroGraphReference) {
|
||||
this.MacroGraphReference.MacroGraph?.sanitize()
|
||||
this.MacroGraphReference.GraphBlueprint?.sanitize()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,6 +432,11 @@ export default class ObjectEntity extends IEntity {
|
||||
this.NodePosY.value = Math.round(value)
|
||||
}
|
||||
|
||||
/** @returns {PinEntity[]} */
|
||||
getPinEntities() {
|
||||
return this.CustomProperties.filter(v => v instanceof PinEntity)
|
||||
}
|
||||
|
||||
isEvent() {
|
||||
switch (this.getClass()) {
|
||||
case Configuration.nodeType.customEvent:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import IEntity from "./IEntity.js"
|
||||
|
||||
@@ -27,6 +28,20 @@ export default class ObjectReferenceEntity extends IEntity {
|
||||
/** @type {String} */ this.path
|
||||
}
|
||||
|
||||
sanitize() {
|
||||
if (this.type && !this.type.startsWith("/")) {
|
||||
let deprecatedType = this.type + "_Deprecated"
|
||||
let nodeType = Object.keys(Configuration.nodeType)
|
||||
.find(type => {
|
||||
const name = Utility.getNameFromPath(Configuration.nodeType[type])
|
||||
return name === this.type || name === deprecatedType
|
||||
})
|
||||
if (nodeType) {
|
||||
this.type = Configuration.nodeType[nodeType]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getName() {
|
||||
return Utility.getNameFromPath(this.path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user