Added a couple of new nodes and a grammar fix.

This commit is contained in:
barsdeveloper
2023-03-10 10:52:32 +01:00
parent c63f51da57
commit 405accc39c
9 changed files with 4902 additions and 4798 deletions

View File

@@ -154,6 +154,48 @@ const tests = [
delegate: false,
development: false,
},
{
name: "Multi Gate",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_MultiGate Name="K2Node_MultiGate_2"
NodePosX=-96
NodePosY=-160
NodeGuid=8D5767632F6C462B928E7F9A47E84AF3
CustomProperties Pin (PinId=61334592A1B647A7888EDF804247FF70,PinName="execute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=39200141C5D0415B825C28E3EC01A3F1,PinName="Out 0",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=EF36C23B68A44578B518B963E636D33C,PinName="Out 1",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=92FADDC1B07C45AC8BEF2FE42E13A638,PinName="Reset",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=363311761BC8401B8B26AD4B2D255749,PinName="IsRandom",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=6F24605AD128461BB5652884D40E61E3,PinName="Loop",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=E547C9E4961A43AD944E6877C2FF44D6,PinName="StartIndex",PinType.PinCategory="int",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="-1",AutogeneratedDefaultValue="-1",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
color: Configuration.nodeColors.gray,
icon: SVGIcon.sequence,
pins: 7,
delegate: false,
development: false,
},
{
name: "Do Once",
value: String.raw`
Begin Object Class=/Script/BlueprintGraph.K2Node_MacroInstance Name="K2Node_MacroInstance_1"
MacroGraphReference=(MacroGraph=/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce"',GraphBlueprint=/Script/Engine.Blueprint'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros"',GraphGuid=1281F54248A2ECB5B8B2C5B24AE6FDF4)
NodePosX=-416
NodePosY=-112
NodeGuid=A1831A1B85EF4E568E766FE3A3BCC5CD
CustomProperties Pin (PinId=5C24D82D7B084DFB841D17E5DF1CD8CF,PinName="execute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=27242FC0B565448396C6A2DCD6BEDBD1,PinName="Reset",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=A8C0EB54974741248EA0B7B97FAC44DE,PinName="Start Closed",PinType.PinCategory="bool",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="true",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
CustomProperties Pin (PinId=3DE1FC03BFCD4ACF9AC7B99B89CEF465,PinName="Completed",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_MultiGate_2 92FADDC1B07C45AC8BEF2FE42E13A638,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)
End Object
`,
color: Configuration.nodeColors.gray,
icon: SVGIcon.doOnce,
pins: 4,
delegate: false,
development: false,
},
]
/** @type {Blueprint} */

