mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-18 03:27:32 +08:00
Fix format text serialization, LineTrace node name
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user