mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:28:17 +08:00
SVGIcon class, Macro reference entity
This commit is contained in:
@@ -7,6 +7,7 @@ import InvariantTextEntity from "../entity/InvariantTextEntity"
|
||||
import KeyBindingEntity from "../entity/KeyBindingEntity"
|
||||
import LinearColorEntity from "../entity/LinearColorEntity"
|
||||
import LocalizedTextEntity from "../entity/LocalizedTextEntity"
|
||||
import MacroGraphReferenceEntity from "../entity/MacroGraphReferenceEntity"
|
||||
import ObjectEntity from "../entity/ObjectEntity"
|
||||
import ObjectReferenceEntity from "../entity/ObjectReferenceEntity"
|
||||
import Parsimmon from "parsimmon"
|
||||
@@ -69,10 +70,12 @@ export default class Grammar {
|
||||
return r.LinearColor
|
||||
case LocalizedTextEntity:
|
||||
return r.LocalizedText
|
||||
case MacroGraphReferenceEntity:
|
||||
return r.MacroGraphReference
|
||||
case Number:
|
||||
return r.Number
|
||||
case ObjectReferenceEntity:
|
||||
return r.Reference
|
||||
return r.ObjectReference
|
||||
case PinEntity:
|
||||
return r.Pin
|
||||
case PinReferenceEntity:
|
||||
@@ -181,6 +184,8 @@ export default class Grammar {
|
||||
.map(v => v.toString())
|
||||
.sepBy1(P.string("."))
|
||||
.tieWith(".")
|
||||
.sepBy1(P.string(":"))
|
||||
.tieWith(":")
|
||||
)
|
||||
.tie()
|
||||
.atLeast(2)
|
||||
@@ -208,7 +213,7 @@ export default class Grammar {
|
||||
PathSymbol = r => P.regex(/[0-9\w]+/).map(v => new PathSymbolEntity({ value: v }))
|
||||
|
||||
/** @param {Grammar} r */
|
||||
Reference = r => P.alt(
|
||||
ObjectReference = r => P.alt(
|
||||
r.None,
|
||||
...[r.ReferencePath.map(path => new ObjectReferenceEntity({ type: "", path: path }))]
|
||||
.flatMap(referencePath => [
|
||||
@@ -261,7 +266,7 @@ export default class Grammar {
|
||||
r.Guid,
|
||||
r.LocalizedText,
|
||||
r.InvariantText,
|
||||
r.Reference,
|
||||
r.ObjectReference,
|
||||
r.Vector,
|
||||
r.LinearColor,
|
||||
)
|
||||
@@ -317,6 +322,9 @@ export default class Grammar {
|
||||
/** @param {Grammar} r */
|
||||
FunctionReference = r => Grammar.createEntityGrammar(r, FunctionReferenceEntity)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
MacroGraphReference = r => Grammar.createEntityGrammar(r, MacroGraphReferenceEntity)
|
||||
|
||||
/** @param {Grammar} r */
|
||||
KeyBinding = r => P.alt(
|
||||
r.Identifier.map(identifier => new KeyBindingEntity({
|
||||
|
||||
@@ -71,9 +71,10 @@ export default class ISerializer {
|
||||
* @param {Boolean} insideString
|
||||
*/
|
||||
writeValue(entity, value, fullKey, insideString) {
|
||||
const serializer = SerializerFactory.getSerializer(Utility.getType(value))
|
||||
const type = Utility.getType(value)
|
||||
const serializer = SerializerFactory.getSerializer(type)
|
||||
if (!serializer) {
|
||||
throw new Error("Unknown value type, a serializer must be registered in the SerializerFactory class")
|
||||
throw new Error(`Unknown value type "${type.name}", a serializer must be registered in the SerializerFactory class, check initializeSerializerFactory.js`)
|
||||
}
|
||||
return serializer.write(entity, value, insideString)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import InvariantTextEntity from "../entity/InvariantTextEntity"
|
||||
import KeyBindingEntity from "../entity/KeyBindingEntity"
|
||||
import LinearColorEntity from "../entity/LinearColorEntity"
|
||||
import LocalizedTextEntity from "../entity/LocalizedTextEntity"
|
||||
import MacroGraphReferenceEntity from "../entity/MacroGraphReferenceEntity"
|
||||
import ObjectEntity from "../entity/ObjectEntity"
|
||||
import ObjectReferenceEntity from "../entity/ObjectReferenceEntity"
|
||||
import ObjectSerializer from "./ObjectSerializer"
|
||||
@@ -105,6 +106,11 @@ export default function initializeSerializerFactory() {
|
||||
new GeneralSerializer(v => `${LocalizedTextEntity.lookbehind}(${v})`, LocalizedTextEntity, "", ", ", false, "", _ => "")
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
MacroGraphReferenceEntity,
|
||||
new GeneralSerializer(bracketsWrapped, MacroGraphReferenceEntity)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
Number,
|
||||
new CustomSerializer(
|
||||
|
||||
Reference in New Issue
Block a user