mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 10:44:43 +08:00
Refactoring and bugfixing
This commit is contained in:
@@ -33,6 +33,12 @@ export default class Entity {
|
||||
continue
|
||||
}
|
||||
let defaultValue = properties[property]
|
||||
if (defaultValue instanceof TypeInitialization) {
|
||||
if (!defaultValue.showDefault) {
|
||||
continue
|
||||
}
|
||||
defaultValue = defaultValue.value
|
||||
}
|
||||
if (defaultValue instanceof Array) {
|
||||
propertySetter(target, property, [])
|
||||
defineAllAttributes(
|
||||
@@ -42,12 +48,6 @@ export default class Entity {
|
||||
(t, _, v) => t.push(v))
|
||||
continue
|
||||
}
|
||||
if (defaultValue instanceof TypeInitialization) {
|
||||
if (!defaultValue.showDefault) {
|
||||
continue
|
||||
}
|
||||
defaultValue = defaultValue.value
|
||||
}
|
||||
if (defaultValue instanceof Function) {
|
||||
defaultValue = Utility.sanitize(new defaultValue())
|
||||
}
|
||||
|
||||
37
js/entity/GuidEntity.js
Normal file
37
js/entity/GuidEntity.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import Entity from "./Entity";
|
||||
|
||||
export default class GuidEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
value: String
|
||||
}
|
||||
|
||||
static generateGuid(random) {
|
||||
let values = new Uint32Array(4);
|
||||
if (random === true) {
|
||||
crypto.getRandomValues(values)
|
||||
}
|
||||
let result = ""
|
||||
values.forEach(n => {
|
||||
result += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
if (guid?.constructor === String) {
|
||||
guid = {
|
||||
value: guid
|
||||
}
|
||||
} else if (guid?.constructor === Boolean) {
|
||||
guid = {
|
||||
value: GuidEntity.generateGuid(guid == true)
|
||||
}
|
||||
}
|
||||
super(guid)
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
return GuidEntity.attributes
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import FunctionReferenceEntity from "./FunctionReferenceEntity"
|
||||
import Guid from "../Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import Integer from "./Integer"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinEntity from "./PinEntity"
|
||||
@@ -18,7 +18,7 @@ export default class ObjectEntity extends Entity {
|
||||
TargetType: new TypeInitialization(new ObjectReferenceEntity(), false),
|
||||
NodePosX: Integer,
|
||||
NodePosY: Integer,
|
||||
NodeGuid: Guid,
|
||||
NodeGuid: GuidEntity,
|
||||
CustomProperties: [PinEntity]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import Entity from "./Entity";
|
||||
import Guid from "../Guid";
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity";
|
||||
import TypeInitialization from "./TypeInitialization";
|
||||
import LocalizedTextEntity from "./LocalizedTextEntity";
|
||||
import Entity from "./Entity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import LocalizedTextEntity from "./LocalizedTextEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
import PinReferenceEntity from "./PinReferenceEntity"
|
||||
|
||||
export default class PinEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
PinId: Guid,
|
||||
PinId: GuidEntity,
|
||||
PinName: "",
|
||||
PinFriendlyName: new TypeInitialization(new LocalizedTextEntity(), false),
|
||||
PinToolTip: "",
|
||||
@@ -23,10 +25,10 @@ export default class PinEntity extends Entity {
|
||||
bIsWeakPointer: false,
|
||||
bIsUObjectWrapper: false
|
||||
},
|
||||
LinkedTo: Guid,
|
||||
LinkedTo: [new TypeInitialization(null, false, PinReferenceEntity)],
|
||||
DefaultValue: "",
|
||||
AutogeneratedDefaultValue: "",
|
||||
PersistentGuid: Guid,
|
||||
PersistentGuid: GuidEntity,
|
||||
bHidden: false,
|
||||
bNotConnectable: false,
|
||||
bDefaultValueIsReadOnly: false,
|
||||
@@ -38,4 +40,10 @@ export default class PinEntity extends Entity {
|
||||
getAttributes() {
|
||||
return PinEntity.attributes
|
||||
}
|
||||
}
|
||||
|
||||
isOutput() {
|
||||
if (this.Direction === "EGPD_Output") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
14
js/entity/PinReferenceEntity.js
Normal file
14
js/entity/PinReferenceEntity.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import Entity from "./Entity"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
|
||||
export default class PinReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
objectName: String,
|
||||
pinGuid: GuidEntity
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
return PinReferenceEntity.attributes
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,6 @@ import Utility from "../Utility"
|
||||
|
||||
export default class TypeInitialization {
|
||||
constructor(value, showDefault = true, type = Utility.getType(value)) {
|
||||
if (type.prototype.constructor.name != value.constructor.name) {
|
||||
throw new Error("Default value expected to be of the same type.")
|
||||
}
|
||||
this.value = value
|
||||
this.showDefault = showDefault
|
||||
this.type = type
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Guid from "../Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import Entity from "./Entity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
|
||||
export default class VariableReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
MemberName: "",
|
||||
MemberGuid: Guid,
|
||||
MemberName: String,
|
||||
MemberGuid: GuidEntity,
|
||||
bSelfContext: true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user