mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-15 17:54:52 +08:00
Move entities decode methods to entities
This commit is contained in:
@@ -8,7 +8,9 @@ import LinearColorEntity from "./LinearColorEntity"
|
||||
import MacroGraphReferenceEntity from "./MacroGraphReferenceEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinEntity from "./PinEntity"
|
||||
import SVGIcon from "../SVGIcon"
|
||||
import SymbolEntity from "./SymbolEntity"
|
||||
import Utility from "../Utility"
|
||||
import VariableReferenceEntity from "./VariableReferenceEntity"
|
||||
|
||||
export default class ObjectEntity extends IEntity {
|
||||
@@ -186,11 +188,42 @@ export default class ObjectEntity extends IEntity {
|
||||
|
||||
static nameRegex = /^(\w+?)(?:_(\d+))?$/
|
||||
static sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/
|
||||
static #keyName = {
|
||||
"A_AccentGrave": "à",
|
||||
"E_AccentGrave": "è",
|
||||
"E_AccentAigu": "é",
|
||||
"Add": "Num +",
|
||||
"Decimal": "Num .",
|
||||
"Divide": "Num /",
|
||||
"Multiply": "Num *",
|
||||
"Subtract": "Num -",
|
||||
"Section": "§",
|
||||
"C_Cedille": "ç",
|
||||
}
|
||||
|
||||
static {
|
||||
this.cleanupAttributes(this.attributes)
|
||||
}
|
||||
|
||||
/** @param {String} value */
|
||||
static keyName(value) {
|
||||
let result = ObjectEntity.#keyName[value]
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
result = Utility.numberFromText(value)?.toString()
|
||||
if (result) {
|
||||
return result
|
||||
}
|
||||
const match = value.match(/NumPad([a-zA-Z]+)/)
|
||||
if (match) {
|
||||
result = Utility.numberFromText(match[1])
|
||||
if (result) {
|
||||
return "Num " + result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor(values, suppressWarns = false) {
|
||||
super(values, suppressWarns)
|
||||
/** @type {ObjectReferenceEntity} */ this.Class
|
||||
@@ -315,13 +348,178 @@ export default class ObjectEntity extends IEntity {
|
||||
this.NodePosY.value = Math.round(value)
|
||||
}
|
||||
|
||||
isEvent() {
|
||||
if (
|
||||
this.getClass() === Configuration.nodeType.event
|
||||
|| this.getClass() === Configuration.nodeType.customEvent
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (this.getDelegatePin()) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
isDevelopmentOnly() {
|
||||
const nodeClass = this.getClass()
|
||||
return this.EnabledState?.toString() === "DevelopmentOnly"
|
||||
|| nodeClass.includes("Debug", Math.max(0, nodeClass.lastIndexOf(".")))
|
||||
}
|
||||
|
||||
hasHIDAttribute() {
|
||||
return this.InputKey ?? this.AxisKey ?? this.InputAxisKey
|
||||
}
|
||||
|
||||
getDelegatePin() {
|
||||
return this.CustomProperties?.find(pin => pin.PinType.PinCategory === "delegate")
|
||||
}
|
||||
|
||||
nodeDisplayName() {
|
||||
switch (this.getType()) {
|
||||
case Configuration.nodeType.callFunction:
|
||||
case Configuration.nodeType.commutativeAssociativeBinaryOperator:
|
||||
let memberName = this.FunctionReference.MemberName ?? ""
|
||||
const memberParent = this.FunctionReference.MemberParent?.path ?? ""
|
||||
if (memberName === "AddKey") {
|
||||
let result = memberParent.match(ObjectEntity.sequencerScriptingNameRegex)
|
||||
if (result) {
|
||||
return `Add Key (${Utility.formatStringName(result[1])})`
|
||||
}
|
||||
}
|
||||
if (memberParent == "/Script/Engine.KismetMathLibrary") {
|
||||
if (memberName.startsWith("Conv_")) {
|
||||
return "" // Conversion nodes do not have visible names
|
||||
}
|
||||
if (memberName.startsWith("Percent_")) {
|
||||
return "%"
|
||||
}
|
||||
const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/)
|
||||
if (leadingLetter) {
|
||||
// Some functions start with B or F (Like FCeil, FMax, BMin)
|
||||
memberName = leadingLetter[1]
|
||||
}
|
||||
switch (memberName) {
|
||||
case "Abs": return "ABS"
|
||||
case "Exp": return "e"
|
||||
case "Max": return "MAX"
|
||||
case "MaxInt64": return "MAX"
|
||||
case "Min": return "MIN"
|
||||
case "MinInt64": return "MIN"
|
||||
}
|
||||
}
|
||||
if (memberParent === "/Script/Engine.BlueprintSetLibrary") {
|
||||
const setOperationMatch = memberName.match(/Set_(\w+)/)
|
||||
if (setOperationMatch) {
|
||||
return Utility.formatStringName(setOperationMatch[1]).toUpperCase()
|
||||
}
|
||||
}
|
||||
if (memberParent === "/Script/Engine.BlueprintMapLibrary") {
|
||||
const setOperationMatch = memberName.match(/Map_(\w+)/)
|
||||
if (setOperationMatch) {
|
||||
return Utility.formatStringName(setOperationMatch[1]).toUpperCase()
|
||||
}
|
||||
}
|
||||
return Utility.formatStringName(memberName)
|
||||
case Configuration.nodeType.dynamicCast:
|
||||
return `Cast To ${this.TargetType.getName()}`
|
||||
case Configuration.nodeType.event:
|
||||
return `Event ${(this.EventReference?.MemberName ?? "").replace(/^Receive/, "")}`
|
||||
case Configuration.nodeType.executionSequence:
|
||||
return "Sequence"
|
||||
case Configuration.nodeType.forEachElementInEnum:
|
||||
return `For Each ${this.Enum.getName()}`
|
||||
case Configuration.nodeType.forEachLoopWithBreak:
|
||||
return "For Each Loop with Break"
|
||||
case Configuration.nodeType.ifThenElse:
|
||||
return "Branch"
|
||||
case Configuration.nodeType.variableGet:
|
||||
return ""
|
||||
case Configuration.nodeType.variableSet:
|
||||
return "SET"
|
||||
}
|
||||
const keyNameSymbol = this.hasHIDAttribute()
|
||||
if (keyNameSymbol) {
|
||||
const keyName = keyNameSymbol.toString()
|
||||
let title = ObjectEntity.keyName(keyName) ?? Utility.formatStringName(keyName)
|
||||
if (this.getClass() === Configuration.nodeType.inputDebugKey) {
|
||||
title = "Debug Key " + title
|
||||
}
|
||||
return title
|
||||
}
|
||||
if (this.getClass() === Configuration.nodeType.macro) {
|
||||
return Utility.formatStringName(this.MacroGraphReference.getMacroName())
|
||||
} else {
|
||||
return Utility.formatStringName(this.getNameAndCounter()[0])
|
||||
}
|
||||
}
|
||||
|
||||
nodeColor() {
|
||||
switch (this.getClass()) {
|
||||
case Configuration.nodeType.callFunction:
|
||||
return this.bIsPureFunc
|
||||
? Configuration.nodeColors.green
|
||||
: Configuration.nodeColors.blue
|
||||
case Configuration.nodeType.event:
|
||||
case Configuration.nodeType.customEvent:
|
||||
case Configuration.nodeType.inputKey:
|
||||
case Configuration.nodeType.inputAxisKeyEvent:
|
||||
case Configuration.nodeType.inputDebugKey:
|
||||
return Configuration.nodeColors.red
|
||||
case Configuration.nodeType.makeArray:
|
||||
case Configuration.nodeType.makeMap:
|
||||
case Configuration.nodeType.select:
|
||||
return Configuration.nodeColors.green
|
||||
case Configuration.nodeType.executionSequence:
|
||||
case Configuration.nodeType.ifThenElse:
|
||||
case Configuration.nodeType.macro:
|
||||
return Configuration.nodeColors.gray
|
||||
case Configuration.nodeType.dynamicCast:
|
||||
return Configuration.nodeColors.turquoise
|
||||
}
|
||||
if (this.bIsPureFunc) {
|
||||
return Configuration.nodeColors.green
|
||||
}
|
||||
if (this.isEvent()) {
|
||||
return Configuration.nodeColors.red
|
||||
}
|
||||
return Configuration.nodeColors.blue
|
||||
}
|
||||
|
||||
nodeIcon() {
|
||||
switch (this.getType()) {
|
||||
case Configuration.nodeType.doN: return SVGIcon.doN
|
||||
case Configuration.nodeType.dynamicCast: return SVGIcon.cast
|
||||
case Configuration.nodeType.event:
|
||||
case Configuration.nodeType.customEvent:
|
||||
return SVGIcon.event
|
||||
case Configuration.nodeType.executionSequence: return SVGIcon.sequence
|
||||
case Configuration.nodeType.forEachElementInEnum: return SVGIcon.loop
|
||||
case Configuration.nodeType.forEachLoop: return SVGIcon.forEachLoop
|
||||
case Configuration.nodeType.forEachLoopWithBreak: return SVGIcon.forEachLoop
|
||||
case Configuration.nodeType.forLoop: return SVGIcon.loop
|
||||
case Configuration.nodeType.forLoopWithBreak: return SVGIcon.loop
|
||||
case Configuration.nodeType.ifThenElse: return SVGIcon.branchNode
|
||||
case Configuration.nodeType.makeArray: return SVGIcon.makeArray
|
||||
case Configuration.nodeType.makeMap: return SVGIcon.makeMap
|
||||
case Configuration.nodeType.makeSet: return SVGIcon.makeSet
|
||||
case Configuration.nodeType.select: return SVGIcon.select
|
||||
case Configuration.nodeType.whileLoop: return SVGIcon.loop
|
||||
}
|
||||
if (this.nodeDisplayName().startsWith("Break")) {
|
||||
return SVGIcon.breakStruct
|
||||
}
|
||||
if (this.getClass() === Configuration.nodeType.macro) {
|
||||
return SVGIcon.macro
|
||||
}
|
||||
const hidValue = this.hasHIDAttribute()
|
||||
if (hidValue) {
|
||||
if (hidValue.toString().includes("Mouse")) {
|
||||
return SVGIcon.mouse
|
||||
} else {
|
||||
return SVGIcon.keyboard
|
||||
}
|
||||
}
|
||||
return SVGIcon.functionSymbol
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user