mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 15:18:58 +08:00
Attributes initialization refactoring (#19)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import AttributeInfo from "./AttributeInfo.js"
|
||||
import ByteEntity from "./ByteEntity.js"
|
||||
import ComputedType from "./ComputedType.js"
|
||||
import Configuration from "../Configuration.js"
|
||||
import EnumDisplayValueEntity from "./EnumDisplayValueEntity.js"
|
||||
import EnumEntity from "./EnumEntity.js"
|
||||
import FormatTextEntity from "./FormatTextEntity.js"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import GuidEntity from "./GuidEntity.js"
|
||||
import IEntity from "./IEntity.js"
|
||||
import Integer64Entity from "./Integer64Entity.js"
|
||||
@@ -20,7 +22,6 @@ import SimpleSerializationRotatorEntity from "./SimpleSerializationRotatorEntity
|
||||
import SimpleSerializationVector2DEntity from "./SimpleSerializationVector2DEntity.js"
|
||||
import SimpleSerializationVectorEntity from "./SimpleSerializationVectorEntity.js"
|
||||
import Union from "./Union.js"
|
||||
import Utility from "../Utility.js"
|
||||
import Vector2DEntity from "./Vector2DEntity.js"
|
||||
import VectorEntity from "./VectorEntity.js"
|
||||
|
||||
@@ -49,86 +50,62 @@ export default class PinEntity extends IEntity {
|
||||
[Configuration.paths.vector]: SimpleSerializationVectorEntity,
|
||||
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity,
|
||||
}
|
||||
static lookbehind = "Pin"
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
objectEntity: {
|
||||
lookbehind: new AttributeInfo({
|
||||
default: "Pin",
|
||||
ignored: true,
|
||||
},
|
||||
pinIndex: {
|
||||
}),
|
||||
objectEntity: new AttributeInfo({
|
||||
ignored: true,
|
||||
}),
|
||||
pinIndex: new AttributeInfo({
|
||||
type: Number,
|
||||
ignored: true,
|
||||
},
|
||||
PinId: {
|
||||
}),
|
||||
PinId: new AttributeInfo({
|
||||
type: GuidEntity,
|
||||
default: () => new GuidEntity()
|
||||
},
|
||||
PinName: {
|
||||
default: "",
|
||||
},
|
||||
PinFriendlyName: {
|
||||
type: new Union(LocalizedTextEntity, FormatTextEntity, String),
|
||||
},
|
||||
PinToolTip: {
|
||||
type: String,
|
||||
},
|
||||
Direction: {
|
||||
type: String,
|
||||
},
|
||||
PinType: {
|
||||
}),
|
||||
PinName: AttributeInfo.createValue(""),
|
||||
PinFriendlyName: AttributeInfo.createType(new Union(LocalizedTextEntity, FormatTextEntity, String)),
|
||||
PinToolTip: AttributeInfo.createType(String),
|
||||
Direction: AttributeInfo.createType(String),
|
||||
PinType: new AttributeInfo({
|
||||
type: PinTypeEntity,
|
||||
default: () => new PinTypeEntity(),
|
||||
inlined: true,
|
||||
},
|
||||
LinkedTo: {
|
||||
type: [PinReferenceEntity],
|
||||
},
|
||||
SubPins: {
|
||||
type: [PinReferenceEntity],
|
||||
},
|
||||
ParentPin: {
|
||||
type: PinReferenceEntity,
|
||||
},
|
||||
DefaultValue: {
|
||||
}),
|
||||
LinkedTo: AttributeInfo.createType([PinReferenceEntity]),
|
||||
SubPins: AttributeInfo.createType([PinReferenceEntity]),
|
||||
ParentPin: AttributeInfo.createType(PinReferenceEntity),
|
||||
DefaultValue: new AttributeInfo({
|
||||
type: new ComputedType(
|
||||
/** @param {PinEntity} pinEntity */
|
||||
pinEntity => pinEntity.getEntityType(true) ?? String
|
||||
),
|
||||
serialized: true,
|
||||
},
|
||||
AutogeneratedDefaultValue: {
|
||||
type: String,
|
||||
},
|
||||
DefaultObject: {
|
||||
type: ObjectReferenceEntity,
|
||||
},
|
||||
PersistentGuid: {
|
||||
type: GuidEntity,
|
||||
},
|
||||
bHidden: {
|
||||
default: false,
|
||||
},
|
||||
bNotConnectable: {
|
||||
default: false,
|
||||
},
|
||||
bDefaultValueIsReadOnly: {
|
||||
default: false,
|
||||
},
|
||||
bDefaultValueIsIgnored: {
|
||||
default: false,
|
||||
},
|
||||
bAdvancedView: {
|
||||
default: false,
|
||||
},
|
||||
bOrphanedPin: {
|
||||
default: false,
|
||||
},
|
||||
}
|
||||
static {
|
||||
this.cleanupAttributes(this.attributes)
|
||||
}),
|
||||
AutogeneratedDefaultValue: AttributeInfo.createType(String),
|
||||
DefaultObject: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
PersistentGuid: AttributeInfo.createType(GuidEntity),
|
||||
bHidden: AttributeInfo.createValue(false),
|
||||
bNotConnectable: AttributeInfo.createValue(false),
|
||||
bDefaultValueIsReadOnly: AttributeInfo.createValue(false),
|
||||
bDefaultValueIsIgnored: AttributeInfo.createValue(false),
|
||||
bAdvancedView: AttributeInfo.createValue(false),
|
||||
bOrphanedPin: AttributeInfo.createValue(false),
|
||||
}
|
||||
static grammar = this.createGrammar()
|
||||
|
||||
#recomputesNodeTitleOnChange = false
|
||||
set recomputesNodeTitleOnChange(value) {
|
||||
this.#recomputesNodeTitleOnChange = value
|
||||
}
|
||||
get recomputesNodeTitleOnChange() {
|
||||
return this.#recomputesNodeTitleOnChange
|
||||
}
|
||||
|
||||
static createGrammar() {
|
||||
return Grammar.createEntityGrammar(this)
|
||||
}
|
||||
@@ -166,20 +143,6 @@ export default class PinEntity extends IEntity {
|
||||
if (category === "struct" || category === "object") {
|
||||
return this.PinType.PinSubCategoryObject.path
|
||||
}
|
||||
if (category === "optional") {
|
||||
switch (this.PinType.PinSubCategory) {
|
||||
case "int":
|
||||
return "int"
|
||||
case "red":
|
||||
return "real"
|
||||
case "rg":
|
||||
return "rg"
|
||||
case "rgb":
|
||||
return Configuration.paths.vector
|
||||
case "rgba":
|
||||
return Configuration.paths.linearColor
|
||||
}
|
||||
}
|
||||
if (this.isEnum()) {
|
||||
return "enum"
|
||||
}
|
||||
@@ -209,6 +172,20 @@ export default class PinEntity extends IEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (category === "optional") {
|
||||
switch (this.PinType.PinSubCategory) {
|
||||
case "red":
|
||||
return "real"
|
||||
case "rg":
|
||||
return "rg"
|
||||
case "rgb":
|
||||
return Configuration.paths.vector
|
||||
case "rgba":
|
||||
return Configuration.paths.linearColor
|
||||
default:
|
||||
return this.PinType.PinSubCategory
|
||||
}
|
||||
}
|
||||
return category
|
||||
}
|
||||
|
||||
@@ -291,6 +268,7 @@ export default class PinEntity extends IEntity {
|
||||
/**
|
||||
* @param {String} targetObjectName
|
||||
* @param {PinEntity} targetPinEntity
|
||||
* @returns true if it was not already linked to the tarket
|
||||
*/
|
||||
linkTo(targetObjectName, targetPinEntity) {
|
||||
const linkFound = this.LinkedTo?.some(pinReferenceEntity =>
|
||||
@@ -310,6 +288,7 @@ export default class PinEntity extends IEntity {
|
||||
/**
|
||||
* @param {String} targetObjectName
|
||||
* @param {PinEntity} targetPinEntity
|
||||
* @returns true if it was linked to the target
|
||||
*/
|
||||
unlinkFrom(targetObjectName, targetPinEntity) {
|
||||
const indexElement = this.LinkedTo?.findIndex(pinReferenceEntity => {
|
||||
|
||||
Reference in New Issue
Block a user