mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-24 07:44:42 +08:00
PCG nodes and other fixes (#14)
* Various fixes * Fix name from SettingsInterface * Allow path lookbehind for unknown keys entity * Subraph object name * Several fixes * Various fixes * Fix colors * Various pin types
This commit is contained in:
@@ -429,13 +429,16 @@ export default class Grammar {
|
||||
static formatTextEntity = P.lazy(() =>
|
||||
P.seq(
|
||||
this.regexMap(
|
||||
// Resulting regex: /(LOCGEN_FORMAT_NAMED|LOCGEN_FORMAT_ORDERED)\s*/
|
||||
new RegExp(`(${FormatTextEntity.lookbehind.values.reduce((acc, cur) => acc + "|" + cur)})\\s*`),
|
||||
result => result[1]
|
||||
),
|
||||
this.grammarFor(FormatTextEntity.attributes.value)
|
||||
)
|
||||
.map(([lookbehind, values]) => {
|
||||
const result = new FormatTextEntity(values)
|
||||
const result = new FormatTextEntity({
|
||||
value: values,
|
||||
})
|
||||
result.lookbehind = lookbehind
|
||||
return result
|
||||
})
|
||||
@@ -515,7 +518,7 @@ export default class Grammar {
|
||||
)
|
||||
|
||||
static fullReferenceEntity = P.lazy(() =>
|
||||
P.seq(this.typeReference, P.optWhitespace, this.pathQuotes)
|
||||
P.seq(this.typeReference, P.regex(Grammar.Regex.InlineOptWhitespace), this.pathQuotes)
|
||||
.map(([type, _2, path]) =>
|
||||
new ObjectReferenceEntity({ type: type, path: path })
|
||||
)
|
||||
@@ -611,8 +614,9 @@ export default class Grammar {
|
||||
|
||||
static unknownKeysEntity = P.lazy(() =>
|
||||
P.seq(
|
||||
// Lookbehind
|
||||
this.regexMap(
|
||||
new RegExp(`(${this.Regex.Symbol.source}\\s*)?\\(\\s*`),
|
||||
new RegExp(`(${this.Regex.Path.source}\\s*)?\\(\\s*`),
|
||||
result => result[1] ?? ""
|
||||
),
|
||||
this.attributeName
|
||||
|
||||
@@ -15,6 +15,7 @@ export default class ObjectSerializer extends Serializer {
|
||||
switch (key) {
|
||||
case "Class":
|
||||
case "Name":
|
||||
case "Archetype":
|
||||
case "ExportPath":
|
||||
case "CustomProperties":
|
||||
// Serielized separately, check doWrite()
|
||||
@@ -81,6 +82,7 @@ export default class ObjectSerializer extends Serializer {
|
||||
let result = indentation + "Begin Object"
|
||||
+ (entity.Class?.type || entity.Class?.path ? ` Class=${this.doWriteValue(entity.Class, insideString)}` : "")
|
||||
+ (entity.Name ? ` Name=${this.doWriteValue(entity.Name, insideString)}` : "")
|
||||
+ (entity.Archetype ? ` Archetype=${this.doWriteValue(entity.Archetype, insideString)}` : "")
|
||||
+ (entity.ExportPath?.type || entity.ExportPath?.path ? ` ExportPath=${this.doWriteValue(entity.ExportPath, insideString)}` : "")
|
||||
+ "\n"
|
||||
+ super.doWrite(
|
||||
|
||||
@@ -5,10 +5,14 @@ import Utility from "../Utility.js"
|
||||
|
||||
/**
|
||||
* @typedef {import("../entity/IEntity.js").AnyValue} AnyValue
|
||||
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<*>} AnyValueConstructor
|
||||
* @typedef {import("../entity/IEntity.js").EntityConstructor} EntityConstructor
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {AnyValue} T
|
||||
* @typedef {import("../entity/IEntity.js").AnyValueConstructor<T>} AnyValueConstructor
|
||||
*/
|
||||
|
||||
/** @template {AnyValue} T */
|
||||
export default class Serializer {
|
||||
|
||||
@@ -21,7 +25,7 @@ export default class Serializer {
|
||||
/** @type {(entity: AnyValue, serialized: String) => String} */
|
||||
static bracketsWrapped = (entity, serialized) => `(${serialized})`
|
||||
|
||||
/** @param {AnyValueConstructor} entityType */
|
||||
/** @param {AnyValueConstructor<T>} entityType */
|
||||
constructor(
|
||||
entityType,
|
||||
/** @type {(entity: T, serialized: String) => String} */
|
||||
@@ -148,6 +152,7 @@ export default class Serializer {
|
||||
}
|
||||
|
||||
showProperty(entity, key) {
|
||||
// @ts-expect-error
|
||||
const attribute = /** @type {EntityConstructor} */(this.entityType).attributes[key]
|
||||
if (attribute?.constructor === Object && attribute.ignored) {
|
||||
return false
|
||||
|
||||
@@ -107,7 +107,7 @@ export default function initializeSerializerFactory() {
|
||||
FormatTextEntity,
|
||||
new CustomSerializer(
|
||||
(v, insideString) => {
|
||||
let result = FormatTextEntity.lookbehind + "("
|
||||
let result = v.getLookbehind() + "("
|
||||
+ v.value.map(v =>
|
||||
SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString)
|
||||
).join(", ")
|
||||
@@ -144,7 +144,7 @@ export default function initializeSerializerFactory() {
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
InvariantTextEntity,
|
||||
new Serializer(InvariantTextEntity, (entity, v) => `${InvariantTextEntity.lookbehind}(${v})`, ", ", false, "", () => "")
|
||||
new Serializer(InvariantTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "")
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
@@ -159,7 +159,7 @@ export default function initializeSerializerFactory() {
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
LocalizedTextEntity,
|
||||
new Serializer(LocalizedTextEntity, (entity, v) => `${LocalizedTextEntity.lookbehind}(${v})`, ", ", false, "", () => "")
|
||||
new Serializer(LocalizedTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "")
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
@@ -204,7 +204,7 @@ export default function initializeSerializerFactory() {
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
PinEntity,
|
||||
new Serializer(PinEntity, (entity, v) => `${PinEntity.lookbehind} (${v})`, ",", true)
|
||||
new Serializer(PinEntity, (entity, v) => `${entity.getLookbehind()} (${v})`, ",", true)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
@@ -265,7 +265,7 @@ export default function initializeSerializerFactory() {
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
UnknownKeysEntity,
|
||||
new Serializer(UnknownKeysEntity, (entity, string) => `${entity.lookbehind ?? ""}(${string})`)
|
||||
new Serializer(UnknownKeysEntity, (entity, string) => `${entity.getLookbehind() ?? ""}(${string})`)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
|
||||
Reference in New Issue
Block a user