mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-03 23:55:04 +08:00
Fixes #28
This commit is contained in:
@@ -106,6 +106,7 @@ export default class Configuration {
|
||||
callArrayFunction: "/Script/BlueprintGraph.K2Node_CallArrayFunction",
|
||||
callDelegate: "/Script/BlueprintGraph.K2Node_CallDelegate",
|
||||
callFunction: "/Script/BlueprintGraph.K2Node_CallFunction",
|
||||
clearDelegate: "/Script/BlueprintGraph.K2Node_ClearDelegate",
|
||||
comment: "/Script/UnrealEd.EdGraphNode_Comment",
|
||||
commutativeAssociativeBinaryOperator: "/Script/BlueprintGraph.K2Node_CommutativeAssociativeBinaryOperator",
|
||||
componentBoundEvent: "/Script/BlueprintGraph.K2Node_ComponentBoundEvent",
|
||||
@@ -192,6 +193,7 @@ export default class Configuration {
|
||||
pcgSubgraphSettings: "/Script/PCG.PCGSubgraphSettings",
|
||||
promotableOperator: "/Script/BlueprintGraph.K2Node_PromotableOperator",
|
||||
quat4f: "/Script/CoreUObject.Quat4f",
|
||||
removeDelegate: "/Script/BlueprintGraph.K2Node_RemoveDelegate",
|
||||
reverseForEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",
|
||||
rotator: "/Script/CoreUObject.Rotator",
|
||||
select: "/Script/BlueprintGraph.K2Node_Select",
|
||||
|
||||
@@ -11,9 +11,11 @@ export default function nodeIcon(entity) {
|
||||
case Configuration.paths.addDelegate:
|
||||
case Configuration.paths.asyncAction:
|
||||
case Configuration.paths.callDelegate:
|
||||
case Configuration.paths.clearDelegate:
|
||||
case Configuration.paths.createDelegate:
|
||||
case Configuration.paths.functionEntry:
|
||||
case Configuration.paths.functionResult:
|
||||
case Configuration.paths.removeDelegate:
|
||||
return SVGIcon.node
|
||||
case Configuration.paths.customEvent: return SVGIcon.event
|
||||
case Configuration.paths.doN: return SVGIcon.doN
|
||||
|
||||
25
js/decoding/nodeSubtitle.js
Normal file
25
js/decoding/nodeSubtitle.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import pinTitle from "./pinTitle.js"
|
||||
|
||||
/**
|
||||
* @param {ObjectEntity} entity
|
||||
* @returns {String?}
|
||||
*/
|
||||
export default function nodeSubtitle(entity) {
|
||||
switch (entity.getType()) {
|
||||
case Configuration.paths.addDelegate:
|
||||
case Configuration.paths.clearDelegate:
|
||||
return null
|
||||
}
|
||||
const targetPin = entity
|
||||
.getPinEntities()
|
||||
.find(pin => pin.PinName?.toString() === "self" && pinTitle(pin) === "Target")
|
||||
if (targetPin) {
|
||||
const target = entity.FunctionReference?.MemberParent?.getName()
|
||||
?? targetPin.PinType?.PinSubCategoryObject?.getName()
|
||||
?? "Untitled"
|
||||
return target.length > 0 ? `Target is ${Utility.formatStringName(target)}` : null
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -76,8 +76,17 @@ function keyName(value) {
|
||||
* @returns {String}
|
||||
*/
|
||||
export default function nodeTitle(entity) {
|
||||
let input
|
||||
let value
|
||||
switch (entity.getType()) {
|
||||
case Configuration.paths.addDelegate:
|
||||
value ??= "Bind Event to "
|
||||
case Configuration.paths.clearDelegate:
|
||||
value ??= "Unbind all Events from "
|
||||
case Configuration.paths.removeDelegate:
|
||||
value ??= "Unbind Event from "
|
||||
return value + Utility.formatStringName(
|
||||
entity.DelegateReference?.MemberName?.toString().replace(/Delegate$/, "") ?? "None"
|
||||
)
|
||||
case Configuration.paths.asyncAction:
|
||||
if (entity.ProxyFactoryFunctionName) {
|
||||
return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString())
|
||||
@@ -130,25 +139,26 @@ export default function nodeTitle(entity) {
|
||||
}
|
||||
}
|
||||
case Configuration.paths.materialExpressionConstant:
|
||||
input ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue]
|
||||
value ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue]
|
||||
case Configuration.paths.materialExpressionConstant2Vector:
|
||||
input ??= [
|
||||
value ??= [
|
||||
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue,
|
||||
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue,
|
||||
]
|
||||
case Configuration.paths.materialExpressionConstant3Vector:
|
||||
case Configuration.paths.materialExpressionConstant4Vector:
|
||||
if (!input) {
|
||||
if (!value) {
|
||||
const vector = entity.getCustomproperties()
|
||||
.find(pinEntity => pinEntity.PinName?.toString() == "Constant")
|
||||
?.DefaultValue
|
||||
input = vector instanceof VectorEntity ? [vector.X, vector.Y, vector.Z].map(v => v.valueOf())
|
||||
value = vector instanceof VectorEntity ? [vector.X, vector.Y, vector.Z].map(v => v.valueOf())
|
||||
: vector instanceof LinearColorEntity ? [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf())
|
||||
: /** @type {Number[]} */([])
|
||||
}
|
||||
if (input.length > 0) {
|
||||
return input.map(v => Utility.printExponential(v)).join(",")
|
||||
if (value?.length > 0) {
|
||||
return value.map(v => Utility.printExponential(v)).join(",")
|
||||
}
|
||||
value = undefined
|
||||
break
|
||||
case Configuration.paths.materialExpressionFunctionInput: {
|
||||
const materialObject = entity.getMaterialSubobject()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { html, nothing } from "lit"
|
||||
import SVGIcon from "../../SVGIcon.js"
|
||||
import Utility from "../../Utility.js"
|
||||
import nodeSubtitle from "../../decoding/nodeSubtitle.js"
|
||||
import ElementFactory from "../../element/ElementFactory.js"
|
||||
import SVGIcon from "../../SVGIcon.js"
|
||||
import ISelectableDraggableTemplate from "../ISelectableDraggableTemplate.js"
|
||||
|
||||
/** @extends {ISelectableDraggableTemplate<NodeElement>} */
|
||||
@@ -9,7 +9,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
|
||||
static nodeStyleClasses = ["ueb-node-style-default"]
|
||||
|
||||
#hasSubtitle = false
|
||||
#subtitle
|
||||
|
||||
/** @type {() => PinEntity<IEntity>} */
|
||||
pinInserter
|
||||
@@ -55,6 +55,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
/** @param {NodeElement} element */
|
||||
initialize(element) {
|
||||
super.initialize(element)
|
||||
this.#subtitle = nodeSubtitle(element.entity)
|
||||
this.element.classList.add(.../** @type {typeof NodeTemplate} */(this.constructor).nodeStyleClasses)
|
||||
this.element.style.setProperty("--ueb-node-color", this.getColor().cssText)
|
||||
this.pinInserter = this.element.entity.additionalPinInserter()
|
||||
@@ -113,13 +114,12 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
${name ? html`
|
||||
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
|
||||
${name}
|
||||
${this.#hasSubtitle && this.getTargetType().length > 0 ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
|
||||
Target is ${Utility.formatStringName(this.getTargetType())}
|
||||
</div>
|
||||
`: nothing}
|
||||
${this.#subtitle ? html`
|
||||
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">${this.#subtitle}</div>
|
||||
`: nothing
|
||||
}
|
||||
</div>
|
||||
` : nothing}
|
||||
` : nothing}
|
||||
</div>
|
||||
`
|
||||
}
|
||||
@@ -167,15 +167,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
|
||||
createPinElements() {
|
||||
return this.element.getPinEntities()
|
||||
.filter(v => !v.isHidden())
|
||||
.map(pinEntity => {
|
||||
this.#hasSubtitle = this.#hasSubtitle
|
||||
|| pinEntity.PinName.toString() === "self" && pinEntity.pinTitle() === "Target"
|
||||
return this.createPinElement(pinEntity)
|
||||
})
|
||||
}
|
||||
|
||||
getTargetType() {
|
||||
return this.element.entity.FunctionReference?.MemberParent?.getName() ?? "Untitled"
|
||||
.map(pinEntity => this.createPinElement(pinEntity))
|
||||
}
|
||||
|
||||
linksChanged() { }
|
||||
|
||||
Reference in New Issue
Block a user