Link icon fixing, name refactoring

This commit is contained in:
barsdeveloper
2022-11-21 11:45:43 +01:00
parent 401ce75fdc
commit a7468f4cf0
37 changed files with 239 additions and 151 deletions

View File

@@ -162,6 +162,13 @@ export default class SVGIcon {
</svg>
`
static reject = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path stroke="red" stroke-width="2" stroke-miterlimit="10" d="M12.5 3.5L3.5 12.5" />
<path fill="red" d="M8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2ZM8 0.5C3.9 0.5 0.5 3.9 0.5 8C0.5 12.1 3.9 15.5 8 15.5C12.1 15.5 15.5 12.1 15.5 8C15.5 3.9 12.1 0.5 8 0.5Z" />
</svg>
`
static select = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1" y="2" width="6" height="2" fill="white"/>

View File

@@ -237,7 +237,7 @@ export default class LinkElement extends IFromToPositionedElement {
}
setMessageDirectionsIncompatible() {
this.linkMessageIcon = "ueb-icon-directions-incompatible"
this.linkMessageIcon = SVGIcon.reject
this.linkMessageText = html`Directions are not compatbile.`
}
@@ -247,17 +247,17 @@ export default class LinkElement extends IFromToPositionedElement {
}
setMessageReplaceLink() {
this.linkMessageIcon = "ueb-icon-replace-link"
this.linkMessageIcon = SVGIcon.correct
this.linkMessageText = html`Replace existing input connections.`
}
setMessageSameNode() {
this.linkMessageIcon = "ueb-icon-same-node"
this.linkMessageIcon = SVGIcon.reject
this.linkMessageText = html`Both are on the same node.`
}
setMEssagetypesIncompatible() {
this.linkMessageIcon = "ueb-icon-types-incompatible"
this.linkMessageIcon = SVGIcon.reject
this.linkMessageText = html`${this.sourcePin.pinType} is not compatible with ${this.destinationPin.pinType}.`
}
}

View File

@@ -9,8 +9,8 @@ export default class FunctionReferenceEntity extends IEntity {
MemberName: "",
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {ObjectReferenceEntity} */ this.MemberParent
/** @type {String} */ this.MemberName
}

View File

