mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-17 05:47:34 +08:00
SVGIcon class, Macro reference entity
This commit is contained in:
@@ -13,7 +13,7 @@ export default class IEntity extends Observable {
|
||||
|
||||
static attributes = {}
|
||||
|
||||
constructor(values) {
|
||||
constructor(values = {}) {
|
||||
super()
|
||||
/**
|
||||
* @param {Object} target
|
||||
|
||||
@@ -15,4 +15,12 @@ export default class LocalizedTextEntity extends IEntity {
|
||||
/** @type {String} */ this.key
|
||||
/** @type {String} */ this.value
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.value.length === 0) {
|
||||
return this.value
|
||||
}
|
||||
let result = this.value
|
||||
return result.charAt(0).toLocaleUpperCase() + result.slice(1).toLocaleLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
24
js/entity/MacroGraphReferenceEntity.js
Executable file
24
js/entity/MacroGraphReferenceEntity.js
Executable file
@@ -0,0 +1,24 @@
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import IEntity from "./IEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
|
||||
export default class MacroGraphReferenceEntity extends IEntity {
|
||||
|
||||
static attributes = {
|
||||
MacroGraph: ObjectReferenceEntity,
|
||||
GraphBlueprint: ObjectReferenceEntity,
|
||||
GraphGuid: GuidEntity,
|
||||
}
|
||||
|
||||
constructor(options = {}) {
|
||||
super(options)
|
||||
/** @type {ObjectReferenceEntity} */ this.MacroGraph
|
||||
/** @type {ObjectReferenceEntity} */ this.GraphBlueprint
|
||||
/** @type {GuidEntity} */ this.GuidEntity
|
||||
}
|
||||
|
||||
getMacroName() {
|
||||
const colonIndex = this.MacroGraph.path.search(":")
|
||||
return this.MacroGraph.path.substring(colonIndex + 1)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import Configuration from "../Configuration"
|
||||
import FunctionReferenceEntity from "./FunctionReferenceEntity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import IdentifierEntity from "./IdentifierEntity"
|
||||
import IEntity from "./IEntity"
|
||||
import IntegerEntity from "./IntegerEntity"
|
||||
import MacroGraphReferenceEntity from "./MacroGraphReferenceEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinEntity from "./PinEntity"
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
@@ -19,6 +21,7 @@ export default class ObjectEntity extends IEntity {
|
||||
FunctionReference: new TypeInitialization(FunctionReferenceEntity, false, null,),
|
||||
EventReference: new TypeInitialization(FunctionReferenceEntity, false, null,),
|
||||
TargetType: new TypeInitialization(ObjectReferenceEntity, false, null),
|
||||
MacroGraphReference: new TypeInitialization(MacroGraphReferenceEntity, false, null),
|
||||
NodePosX: IntegerEntity,
|
||||
NodePosY: IntegerEntity,
|
||||
AdvancedPinDisplay: new TypeInitialization(IdentifierEntity, false, null),
|
||||
@@ -29,7 +32,7 @@ export default class ObjectEntity extends IEntity {
|
||||
CustomProperties: [PinEntity],
|
||||
}
|
||||
|
||||
static nameRegex = /(\w+)_(\d+)/
|
||||
static nameRegex = /(\w+)(?:_(\d+))?/
|
||||
|
||||
constructor(options = {}) {
|
||||
super(options)
|
||||
@@ -40,6 +43,7 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @type {FunctionReferenceEntity?} */ this.FunctionReference
|
||||
/** @type {FunctionReferenceEntity?} */ this.EventReference
|
||||
/** @type {ObjectReferenceEntity?} */ this.TargetType
|
||||
/** @type {MacroGraphReferenceEntity?} */ this.MacroGraphReference
|
||||
/** @type {IntegerEntity} */ this.NodePosX
|
||||
/** @type {IntegerEntity} */ this.NodePosY
|
||||
/** @type {IdentifierEntity?} */ this.AdvancedPinDisplay
|
||||
@@ -54,6 +58,14 @@ export default class ObjectEntity extends IEntity {
|
||||
return this.Class.path
|
||||
}
|
||||
|
||||
getType() {
|
||||
let classValue = this.getClass()
|
||||
if (classValue === Configuration.nodeType.macro) {
|
||||
return this.MacroGraphReference.GraphBlueprint.path
|
||||
}
|
||||
return classValue
|
||||
}
|
||||
|
||||
getObjectName(dropCounter = false) {
|
||||
if (dropCounter) {
|
||||
return this.getNameAndCounter()[0]
|
||||
@@ -64,20 +76,34 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @returns {[String, Number]} */
|
||||
getNameAndCounter() {
|
||||
const result = this.getObjectName(false).match(ObjectEntity.nameRegex)
|
||||
if (result && result.length == 3) {
|
||||
return [result[1], parseInt(result[2])]
|
||||
let name = ""
|
||||
let counter = null
|
||||
if (result) {
|
||||
if (result.length > 1) {
|
||||
name = result[1]
|
||||
}
|
||||
if (result.length > 2) {
|
||||
counter = parseInt(result[2])
|
||||
}
|
||||
return [name, counter]
|
||||
}
|
||||
return ["", 0]
|
||||
}
|
||||
|
||||
getDisplayName() {
|
||||
let name = this.FunctionReference?.MemberName
|
||||
if (name) {
|
||||
name = Utility.formatStringName(name)
|
||||
return name
|
||||
let name = ""
|
||||
switch (this.getClass()) {
|
||||
case Configuration.nodeType.function:
|
||||
name = this.FunctionReference.MemberName
|
||||
break
|
||||
case Configuration.nodeType.macro:
|
||||
name = this.MacroGraphReference.getMacroName()
|
||||
break
|
||||
default:
|
||||
name = this.getNameAndCounter()[0]
|
||||
break
|
||||
}
|
||||
name = Utility.formatStringName(this.getNameAndCounter()[0])
|
||||
return name
|
||||
return Utility.formatStringName(name)
|
||||
}
|
||||
|
||||
getCounter() {
|
||||
|
||||
@@ -123,6 +123,21 @@ export default class PinEntity extends IEntity {
|
||||
return this.PinType.PinCategory
|
||||
}
|
||||
|
||||
/** @param {PinEntity} other */
|
||||
copyTypeFrom(other) {
|
||||
this.PinType.PinCategory = other.PinType.PinCategory
|
||||
this.PinType.PinSubCategory = other.PinType.PinSubCategory
|
||||
this.PinType.PinSubCategoryObject = other.PinType.PinSubCategoryObject
|
||||
this.PinType.PinSubCategoryMemberReference = other.PinType.PinSubCategoryMemberReference
|
||||
this.PinType.PinValueType = other.PinType.PinValueType
|
||||
this.PinType.ContainerType = other.PinType.ContainerType
|
||||
this.PinType.bIsReference = other.PinType.bIsReference
|
||||
this.PinType.bIsConst = other.PinType.bIsConst
|
||||
this.PinType.bIsWeakPointer = other.PinType.bIsWeakPointer
|
||||
this.PinType.bIsUObjectWrapper = other.PinType.bIsUObjectWrapper
|
||||
this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat
|
||||
}
|
||||
|
||||
getDefaultValue() {
|
||||
return this.DefaultValue
|
||||
}
|
||||
|
||||
@@ -4,18 +4,25 @@ import PinEntity from "../PinEntity"
|
||||
|
||||
export default class KnotEntity extends ObjectEntity {
|
||||
|
||||
constructor(options = {}, pinType = undefined) {
|
||||
/**
|
||||
* @param {Object} options
|
||||
* @param {PinEntity} pinReferenceForType
|
||||
*/
|
||||
constructor(options = {}, pinReferenceForType = undefined) {
|
||||
super(options)
|
||||
this.Class = new ObjectReferenceEntity("/Script/BlueprintGraph.K2Node_Knot")
|
||||
this.Name = "K2Node_Knot"
|
||||
this.CustomProperties = [
|
||||
new PinEntity({
|
||||
PinName: "InputPin",
|
||||
}),
|
||||
new PinEntity({
|
||||
PinName: "OutputPin",
|
||||
Direction: "EGPD_Output",
|
||||
})
|
||||
]
|
||||
const inputPinEntity = new PinEntity({
|
||||
PinName: "InputPin",
|
||||
})
|
||||
const outputPinEntity = new PinEntity({
|
||||
PinName: "OutputPin",
|
||||
Direction: "EGPD_Output",
|
||||
})
|
||||
if (pinReferenceForType) {
|
||||
inputPinEntity.copyTypeFrom(pinReferenceForType)
|
||||
outputPinEntity.copyTypeFrom(pinReferenceForType)
|
||||
}
|
||||
this.CustomProperties = [inputPinEntity, outputPinEntity]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user