diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index 54cb39f..81635ec 100755 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -1046,6 +1046,29 @@ class Utility { gridSize * Math.round(location[1] / gridSize) ] } + + /** + * @template T + * @param {Array} a + * @param {Array} b + */ + static mergeArrays(a = [], b = []) { + let result = []; + for (let j = 0; j < b.length; ++j) { + for (let i = 0; i < a.length; ++i) { + if (a[i] == b[j]) { + result.push(...a.splice(0, i), ...b.splice(0, j), ...a.splice(0, 1)); + j = 0; + i = 0; + b.shift(); + break + } + } + } + return [...(new Set(result.concat(...a, ...b)))] + } + + } // @ts-check @@ -1071,7 +1094,10 @@ class IEntity { const defineAllAttributes = (prefix, target, properties, values) => { let fullKey = prefix.concat(""); const last = fullKey.length - 1; - for (let property of Object.getOwnPropertyNames(properties)) { + for (let property of Utility.mergeArrays( + Object.getOwnPropertyNames(properties), + Object.getOwnPropertyNames(values ?? {}) + )) { fullKey[last] = property; let defaultValue = properties[property]; const defaultType = (defaultValue instanceof TypeInitialization) @@ -1099,7 +1125,7 @@ class IEntity { } if (defaultValue instanceof TypeInitialization) { if (!defaultValue.showDefault) { - target[property] = undefined; // to preserve the order + target[property] = undefined; // Declare undefined to preserve the order or attributes continue } defaultValue = defaultValue.value; @@ -1492,6 +1518,7 @@ class ObjectEntity extends IEntity { NodePosX: IntegerEntity, NodePosY: IntegerEntity, AdvancedPinDisplay: new TypeInitialization(IdentifierEntity, false, null), + EnabledState: new TypeInitialization(IdentifierEntity, false, null), NodeGuid: GuidEntity, ErrorType: new TypeInitialization(IntegerEntity, false), ErrorMsg: new TypeInitialization(String, false, ""), @@ -1512,6 +1539,7 @@ class ObjectEntity extends IEntity { /** @type {IntegerEntity} */ this.NodePosX; /** @type {IntegerEntity} */ this.NodePosY; /** @type {IdentifierEntity} */ this.AdvancedPinDisplay; + /** @type {IdentifierEntity} */ this.EnabledState; /** @type {GuidEntity} */ this.NodeGuid; /** @type {IntegerEntity} */ this.ErrorType; /** @type {String} */ this.ErrorMsg; diff --git a/js/Utility.js b/js/Utility.js index 442f0eb..ea66b67 100755 --- a/js/Utility.js +++ b/js/Utility.js @@ -118,4 +118,27 @@ export default class Utility { gridSize * Math.round(location[1] / gridSize) ] } + + /** + * @template T + * @param {Array} a + * @param {Array} b + */ + static mergeArrays(a = [], b = []) { + let result = [] + for (let j = 0; j < b.length; ++j) { + for (let i = 0; i < a.length; ++i) { + if (a[i] == b[j]) { + result.push(...a.splice(0, i), ...b.splice(0, j), ...a.splice(0, 1)) + j = 0 + i = 0 + b.shift() + break + } + } + } + return [...(new Set(result.concat(...a, ...b)))] + } + + } diff --git a/js/entity/IEntity.js b/js/entity/IEntity.js index d7d6e37..180647c 100644 --- a/js/entity/IEntity.js +++ b/js/entity/IEntity.js @@ -24,7 +24,10 @@ export default class IEntity { const defineAllAttributes = (prefix, target, properties, values) => { let fullKey = prefix.concat("") const last = fullKey.length - 1 - for (let property of Object.getOwnPropertyNames(properties)) { + for (let property of Utility.mergeArrays( + Object.getOwnPropertyNames(properties), + Object.getOwnPropertyNames(values ?? {}) + )) { fullKey[last] = property let defaultValue = properties[property] const defaultType = (defaultValue instanceof TypeInitialization) diff --git a/js/entity/ObjectEntity.js b/js/entity/ObjectEntity.js index 8f066ea..4c4afcb 100755 --- a/js/entity/ObjectEntity.js +++ b/js/entity/ObjectEntity.js @@ -23,6 +23,7 @@ export default class ObjectEntity extends IEntity { NodePosX: IntegerEntity, NodePosY: IntegerEntity, AdvancedPinDisplay: new TypeInitialization(IdentifierEntity, false, null), + EnabledState: new TypeInitialization(IdentifierEntity, false, null), NodeGuid: GuidEntity, ErrorType: new TypeInitialization(IntegerEntity, false), ErrorMsg: new TypeInitialization(String, false, ""), @@ -43,6 +44,7 @@ export default class ObjectEntity extends IEntity { /** @type {IntegerEntity} */ this.NodePosX /** @type {IntegerEntity} */ this.NodePosY /** @type {IdentifierEntity} */ this.AdvancedPinDisplay + /** @type {IdentifierEntity} */ this.EnabledState /** @type {GuidEntity} */ this.NodeGuid /** @type {IntegerEntity} */ this.ErrorType /** @type {String} */ this.ErrorMsg