New node type

This commit is contained in:
barsdeveloper
2023-04-01 22:17:50 +02:00
parent a2bf17ab21
commit 82aaf5a9cb
11 changed files with 123 additions and 12 deletions

View File

@@ -54,7 +54,7 @@ export default class Configuration {
static nameRegexSpaceReplacement = new RegExp(
"^K2(?:[Nn]ode)?_"
+ "|(?<=[a-z])(?=[A-Z0-9])" // ("Alpha2", "AlphaBravo") => ("Alpha 2", "Alpha Bravo")
+ "|(?<=[A-Z])(?=[A-Z][a-z]|[0-9])" // ("ALPHABravo", "ALPHA2") => ("ALPHA Bravo", "ALPHA 2")
+ "|(?<=[A-Z])(?=[A-Z][a-z](?![a-z]+_)|[0-9])" // ("ALPHABravo", "ALPHA2", "BTTask_") => ("ALPHA Bravo", "ALPHA 2", "BTTask")
+ "|(?<=[014-9]|[23](?!D(?:[^a-z]|$)))(?=[a-zA-Z])" // ("3Times", "3D", "3Delta") => ("3 Times", "3D", "3 Delta")
+ "|\\s*_+\\s*" // "Alpha__Bravo" => "Alpha Bravo"
+ "|\\s{2,}",
@@ -83,6 +83,7 @@ export default class Configuration {
comment: "/Script/UnrealEd.EdGraphNode_Comment",
commutativeAssociativeBinaryOperator: "/Script/BlueprintGraph.K2Node_CommutativeAssociativeBinaryOperator",
componentBoundEvent: "/Script/BlueprintGraph.K2Node_ComponentBoundEvent",
createDelegate: "/Script/BlueprintGraph.K2Node_CreateDelegate",
customEvent: "/Script/BlueprintGraph.K2Node_CustomEvent",
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",

View File

@@ -240,6 +240,14 @@ export default class SVGIcon {
</svg>
`
static node = html`
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="16" height="15" rx="1" fill="white" fill-opacity="0.5"/>
<rect x="0.5" y="0.5" width="15" height="14" rx="0.5" stroke="white"/>
<rect x="1" width="14" height="5" fill="white"/>
</svg>
`
static questionMark = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8 15C9.10456 15 10 14.1046 10 13C10 11.8954 9.10456 11 8 11C6.89544 11 6 11.8954 6 13C6 14.1046 6.89544 15 8 15Z" fill="white" />

View File

@@ -141,6 +141,8 @@ export default class NodeElement extends ISelectableDraggableElement {
switch (nodeEntity.getClass()) {
case Configuration.nodeType.comment:
return CommentNodeTemplate
case Configuration.nodeType.createDelegate:
return NodeTemplate
case Configuration.nodeType.event:
case Configuration.nodeType.customEvent:
return EventNodeTemplate

View File

@@ -421,6 +421,12 @@ export default class ObjectEntity extends IEntity {
switch (this.getType()) {
case Configuration.nodeType.componentBoundEvent:
return `${Utility.formatStringName(this.DelegatePropertyName)} (${this.ComponentPropertyName})`
case Configuration.nodeType.createDelegate:
return "Create Event"
case Configuration.nodeType.customEvent:
if (this.CustomFunctionName) {
return this.CustomFunctionName
}
case Configuration.nodeType.dynamicCast:
if (!this.TargetType) {
return "Bad cast node" // Target type not found
@@ -534,6 +540,7 @@ export default class ObjectEntity extends IEntity {
case Configuration.nodeType.inputAxisKeyEvent:
case Configuration.nodeType.inputDebugKey:
return Configuration.nodeColors.red
case Configuration.nodeType.createDelegate:
case Configuration.nodeType.enumLiteral:
case Configuration.nodeType.makeArray:
case Configuration.nodeType.makeMap:
@@ -558,6 +565,7 @@ export default class ObjectEntity extends IEntity {
nodeIcon() {
switch (this.getType()) {
case Configuration.nodeType.createDelegate: return SVGIcon.node
case Configuration.nodeType.customEvent: return SVGIcon.event
case Configuration.nodeType.doN: return SVGIcon.doN
case Configuration.nodeType.doOnce: return SVGIcon.doOnce

View File

@@ -1,4 +1,5 @@
import { html, nothing } from "lit"
import Configuration from "../../Configuration.js"
import ElementFactory from "../../element/ElementFactory.js"
import MinimalPinTemplate from "../pin/MinimalPinTemplate.js"
import NodeTemplate from "./NodeTemplate.js"
@@ -21,6 +22,8 @@ export default class EventNodeTemplate extends NodeTemplate {
renderTop() {
const icon = this.renderNodeIcon()
const name = this.renderNodeName()
const customEvent = this.element.getType() === Configuration.nodeType.customEvent
&& (this.element.entity.CustomFunctionName || this.element.entity.FunctionReference.MemberParent)
return html`
<div class="ueb-node-name">
${icon ? html`
@@ -29,7 +32,7 @@ export default class EventNodeTemplate extends NodeTemplate {
${name ? html`
<div class="ueb-node-name-text ueb-ellipsis-nowrap-text">
${name}
${this.hasSubtitle && this.element.entity.FunctionReference.MemberParent ? html`
${customEvent ? html`
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
Custom Event
</div>

View File

@@ -16,7 +16,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
/** @typedef {typeof NodeTemplate} NodeTemplateConstructor */
hasSubtitle = false
#hasSubtitle = false
static nodeStyleClasses = ["ueb-node-style-default"]
@@ -79,7 +79,7 @@ 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`
${this.#hasSubtitle && this.getTargetType().length > 0 ? html`
<div class="ueb-node-subtitle-text ueb-ellipsis-nowrap-text">
Target is ${Utility.formatStringName(this.getTargetType())}
</div>
@@ -124,7 +124,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
return this.element.getPinEntities()
.filter(v => !v.isHidden())
.map(pinEntity => {
this.hasSubtitle = this.hasSubtitle
this.#hasSubtitle = this.#hasSubtitle
|| pinEntity.PinName === "self" && pinEntity.getDisplayName() === "Target"
let pinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin"))
.newObject(pinEntity, undefined, this.element)