@@ -18,11 +18,11 @@ export default class GuidEntity extends IEntity {
return new GuidEntity({ value: guid })
}
constructor(options) {
if (!options) {
options = GuidEntity.generateGuid().value
constructor(values) {
if (!values) {
values = GuidEntity.generateGuid().value
}
super(options)
super(values)
/** @type {String} */ this.value
}

View File

@@ -11,8 +11,8 @@ export default class IdentifierEntity extends IEntity {
toAttribute: (value, type) => value.toString()
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {String} */ this.value
}

View File

@@ -6,9 +6,9 @@ export default class IntegerEntity extends IEntity {
value: 0,
}
/** @param {Object | Number | String} options */
constructor(options = 0) {
super(options)
/** @param {Object | Number | String} values */
constructor(values = 0) {
super(values)
/** @type {Number} */
this.value = Math.round(this.value)
}

View File

@@ -7,8 +7,8 @@ export default class InvariantTextEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {String} */ this.value
}
}

View File

@@ -12,13 +12,13 @@ export default class KeyBindingEntity extends IEntity {
Key: IdentifierEntity,
}
constructor(options = {}) {
options.ActionName = options.ActionName ?? ""
options.bShift = options.bShift ?? false
options.bCtrl = options.bCtrl ?? false
options.bAlt = options.bAlt ?? false
options.bCmd = options.bCmd ?? false
super(options)
constructor(values = {}) {
values.ActionName = values.ActionName ?? ""
values.bShift = values.bShift ?? false
values.bCtrl = values.bCtrl ?? false
values.bAlt = values.bAlt ?? false
values.bCmd = values.bCmd ?? false
super(values)
/** @type {String} */ this.ActionName
/** @type {Boolean} */ this.bShift
/** @type {Boolean} */ this.bCtrl

View File

@@ -41,8 +41,8 @@ export default class LinearColorEntity extends IEntity {
}
}
constructor(options) {
super(options)
constructor(values) {
super(values)
/** @type {RealUnitEntity} */ this.R
/** @type {RealUnitEntity} */ this.G
/** @type {RealUnitEntity} */ this.B

View File

@@ -10,8 +10,8 @@ export default class LocalizedTextEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {String} */ this.namespace
/** @type {String} */ this.key
/** @type {String} */ this.value

View File

@@ -10,8 +10,8 @@ export default class MacroGraphReferenceEntity extends IEntity {
GraphGuid: GuidEntity,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {ObjectReferenceEntity} */ this.MacroGraph
/** @type {ObjectReferenceEntity} */ this.GraphBlueprint
/** @type {GuidEntity} */ this.GuidEntity

View File

@@ -3,8 +3,8 @@ import Utility from "../Utility"
export default class NaturalNumberEntity extends IntegerEntity {
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
this.value = Math.round(Utility.clamp(this.value, 0))
}
}

View File

@@ -7,6 +7,7 @@ import IntegerEntity from "./IntegerEntity"
import MacroGraphReferenceEntity from "./MacroGraphReferenceEntity"
import ObjectReferenceEntity from "./ObjectReferenceEntity"
import PinEntity from "./PinEntity"
import SymbolEntity from "./SymbolEntity"
import TypeInitialization from "./TypeInitialization"
import Utility from "../Utility"
import VariableReferenceEntity from "./VariableReferenceEntity"
@@ -18,6 +19,7 @@ export default class ObjectEntity extends IEntity {
Name: "",
bIsPureFunc: new TypeInitialization(Boolean, false, false),
VariableReference: new TypeInitialization(VariableReferenceEntity, false, null),
SelfContextInfo: new TypeInitialization(SymbolEntity, false, null),
FunctionReference: new TypeInitialization(FunctionReferenceEntity, false, null,),
EventReference: new TypeInitialization(FunctionReferenceEntity, false, null,),
TargetType: new TypeInitialization(ObjectReferenceEntity, false, null),
@@ -36,8 +38,8 @@ export default class ObjectEntity extends IEntity {
static nameRegex = /^(\w+?)(?:_(\d+))?$/
static sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {ObjectReferenceEntity} */ this.Class
/** @type {String} */ this.Name
/** @type {Boolean?} */ this.bIsPureFunc

View File

@@ -7,13 +7,13 @@ export default class ObjectReferenceEntity extends IEntity {
path: String,
}
constructor(options = {}) {
if (options.constructor !== Object) {
options = {
path: options
constructor(values = {}) {
if (values.constructor !== Object) {
values = {
path: values
}
}
super(options)
super(values)
/** @type {String} */ this.type
/** @type {String} */ this.path
}

View File

@@ -6,8 +6,8 @@ export default class PathSymbolEntity extends IEntity {
value: String,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {String} */ this.value
}

View File

@@ -83,8 +83,8 @@ export default class PinEntity extends IEntity {
: entity
}
constructor(options = {}) {
super(options)
constructor(values = {}) {
super(values)
/** @type {GuidEntity} */ this.PinId
/** @type {String} */ this.PinName
/** @type {LocalizedTextEntity | String} */ this.PinFriendlyName

View File

@@ -9,8 +9,8 @@ export default class PinReferenceEntity extends IEntity {
pinGuid: GuidEntity,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {PathSymbolEntity} */ this.objectName
/** @type {GuidEntity} */ this.pinGuid
}

View File

@@ -8,7 +8,7 @@ export default class RotatorEntity extends IEntity {
Y: Number,
}
constructor(values = {}) {
constructor(values) {
super(values)
/** @type {Number} */ this.R
/** @type {Number} */ this.P

13
js/entity/SymbolEntity.js Normal file
View File

@@ -0,0 +1,13 @@
import IEntity from "./IEntity"
export default class SymbolEntity extends IEntity {
static attributes = {
value: String
}
constructor(values) {
super(values)
/** @type {String} */ this.value
}
}

View File

@@ -7,10 +7,9 @@ export default class RealUnitEntity extends IEntity {
value: 0,
}
/** @param {Object | Number | String} options */
constructor(options = 0) {
super(options)
/** @type {Number} */
/** @param {Object | Number | String} values */
constructor(values = 0) {
super(values)
this.value = Utility.clamp(this.value, 0, 1)
}
@@ -21,4 +20,4 @@ export default class RealUnitEntity extends IEntity {
toString() {
return this.value.toFixed(6)
}
}
}

View File

@@ -7,7 +7,7 @@ export default class UnknownKeysEntity extends IEntity {
lookbehind: new TypeInitialization(String, false, "", false, true)
}
constructor(values = {}) {
constructor(values) {
super(values)
/** @type {String} */ this.lookbehind
}

View File

@@ -11,7 +11,7 @@ export default class VariableReferenceEntity extends IEntity {
bSelfContext: new TypeInitialization(Boolean, false, false)
}
constructor(values = {}) {
constructor(values) {
super(values)
/** @type {String} */ this.MemberName
/** @type {GuidEntity} */ this.GuidEntity

View File

@@ -8,8 +8,8 @@ export default class VectorEntity extends IEntity {
Z: Number,
}
constructor(options = {}) {
super(options)
constructor(values) {
super(values)
/** @type {Number} */ this.X
/** @type {Number} */ this.Y
/** @type {Number} */ this.Z

View File

@@ -20,9 +20,9 @@ export default class GeneralSerializer extends ISerializer {
* @param {(value: String, entity: T) => String} wrap
* @param {AnyValueConstructor<T>} entityType
*/
constructor(wrap, entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) {
constructor(wrap, entityType, attributePrefix, attributeSeparator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) {
wrap = wrap ?? (v => `(${v})`)
super(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter)
super(entityType, attributePrefix, attributeSeparator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter)
this.wrap = wrap
}
@@ -35,6 +35,7 @@ export default class GeneralSerializer extends ISerializer {
let grammar = Grammar.getGrammarForType(ISerializer.grammar, this.entityType)
const parseResult = grammar.parse(value)
if (!parseResult.status) {
// @ts-expect-error
throw new Error(`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}.`)
}
return parseResult.value

View File

@@ -18,6 +18,7 @@ import RealUnitEntity from "../entity/UnitRealEntity"
import RotatorEntity from "../entity/RotatorEntity"
import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity"
import SimpleSerializationVectorEntity from "../entity/SimpleSerializationVectorEntity"
import SymbolEntity from "../entity/SymbolEntity"
import TypeInitialization from "../entity/TypeInitialization"
import UnionType from "../entity/UnionType"
import UnknownKeysEntity from "../entity/UnknownKeysEntity"
@@ -92,6 +93,8 @@ export default class Grammar {
return r.SimpleSerializationVector
case String:
return r.String
case SymbolEntity:
return r.Symbol
case UnionType:
return attributeType.types
.map(v => Grammar.getGrammarForType(r, Utility.getType(v)))
@@ -242,6 +245,9 @@ export default class Grammar {
/** @param {Grammar} r */
PathSymbolOptSpaces = r => P.regex(/[0-9\w]+(?: [0-9\w]+)+|[0-9\w]+/).map(v => new PathSymbolEntity({ value: v }))
/** @param {Grammar} r */
Symbol = r => P.regex(/\w+/).map(v => new SymbolEntity({ value: v }))
/** @param {Grammar} r */
ObjectReference = r => P.alt(
r.None,
@@ -304,6 +310,7 @@ export default class Grammar {
r.LinearColor,
r.UnknownKeys,
r.ObjectReference,
r.Symbol,
)
/** @param {Grammar} r */

View File

@@ -21,15 +21,15 @@ export default class ISerializer {
/** @param {AnyValueConstructor<T>} entityType */
constructor(
entityType,
prefix = "",
separator = ",",
attributePrefix = "",
attributeSeparator = ",",
trailingSeparator = false,
attributeValueConjunctionSign = "=",
attributeKeyPrinter = k => k.join(".")
) {
this.entityType = entityType
this.prefix = prefix
this.separator = separator
this.attributePrefix = attributePrefix
this.attributeSeparator = attributeSeparator
this.trailingSeparator = trailingSeparator
this.attributeValueConjunctionSign = attributeValueConjunctionSign
this.attributeKeyPrinter = attributeKeyPrinter
@@ -94,12 +94,12 @@ export default class ISerializer {
const value = object[property]
if (value?.constructor === Object) {
// Recursive call when finding an object
result += (result.length ? this.separator : "")
result += (result.length ? this.attributeSeparator : "")
+ this.subWrite(entity, fullKey, value, insideString)
} else if (value !== undefined && this.showProperty(entity, object, fullKey, value)) {
const isSerialized = Utility.isSerialized(entity, fullKey)
result += (result.length ? this.separator : "")
+ this.prefix
result += (result.length ? this.attributeSeparator : "")
+ this.attributePrefix
+ this.attributeKeyPrinter(fullKey)
+ this.attributeValueConjunctionSign
+ (
@@ -111,7 +111,7 @@ export default class ISerializer {
}
if (this.trailingSeparator && result.length && fullKey.length === 1) {
// append separator at the end if asked and there was printed content
result += this.separator
result += this.attributeSeparator
}
return result
}

View File

@@ -47,8 +47,8 @@ export default class ObjectSerializer extends ISerializer {
${this.subWrite(entity, [], object, insideString)
+ object
.CustomProperties.map(pin =>
this.separator
+ this.prefix
this.attributeSeparator
+ this.attributePrefix
+ "CustomProperties "
+ SerializerFactory.getSerializer(PinEntity).serialize(pin)
)

View File

@@ -20,6 +20,7 @@ import RotatorEntity from "../entity/RotatorEntity"
import SerializerFactory from "./SerializerFactory"
import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity"
import SimpleSerializationVectorEntity from "../entity/SimpleSerializationVectorEntity"
import SymbolEntity from "../entity/SymbolEntity"
import ToStringSerializer from "./ToStringSerializer"
import UnknownKeysEntity from "../entity/UnknownKeysEntity"
import Utility from "../Utility"
@@ -193,6 +194,11 @@ export default function initializeSerializerFactory() {
)
)
SerializerFactory.registerSerializer(
SymbolEntity,
new ToStringSerializer(SymbolEntity)
)
SerializerFactory.registerSerializer(
UnknownKeysEntity,
new GeneralSerializer((string, entity) => `${entity.lookbehind ?? ""}(${string})`, UnknownKeysEntity)

View File

@@ -164,8 +164,12 @@ export default class LinkTemplate extends IFromToPositionedTemplate {
</svg>
${this.element.linkMessageIcon || this.element.linkMessageText ? html`
<div class="ueb-link-message">
<span class="ueb-link-message-icon">${this.element.linkMessageIcon}</span>
<span class="ueb-link-message-text">${this.element.linkMessageText}</span>
${this.element.linkMessageIcon !== nothing ? html`
<span class="ueb-link-message-icon">${this.element.linkMessageIcon}</span>
` : nothing}
${this.element.linkMessageText !== nothing ? html`
<span class="ueb-link-message-text">${this.element.linkMessageText}</span>
` : nothing}
</div>
` : nothing}
`