mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-20 05:24:52 +08:00
Dropdown implementation, switch refactoring
* Various fixes * Fix tests * Dropdown names deduced from pin names * Remove update callbacks * Fix double pins issue * return undefined if not switch
This commit is contained in:
@@ -81,7 +81,7 @@ export default class IEntity {
|
||||
|
||||
if (!suppressWarns) {
|
||||
if (!(attributeName in attributes)) {
|
||||
const typeName = value instanceof Array ? `[${value[0].constructor.name}]` : value.constructor.name
|
||||
const typeName = value instanceof Array ? `[${value[0]?.constructor.name}]` : value.constructor.name
|
||||
console.warn(
|
||||
`UEBlueprint: Attribute ${attributeName} (of type ${typeName}) in the serialized data is not `
|
||||
+ `defined in ${Self.name}.attributes`
|
||||
|
||||
@@ -90,6 +90,11 @@ export default class ObjectEntity extends IEntity {
|
||||
type: ObjectReferenceEntity,
|
||||
showDefault: false,
|
||||
},
|
||||
EnumEntries: {
|
||||
type: [String],
|
||||
showDefault: false,
|
||||
inlined: true,
|
||||
},
|
||||
InputKey: {
|
||||
type: SymbolEntity,
|
||||
showDefault: false,
|
||||
@@ -293,6 +298,7 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @type {ObjectReferenceEntity?} */ this.TargetType
|
||||
/** @type {MacroGraphReferenceEntity?} */ this.MacroGraphReference
|
||||
/** @type {ObjectReferenceEntity?} */ this.Enum
|
||||
/** @type {String[]?} */ this.EnumEntries
|
||||
/** @type {SymbolEntity?} */ this.InputKey
|
||||
/** @type {Boolean?} */ this.bOverrideFunction
|
||||
/** @type {Boolean?} */ this.bInternalEvent
|
||||
@@ -434,7 +440,14 @@ export default class ObjectEntity extends IEntity {
|
||||
|
||||
/** @returns {PinEntity[]} */
|
||||
getPinEntities() {
|
||||
return this.CustomProperties.filter(v => v instanceof PinEntity)
|
||||
return this.CustomProperties.filter(v => v.constructor === PinEntity)
|
||||
}
|
||||
|
||||
switchTarget() {
|
||||
const switchMatch = this.getClass().match(Configuration.switchTargetPattern)
|
||||
if (switchMatch) {
|
||||
return switchMatch[1]
|
||||
}
|
||||
}
|
||||
|
||||
isEvent() {
|
||||
@@ -496,11 +509,20 @@ export default class ObjectEntity extends IEntity {
|
||||
)}`
|
||||
case Configuration.nodeType.switchEnum:
|
||||
return `Switch on ${this.Enum?.getName() ?? "Enum"}`
|
||||
case Configuration.nodeType.switchInteger:
|
||||
return `Switch on Int`
|
||||
case Configuration.nodeType.variableGet:
|
||||
return ""
|
||||
case Configuration.nodeType.variableSet:
|
||||
return "SET"
|
||||
}
|
||||
let switchTarget = this.switchTarget()
|
||||
if (switchTarget) {
|
||||
if (switchTarget[0] !== "E") {
|
||||
switchTarget = Utility.formatStringName(switchTarget)
|
||||
}
|
||||
return `Switch on ${switchTarget}`
|
||||
}
|
||||
const keyNameSymbol = this.getHIDAttribute()
|
||||
if (keyNameSymbol) {
|
||||
const keyName = keyNameSymbol.toString()
|
||||
@@ -535,7 +557,7 @@ export default class ObjectEntity extends IEntity {
|
||||
switch (memberParent) {
|
||||
case "/Script/Engine.KismetMathLibrary":
|
||||
if (memberName.startsWith("Conv_")) {
|
||||
return "" // Conversion nodes do not have visible names
|
||||
return "" // Conversion nodes do not have visible names
|
||||
}
|
||||
if (memberName.startsWith("Percent_")) {
|
||||
return "%"
|
||||
@@ -602,8 +624,9 @@ export default class ObjectEntity extends IEntity {
|
||||
return Configuration.nodeColors.gray
|
||||
case Configuration.nodeType.dynamicCast:
|
||||
return Configuration.nodeColors.turquoise
|
||||
case Configuration.nodeType.switchEnum:
|
||||
return Configuration.nodeColors.lime
|
||||
}
|
||||
if (this.switchTarget()) {
|
||||
return Configuration.nodeColors.lime
|
||||
}
|
||||
if (this.isEvent()) {
|
||||
return Configuration.nodeColors.red
|
||||
@@ -645,7 +668,9 @@ export default class ObjectEntity extends IEntity {
|
||||
case Configuration.nodeType.makeSet: return SVGIcon.makeSet
|
||||
case Configuration.nodeType.select: return SVGIcon.select
|
||||
case Configuration.nodeType.spawnActorFromClass: return SVGIcon.spawnActor
|
||||
case Configuration.nodeType.switchEnum: return SVGIcon.switch
|
||||
}
|
||||
if (this.switchTarget()) {
|
||||
return SVGIcon.switch
|
||||
}
|
||||
if (this.nodeDisplayName().startsWith("Break")) {
|
||||
return SVGIcon.breakStruct
|
||||
|
||||
@@ -31,10 +31,10 @@ import VectorEntity from "./VectorEntity.js"
|
||||
export default class PinEntity extends IEntity {
|
||||
|
||||
static #typeEntityMap = {
|
||||
"/Script/CoreUObject.LinearColor": LinearColorEntity,
|
||||
"/Script/CoreUObject.Rotator": RotatorEntity,
|
||||
"/Script/CoreUObject.Vector": VectorEntity,
|
||||
"/Script/CoreUObject.Vector2D": Vector2DEntity,
|
||||
[Configuration.nodeType.linearColor]: LinearColorEntity,
|
||||
[Configuration.nodeType.rotator]: RotatorEntity,
|
||||
[Configuration.nodeType.vector]: VectorEntity,
|
||||
[Configuration.nodeType.vector2D]: Vector2DEntity,
|
||||
"bool": Boolean,
|
||||
"byte": ByteEntity,
|
||||
"enum": EnumEntity,
|
||||
@@ -46,9 +46,9 @@ export default class PinEntity extends IEntity {
|
||||
"string": String,
|
||||
}
|
||||
static #alternativeTypeEntityMap = {
|
||||
"/Script/CoreUObject.Vector2D": SimpleSerializationVector2DEntity,
|
||||
"/Script/CoreUObject.Vector": SimpleSerializationVectorEntity,
|
||||
"/Script/CoreUObject.Rotator": SimpleSerializationRotatorEntity,
|
||||
[Configuration.nodeType.vector2D]: SimpleSerializationVector2DEntity,
|
||||
[Configuration.nodeType.vector]: SimpleSerializationVectorEntity,
|
||||
[Configuration.nodeType.rotator]: SimpleSerializationRotatorEntity,
|
||||
}
|
||||
static lookbehind = "Pin"
|
||||
static attributes = {
|
||||
|
||||
Reference in New Issue
Block a user