mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-02 05:04:43 +08:00
Large refactoring and new nodes
* Fix node reference when changing elements * Fix ScriptVariables parsing * Fix invariant text and niagara types * Niagara convert nodes * Move node tests to own files * More Niagara tests * Niagara float and smaller fixes * More Decoding * More decoding * WIP * Float is real * WIP * More types and colors * Test case and small polish * WIP * WIP * Fix niagara script variables merging * Fix Niagara variables * Fixing mirrored ExportPath * Fix Export paths name adjustments * Simplify arc calculation * Simplify a bit arc calculation * source / destionation => origin / target * Minor refactoring * Fix switched link position * Rename some properties for uniformity * Fix input escape * Simplify test * About window * Dialog backdrop style * About dialog touches * Remove dependency and minot improvement * Light mode * Fix link location and css small improvement * Link direction and minor fixes * Some minor fixes and refactoring * Refactoring WIP * Shorting repetitive bits * More tests * Simplify linking tests
This commit is contained in:
@@ -47,7 +47,7 @@ export default class ObjectEntity extends IEntity {
|
||||
Class: ObjectReferenceEntity,
|
||||
Name: StringEntity,
|
||||
Archetype: ObjectReferenceEntity,
|
||||
ExportPath: ObjectReferenceEntity,
|
||||
ExportPath: MirroredEntity.of(ObjectReferenceEntity),
|
||||
ObjectRef: ObjectReferenceEntity,
|
||||
BlueprintElementType: ObjectReferenceEntity,
|
||||
BlueprintElementInstance: ObjectReferenceEntity,
|
||||
@@ -63,6 +63,7 @@ export default class ObjectEntity extends IEntity {
|
||||
bIsPureFunc: BooleanEntity,
|
||||
bIsConstFunc: BooleanEntity,
|
||||
bIsCaseSensitive: BooleanEntity,
|
||||
bDefaultsToPureFunc: BooleanEntity,
|
||||
VariableReference: VariableReferenceEntity,
|
||||
SelfContextInfo: SymbolEntity,
|
||||
DelegatePropertyName: StringEntity,
|
||||
@@ -107,8 +108,11 @@ export default class ObjectEntity extends IEntity {
|
||||
SizeX: MirroredEntity.of(IntegerEntity),
|
||||
SizeY: MirroredEntity.of(IntegerEntity),
|
||||
Text: MirroredEntity.of(StringEntity),
|
||||
ParameterName: StringEntity,
|
||||
ExpressionGUID: GuidEntity,
|
||||
MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity),
|
||||
MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity),
|
||||
MaterialExpressionGuid: GuidEntity,
|
||||
NodeTitle: StringEntity,
|
||||
NodeTitleColor: LinearColorEntity,
|
||||
PositionX: MirroredEntity.of(IntegerEntity),
|
||||
@@ -136,10 +140,13 @@ export default class ObjectEntity extends IEntity {
|
||||
NodeGuid: GuidEntity,
|
||||
ErrorType: IntegerEntity,
|
||||
ErrorMsg: StringEntity,
|
||||
ScriptVariables: ArrayEntity.of(ScriptVariableEntity),
|
||||
ScriptVariables: ArrayEntity.flagInlined().of(ScriptVariableEntity),
|
||||
Node: MirroredEntity.of(ObjectReferenceEntity),
|
||||
ExportedNodes: StringEntity,
|
||||
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(),
|
||||
CustomProperties: ArrayEntity
|
||||
.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity))
|
||||
.withDefault()
|
||||
.flagSilent(),
|
||||
}
|
||||
static customPropertyGrammar = P.seq(
|
||||
P.reg(/CustomProperties\s+/),
|
||||
@@ -154,29 +161,28 @@ export default class ObjectEntity extends IEntity {
|
||||
Grammar.symbolQuoted.map(v => [v, true]),
|
||||
Grammar.symbol.map(v => [v, false]),
|
||||
),
|
||||
P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number)
|
||||
)
|
||||
.chain(
|
||||
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
|
||||
([[symbol, quoted], index]) =>
|
||||
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
|
||||
values => {
|
||||
if (values[symbol] === undefined) {
|
||||
let arrayEntity = ArrayEntity
|
||||
if (quoted != arrayEntity.quoted) {
|
||||
arrayEntity = arrayEntity.flagQuoted(quoted)
|
||||
}
|
||||
if (!arrayEntity.inlined) {
|
||||
arrayEntity = arrayEntity.flagInlined()
|
||||
}
|
||||
values[symbol] = new arrayEntity()
|
||||
P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) // Number in parentheses then equal
|
||||
).chain(
|
||||
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
|
||||
([[symbol, quoted], index]) =>
|
||||
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
|
||||
values => {
|
||||
if (values[symbol] === undefined) {
|
||||
let arrayEntity = ArrayEntity
|
||||
if (quoted != arrayEntity.quoted) {
|
||||
arrayEntity = arrayEntity.flagQuoted(quoted)
|
||||
}
|
||||
/** @type {ArrayEntity} */
|
||||
const target = values[symbol]
|
||||
target.values[index] = currentValue
|
||||
if (!arrayEntity.inlined) {
|
||||
arrayEntity = arrayEntity.flagInlined()
|
||||
}
|
||||
values[symbol] = new arrayEntity()
|
||||
}
|
||||
)
|
||||
)
|
||||
/** @type {ArrayEntity} */
|
||||
const target = values[symbol]
|
||||
target.values[index] = currentValue
|
||||
}
|
||||
)
|
||||
)
|
||||
static grammar = this.createGrammar()
|
||||
static grammarMultipleObjects = P.seq(
|
||||
P.whitespaceOpt,
|
||||
@@ -202,20 +208,21 @@ export default class ObjectEntity extends IEntity {
|
||||
super(values)
|
||||
|
||||
// Attributes
|
||||
/** @type {ArrayEntity<typeof PinEntity | typeof UnknownPinEntity>} */ this.CustomProperties
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AddedPins>} */ this.AddedPins
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AdvancedPinDisplay>} */ this.AdvancedPinDisplay
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Archetype>} */ this.Archetype
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AxisKey>} */ this.AxisKey
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.bIsPureFunc>} */ this.bIsPureFunc
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.bDefaultsToPureFunc>} */ this.bDefaultsToPureFunc
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.BlueprintElementInstance>} */ this.BlueprintElementInstance
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstA>} */ this.ConstA
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstB>} */ this.ConstB
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.BlueprintElementType>} */ this.BlueprintElementType
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Class>} */ this.Class
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.CommentColor>} */ this.CommentColor
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ComponentPropertyName>} */ this.ComponentPropertyName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstA>} */ this.ConstA
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstB>} */ this.ConstB
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.CustomFunctionName>} */ this.CustomFunctionName
|
||||
/** @type {ArrayEntity<typeof PinEntity | typeof UnknownPinEntity>} */ this.CustomProperties
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.DelegatePropertyName>} */ this.DelegatePropertyName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.DelegateReference>} */ this.DelegateReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.EnabledState>} */ this.EnabledState
|
||||
@@ -254,9 +261,10 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Operation>} */ this.Operation
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.OpName>} */ this.OpName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.OutputPins>} */ this.OutputPins
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ParameterName>} */ this.ParameterName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PCGNode>} */ this.PCGNode
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PinTags>} */ this.PinTags
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PinNames>} */ this.PinNames
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PinTags>} */ this.PinTags
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PositionX>} */ this.PositionX
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PositionY>} */ this.PositionY
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ProxyFactoryFunctionName>} */ this.ProxyFactoryFunctionName
|
||||
@@ -364,6 +372,7 @@ export default class ObjectEntity extends IEntity {
|
||||
? outputIndex++
|
||||
: i
|
||||
})
|
||||
this.mirrorNameInExportPaths()
|
||||
}
|
||||
|
||||
/** @returns {P<ObjectEntity>} */
|
||||
@@ -409,12 +418,46 @@ export default class ObjectEntity extends IEntity {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* Mirror then name part of the objects contained in this one in ExportPath
|
||||
*/
|
||||
mirrorNameInExportPaths(originalName = this.Name?.toString()) {
|
||||
if (!originalName) {
|
||||
return
|
||||
}
|
||||
const values = [this]
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
const value = values[i]
|
||||
if (value instanceof ObjectEntity) {
|
||||
values.push(...Object.values(value))
|
||||
if (!value.ExportPath?.valueOf().path.includes(originalName)) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
const mirroredEntity = /** @type {typeof ObjectEntity} */(value.constructor).attributes.ExportPath
|
||||
let originalExportPath = value.ExportPath
|
||||
value.ExportPath = new mirroredEntity(
|
||||
() => {
|
||||
const exportPath = originalExportPath.valueOf()
|
||||
return new (mirroredEntity.type)(
|
||||
exportPath.type,
|
||||
exportPath.path.replace(originalName, this.Name?.toString() ?? ""),
|
||||
exportPath.full
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {String} */
|
||||
#class
|
||||
getClass() {
|
||||
if (!this.#class) {
|
||||
this.#class = (this.Class?.path ? this.Class.path : this.Class?.type)
|
||||
?? this.ExportPath?.type
|
||||
?? this.ExportPath?.valueOf()?.type
|
||||
?? ""
|
||||
if (this.#class && !this.#class.startsWith("/")) {
|
||||
// Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js
|
||||
@@ -428,14 +471,14 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
getType() {
|
||||
let classValue = this.getClass()
|
||||
if (this.MacroGraphReference?.MacroGraph?.path) {
|
||||
return this.MacroGraphReference.MacroGraph.path
|
||||
const path = this.MacroGraphReference?.MacroGraph?.path
|
||||
if (path) {
|
||||
return path
|
||||
}
|
||||
if (this.MaterialExpression) {
|
||||
return this.MaterialExpression.type
|
||||
}
|
||||
return classValue
|
||||
return this.getClass()
|
||||
}
|
||||
|
||||
getObjectName(dropCounter = false) {
|
||||
@@ -555,24 +598,10 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
isMaterial() {
|
||||
|
||||
return this.getClass() === Configuration.paths.materialGraphNode
|
||||
// return [
|
||||
// Configuration.paths.materialExpressionConstant,
|
||||
// Configuration.paths.materialExpressionConstant2Vector,
|
||||
// Configuration.paths.materialExpressionConstant3Vector,
|
||||
// Configuration.paths.materialExpressionConstant4Vector,
|
||||
// Configuration.paths.materialExpressionLogarithm,
|
||||
// Configuration.paths.materialExpressionLogarithm10,
|
||||
// Configuration.paths.materialExpressionLogarithm2,
|
||||
// Configuration.paths.materialExpressionMaterialFunctionCall,
|
||||
// Configuration.paths.materialExpressionSquareRoot,
|
||||
// Configuration.paths.materialExpressionTextureCoordinate,
|
||||
// Configuration.paths.materialExpressionTextureSample,
|
||||
// Configuration.paths.materialGraphNode,
|
||||
// Configuration.paths.materialGraphNodeComment,
|
||||
// ]
|
||||
// .includes(this.getClass())
|
||||
const classValue = this.getClass()
|
||||
return classValue.startsWith("/Script/Engine.MaterialExpression")
|
||||
|| classValue.startsWith("/Script/InterchangeImport.MaterialExpression")
|
||||
|| classValue.startsWith("/Script/UnrealEd.MaterialGraph")
|
||||
}
|
||||
|
||||
/** @return {ObjectEntity} */
|
||||
@@ -666,9 +695,10 @@ export default class ObjectEntity extends IEntity {
|
||||
attributeSeparator = Self.attributeSeparator,
|
||||
wrap = Self.wrap,
|
||||
) {
|
||||
const isSelfOverriden = Self !== this.constructor
|
||||
const deeperIndentation = indentation + Configuration.indentation
|
||||
const initial_trailing = this.trailing
|
||||
this.trailing = false
|
||||
this.trailing = true
|
||||
const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap)
|
||||
this.trailing = initial_trailing
|
||||
let result = indentation + "Begin Object"
|
||||
@@ -690,27 +720,27 @@ export default class ObjectEntity extends IEntity {
|
||||
? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ ((this.ExportPath?.type || this.ExportPath?.path)
|
||||
// && Self.attributes.ExportPath.ignored !== true
|
||||
// && this.ExportPath.ignored !== true
|
||||
+ ((this.ExportPath?.valueOf()?.type || this.ExportPath?.valueOf()?.path)
|
||||
// && Self.attributes.ExportPath.valueOf().ignored !== true
|
||||
// && this.ExportPath.valueOf().ignored !== true
|
||||
? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ (content ? attributeSeparator + content : "")
|
||||
+ attributeSeparator
|
||||
+ content
|
||||
+ (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true
|
||||
? this.getCustomproperties()
|
||||
.map(pin =>
|
||||
attributeSeparator
|
||||
+ deeperIndentation
|
||||
deeperIndentation
|
||||
+ printKey("CustomProperties ")
|
||||
+ pin.serialize(insideString)
|
||||
+ attributeSeparator
|
||||
)
|
||||
.join("")
|
||||
: ""
|
||||
)
|
||||
+ attributeSeparator
|
||||
+ indentation + "End Object"
|
||||
+ (this.trailing ? attributeSeparator : "")
|
||||
+ (isSelfOverriden && Self.trailing || this.trailing ? attributeSeparator : "")
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user