9534
dist/ueblueprint.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -76,6 +76,7 @@ export default class Configuration {
componentBoundEvent: "/Script/BlueprintGraph.K2Node_ComponentBoundEvent",
customEvent: "/Script/BlueprintGraph.K2Node_CustomEvent",
doN: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",
doOnce: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",
dynamicCast: "/Script/BlueprintGraph.K2Node_DynamicCast",
enum: "/Script/CoreUObject.Enum",
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
@@ -98,6 +99,7 @@ export default class Configuration {
makeArray: "/Script/BlueprintGraph.K2Node_MakeArray",
makeMap: "/Script/BlueprintGraph.K2Node_MakeMap",
makeSet: "/Script/BlueprintGraph.K2Node_MakeSet",
multiGate: "/Script/BlueprintGraph.K2Node_MultiGate",
pawn: "/Script/Engine.Pawn",
promotableOperator: "/Script/BlueprintGraph.K2Node_PromotableOperator",
reverseForEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",

View File

@@ -64,12 +64,20 @@ export default class SVGIcon {
`
static doN = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path fill="white" d="M1 12V8H9V4L16 10L9 16V12H1Z" />
<path fill="white" d="M7 6L6 6L4 2.66667V6H3V1H4L6 4.33333V1H7V6Z" />
</svg>
`
static doOnce = html`
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path d="M1 12V8H9V4L16 10L9 16V12H1Z" fill="white"/>
<path d="M6 6H5L4.98752 2.42387L4 2.8642V1.893L5.89305 1H6V6Z" fill="white"/>
<rect x="4" y="5" width="3" height="1" fill="white"/>
</svg>
`
static enum = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="white" d="M9 5V0H2V16H14V5H9ZM3.2 4.4L4.5 4H4.6V7H4V4.7L3.2 4.9V4.4ZM4.7 14.8C4.6 14.9 4.3 15 4 15C3.7 15 3.5 14.9 3.3 14.8C3.1 14.6 3 14.4 3 14.2H3.6C3.6 14.3 3.6 14.4 3.7 14.5C3.8 14.6 3.9 14.6 4 14.6C4.1 14.6 4.2 14.6 4.3 14.5C4.4 14.4 4.4 14.3 4.4 14.2C4.4 13.9 4.2 13.8 3.9 13.8H3.7V13.3H4C4.1 13.3 4.3 13.3 4.3 13.2C4.4 13.1 4.4 13 4.4 12.9C4.4 12.8 4.4 12.7 4.3 12.6C4.2 12.5 4.1 12.5 4 12.5C3.9 12.5 3.8 12.5 3.7 12.6C3.6 12.7 3.6 12.7 3.6 12.8H3C3 12.6 3 12.5 3.1 12.4C3.2 12.3 3.3 12.2 3.4 12.1C3.7 12 3.8 12 4 12C4.3 12 4.6 12.1 4.7 12.2C4.9 12.4 5 12.6 5 12.8C5 12.9 5 13.1 4.9 13.2C4.8 13.3 4.7 13.4 4.6 13.5C4.8 13.6 4.9 13.6 5 13.8C5 13.8 5 14 5 14.1C5 14.4 4.9 14.6 4.7 14.8ZM5.1 11H3.1V10.6L4.1 9.6C4.2 9.5 4.3 9.3 4.4 9.2C4.4 9.1 4.4 9 4.4 8.9C4.4 8.8 4.4 8.7 4.3 8.6C4.2 8.5 4.1 8.5 4 8.5C3.9 8.5 3.8 8.5 3.7 8.6C3.6 8.7 3.6 8.8 3.6 9H3C3 8.8 3 8.7 3.1 8.5C3.2 8.4 3.3 8.2 3.5 8.1C3.7 8 3.8 8 4 8C4.3 8 4.5 8.1 4.7 8.2C4.9 8.4 5 8.6 5 8.8C5 9 5 9.1 4.9 9.3C4.8 9.4 4.7 9.6 4.5 9.8L3.8 10.5H5.1V11ZM12 15H6V14H12V15ZM12 11H6V10H12V11ZM12 7H6V6H12V7Z" />

View File

@@ -7,7 +7,9 @@ export default class FormatTextEntity extends IEntity {
static lookbehind = "LOCGEN_FORMAT_NAMED"
static attributes = {
value: [new UnionType(LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)],
value: {
type: [new UnionType(LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)]
},
}
static {
@@ -18,4 +20,4 @@ export default class FormatTextEntity extends IEntity {
super(values)
/** @type {String} */ this.value
}
} 1
}

View File

@@ -540,6 +540,7 @@ export default class ObjectEntity extends IEntity {
case Configuration.nodeType.executionSequence:
case Configuration.nodeType.ifThenElse:
case Configuration.nodeType.macro:
case Configuration.nodeType.multiGate:
return Configuration.nodeColors.gray
case Configuration.nodeType.dynamicCast:
return Configuration.nodeColors.turquoise
@@ -557,22 +558,27 @@ export default class ObjectEntity extends IEntity {
switch (this.getType()) {
case Configuration.nodeType.customEvent: return SVGIcon.event
case Configuration.nodeType.doN: return SVGIcon.doN
case Configuration.nodeType.doOnce: return SVGIcon.doOnce
case Configuration.nodeType.dynamicCast: return SVGIcon.cast
case Configuration.nodeType.enumLiteral: return SVGIcon.enum
case Configuration.nodeType.event: return SVGIcon.event
case Configuration.nodeType.executionSequence: return SVGIcon.sequence
case Configuration.nodeType.forEachElementInEnum: return SVGIcon.loop
case Configuration.nodeType.forEachLoop: return SVGIcon.forEachLoop
case Configuration.nodeType.forEachLoopWithBreak: return SVGIcon.forEachLoop
case Configuration.nodeType.forLoop: return SVGIcon.loop
case Configuration.nodeType.forLoopWithBreak: return SVGIcon.loop
case Configuration.nodeType.executionSequence:
case Configuration.nodeType.multiGate:
return SVGIcon.sequence
case Configuration.nodeType.forEachElementInEnum:
case Configuration.nodeType.forLoop:
case Configuration.nodeType.forLoopWithBreak:
case Configuration.nodeType.whileLoop:
return SVGIcon.loop
case Configuration.nodeType.forEachLoop:
case Configuration.nodeType.forEachLoopWithBreak:
return SVGIcon.forEachLoop
case Configuration.nodeType.ifThenElse: return SVGIcon.branchNode
case Configuration.nodeType.isValid: return SVGIcon.questionMark
case Configuration.nodeType.makeArray: return SVGIcon.makeArray
case Configuration.nodeType.makeMap: return SVGIcon.makeMap
case Configuration.nodeType.makeSet: return SVGIcon.makeSet
case Configuration.nodeType.select: return SVGIcon.select
case Configuration.nodeType.whileLoop: return SVGIcon.loop
}
if (this.nodeDisplayName().startsWith("Break")) {
return SVGIcon.breakStruct

View File

@@ -1,6 +1,7 @@
import ByteEntity from "./ByteEntity"
import Configuration from "../Configuration"
import EnumEntity from "./EnumEntity"
import FormatTextEntity from "./FormatTextEntity"
import FunctionReferenceEntity from "./FunctionReferenceEntity"
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
@@ -57,7 +58,7 @@ export default class PinEntity extends IEntity {
},
PinName: "",
PinFriendlyName: {
type: new UnionType(LocalizedTextEntity, String),
type: new UnionType(LocalizedTextEntity, FormatTextEntity, String),
showDefault: false,
},
PinToolTip: {

View File

@@ -1,6 +1,7 @@
// @ts-nocheck
import ByteEntity from "../entity/ByteEntity"
import EnumEntity from "../entity/EnumEntity"
import FormatTextEntity from "../entity/FormatTextEntity"
import FunctionReferenceEntity from "../entity/FunctionReferenceEntity"
import GuidEntity from "../entity/GuidEntity"
import IdentifierEntity from "../entity/IdentifierEntity"
@@ -89,33 +90,6 @@ export default class Grammar {
/** @param {Grammar} r */
static getGrammarForType(r, attribute, defaultGrammar = r.AttributeAnyValue) {
if (attribute.constructor === Object) {
attribute = /** @type {AttributeInformation} */(attribute)
let type = attribute.type
let result
if (type instanceof Array) {
result = Grammar.getGrammarForType(r, type[0])
.trim(P.optWhitespace)
.sepBy(P.string(","))
.skip(P.regex(/,?\s*/))
.wrap(P.string("("), P.string(")"))
} else if (type instanceof UnionType) {
result = type.types
.map(v => Grammar.getGrammarForType(r, Utility.getType(v)))
.reduce((accum, cur) => !cur || accum === r.AttributeAnyValue
? r.AttributeAnyValue
: accum.or(cur))
} else {
result = Grammar.getGrammarForType(r, type, defaultGrammar)
}
if (attribute.serialized && !(type instanceof String)) {
result = result.wrap(P.string('"'), P.string('"'))
}
if (attribute.nullable) {
result = result.or(r.Null)
}
return result
}
switch (attribute) {
case BigInt:
return r.BigInt
@@ -125,6 +99,8 @@ export default class Grammar {
return r.Byte
case EnumEntity:
return r.Enum
case FormatTextEntity:
return r.FormatText
case FunctionReferenceEntity:
return r.FunctionReference
case GuidEntity:
@@ -177,9 +153,35 @@ export default class Grammar {
return r.Vector2D
case VectorEntity:
return r.Vector
default:
return defaultGrammar
}
let result = defaultGrammar
const type = attribute.constructor === Object
? attribute.type
: attribute.constructor
if (type instanceof Array) {
result = Grammar.getGrammarForType(r, type[0])
.trim(P.optWhitespace)
.sepBy(P.string(","))
.skip(P.regex(/,?\s*/))
.wrap(P.string("("), P.string(")"))
} else if (type instanceof UnionType) {
result = type.types
.map(v => Grammar.getGrammarForType(r, v))
.reduce((accum, cur) => !cur || accum === r.AttributeAnyValue
? r.AttributeAnyValue
: accum.or(cur))
} else if (attribute.constructor === Object) {
result = Grammar.getGrammarForType(r, type, defaultGrammar)
}
if (attribute.constructor === Object) {
if (attribute.serialized && type.constructor !== String) {
result = result.wrap(P.string('"'), P.string('"'))
}
if (attribute.nullable) {
result = result.or(r.Null)
}
}
return result
}
/** @param {Grammar} r */
@@ -222,7 +224,7 @@ export default class Grammar {
/**
* @param {Grammar} r
* @param {EntityConstructor} entityType
* @param {Boolean | Number} acceptUnknownKeys can be anumber to specify the limit or true, to let it be a reasonable value
* @param {Boolean | Number} acceptUnknownKeys Number to specify the limit or true, to let it be a reasonable value
*/
static createEntityGrammar = (r, entityType, acceptUnknownKeys = true) =>
P.seqMap(
@@ -366,19 +368,20 @@ export default class Grammar {
namespace: matchResult[1],
key: matchResult[2],
value: matchResult[3]
}
)
})
)
/** @param {Grammar} r */
InvariantText = r =>
Grammar.regexMap(
new RegExp(
String.raw`${InvariantTextEntity.lookbehind}\s*\("(${Grammar.Regex.InsideString.source})"\)`,
matchResult => new InvariantTextEntity({ value: matchResult[1] })
)
new RegExp(String.raw`${InvariantTextEntity.lookbehind}\s*\("(${Grammar.Regex.InsideString.source})"\)`),
matchResult => new InvariantTextEntity({ value: matchResult[1] })
)
FormatText = r => P.string(FormatTextEntity.lookbehind).then(P.optWhitespace).then(
Grammar.getGrammarForType(r, FormatTextEntity.attributes.value).wrap(P.string("("), P.string(")"))
)
/** @param {Grammar} r */
AttributeAnyValue = r => P.alt(
// Remember to keep the order, otherwise parsing might fail