Fix format text serialization, LineTrace node name

This commit is contained in:
barsdeveloper
2023-04-23 15:43:57 +02:00
parent 26a4419a2a
commit bf1a5ca65c
10 changed files with 377 additions and 211 deletions

View File

@@ -8,7 +8,7 @@ export default class FormatTextEntity extends IEntity {
static lookbehind = "LOCGEN_FORMAT_NAMED"
static attributes = {
value: {
type: [new UnionType(LocalizedTextEntity, String, InvariantTextEntity, FormatTextEntity)],
type: [new UnionType(String, LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)],
},
}
@@ -18,6 +18,20 @@ export default class FormatTextEntity extends IEntity {
constructor(values) {
super(values)
/** @type {String} */ this.value
/** @type {(String | LocalizedTextEntity | InvariantTextEntity | FormatTextEntity)[]} */ this.value
}
toString() {
const pattern = this.value?.[0]?.toString() // The pattern is always the first element of the array
if (!pattern) {
return ""
}
const values = this.value.slice(1).map(v => v.toString())
return pattern.replaceAll(/\{([a-zA-Z]\w*)\}/g, (substring, arg) => {
const argLocation = values.indexOf(arg) + 1
return argLocation > 0 && argLocation < values.length
? values[argLocation]
: substring
})
}
}

View File

@@ -547,19 +547,20 @@ export default class ObjectEntity extends IEntity {
let memberName = this.FunctionReference?.MemberName
if (memberName) {
const memberParent = this.FunctionReference.MemberParent?.path ?? ""
switch (memberName) {
case "AddKey":
{
let result = memberParent.match(ObjectEntity.sequencerScriptingNameRegex)
if (result) {
return `Add Key (${Utility.formatStringName(result[1])})`
}
}
break
case "LineTraceSingle":
return "Line Trace By Channel"
case "LineTraceSingleByProfile":
return "Line Trace By Profile"
if (memberName === "AddKey") {
let result = memberParent.match(ObjectEntity.sequencerScriptingNameRegex)
if (result) {
return `Add Key (${Utility.formatStringName(result[1])})`
}
}
const memberNameTraceLineMatch = memberName.match(Configuration.lineTracePattern)
if (memberNameTraceLineMatch) {
return "Line Trace"
+ (memberNameTraceLineMatch[1] === "Multi" ? " Multi " : " ")
+ (memberNameTraceLineMatch[2] === ""
? "By Channel"
: Utility.formatStringName(memberNameTraceLineMatch[2])
)
}
switch (memberParent) {
case "/Script/Engine.KismetMathLibrary":