mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-23 15:24:45 +08:00
Naming
This commit is contained in:
@@ -8,7 +8,7 @@ export default class GraphEntity extends HTMLElement {
|
||||
*/
|
||||
constructor(template) {
|
||||
super()
|
||||
/** @type {import("./UEBlueprint").EBlueprint}" */
|
||||
/** @type {import("./UEBlueprint").default}" */
|
||||
this.blueprint = null
|
||||
this.template = template
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import SelectableDraggable from "./SelectableDraggable"
|
||||
import NodeTemplate from "./template/NodeTemplate"
|
||||
|
||||
export default class UEBlueprintObject extends SelectableDraggable {
|
||||
export default class GraphNode extends SelectableDraggable {
|
||||
|
||||
constructor() {
|
||||
super(new NodeTemplate())
|
||||
@@ -21,4 +21,4 @@ export default class UEBlueprintObject extends SelectableDraggable {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('u-object', UEBlueprintObject)
|
||||
customElements.define('u-object', GraphNode)
|
||||
@@ -8,7 +8,7 @@ import GraphEntity from "./GraphEntity"
|
||||
import BlueprintTemplate from "./template/BlueprintTemplate"
|
||||
|
||||
/**
|
||||
* @typedef {import("./UEBlueprintObject").default} UEBlueprintObject
|
||||
* @typedef {import("./GraphNode").default} GrapNode
|
||||
*/
|
||||
export default class UEBlueprint extends GraphEntity {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class UEBlueprint extends GraphEntity {
|
||||
|
||||
constructor() {
|
||||
super(new BlueprintTemplate())
|
||||
/** @type {UEBlueprintObject[]}" */
|
||||
/** @type {GrapNode[]}" */
|
||||
this.nodes = new Array()
|
||||
this.expandGridSize = 400
|
||||
/** @type {HTMLElement} */
|
||||
@@ -44,7 +44,7 @@ export default class UEBlueprint extends GraphEntity {
|
||||
/** @type {FastSelectionModel} */
|
||||
this.selectionModel = null
|
||||
let self = this
|
||||
/** @type {(node: UEBlueprintObject) => BoundariesInfo} */
|
||||
/** @type {(node: GrapNode) => BoundariesInfo} */
|
||||
this.nodeBoundariesSupplier = (node) => {
|
||||
let rect = node.getBoundingClientRect()
|
||||
let gridRect = this.nodesContainerElement.getBoundingClientRect()
|
||||
@@ -57,7 +57,7 @@ export default class UEBlueprint extends GraphEntity {
|
||||
secondarySup: (rect.bottom - gridRect.bottom) * scaleCorrection
|
||||
}
|
||||
}
|
||||
/** @type {(node: UEBlueprintObject, selected: bool) => void}} */
|
||||
/** @type {(node: GrapNode, selected: bool) => void}} */
|
||||
this.nodeSelectToggleFunction = (node, selected) => {
|
||||
node.setSelected(selected)
|
||||
}
|
||||
@@ -331,7 +331,7 @@ export default class UEBlueprint extends GraphEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {...UEBlueprintObject} blueprintNodes
|
||||
* @param {...GrapNode} blueprintNodes
|
||||
*/
|
||||
addNode(...blueprintNodes) {
|
||||
[...blueprintNodes].reduce(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import UEBlueprint from "./UEBlueprint"
|
||||
import UEBlueprintObject from "./UEBlueprintObject"
|
||||
import GraphPin from "./GraphPin"
|
||||
import GraphNode from "./GraphNode"
|
||||
|
||||
export { UEBlueprint as UEBlueprint, UEBlueprintObject, GraphPin as UGraphPin }
|
||||
export { UEBlueprint as UEBlueprint, GraphNode as GraphNode, GraphPin as UGraphPin }
|
||||
@@ -5,7 +5,7 @@ export default class MouseWheel extends Pointing {
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @param {import("../UEBlueprint").EBlueprint} blueprint
|
||||
* @param {import("../UEBlueprint").default} blueprint
|
||||
* @param {Object} options
|
||||
*/
|
||||
constructor(target, blueprint, options) {
|
||||
|
||||
@@ -5,7 +5,7 @@ export default class Pointing {
|
||||
constructor(target, blueprint, options) {
|
||||
/** @type {HTMLElement} */
|
||||
this.target = target
|
||||
/** @type {import("../UEBlueprint").EBlueprint}" */
|
||||
/** @type {import("../UEBlueprint").default}" */
|
||||
this.blueprint = blueprint
|
||||
this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
<body>
|
||||
<div>Hello</div>
|
||||
<script type="module">
|
||||
import { UEBlueprint, UEBlueprintObject, UGraphPin } from "./ueblueprint.js"
|
||||
import { UEBlueprint, GraphNode, UGraphPin } from "./ueblueprint.js"
|
||||
let blueprint = new UEBlueprint()
|
||||
|
||||
let node0 = new UEBlueprintObject(); node0.setLocation([985, 393]); let node1 = new UEBlueprintObject(); node1.setLocation([999, 114]); let node2 = new UEBlueprintObject(); node2.setLocation([811, 253]); let node3 = new UEBlueprintObject(); node3.setLocation([802, 146]); let node4 = new UEBlueprintObject(); node4.setLocation([597, 105]); let node5 = new UEBlueprintObject(); node5.setLocation([789, 233]); let node6 = new UEBlueprintObject(); node6.setLocation([549, 289]); let node7 = new UEBlueprintObject(); node7.setLocation([678, 193]); let node8 = new UEBlueprintObject(); node8.setLocation([1078, 244]); let node9 = new UEBlueprintObject(); node9.setLocation([751, 151]); let node10 = new UEBlueprintObject(); node10.setLocation([1046, -14]); let node11 = new UEBlueprintObject(); node11.setLocation([714, 267]); let node12 = new UEBlueprintObject(); node12.setLocation([767, 36]); let node13 = new UEBlueprintObject(); node13.setLocation([807, 219]); let node14 = new UEBlueprintObject(); node14.setLocation([1031, 70]); let node15 = new UEBlueprintObject(); node15.setLocation([906, 389]); let node16 = new UEBlueprintObject(); node16.setLocation([936, 131]); let node17 = new UEBlueprintObject(); node17.setLocation([689, 249]); let node18 = new UEBlueprintObject(); node18.setLocation([1153, 343]); let node19 = new UEBlueprintObject(); node19.setLocation([626, 209]); blueprint.addNode(node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, node14, node15, node16, node17, node18, node19);
|
||||
let node0 = new GraphNode(); node0.setLocation([985, 393]); let node1 = new GraphNode(); node1.setLocation([999, 114]); let node2 = new GraphNode(); node2.setLocation([811, 253]); let node3 = new GraphNode(); node3.setLocation([802, 146]); let node4 = new GraphNode(); node4.setLocation([597, 105]); let node5 = new GraphNode(); node5.setLocation([789, 233]); let node6 = new GraphNode(); node6.setLocation([549, 289]); let node7 = new GraphNode(); node7.setLocation([678, 193]); let node8 = new GraphNode(); node8.setLocation([1078, 244]); let node9 = new GraphNode(); node9.setLocation([751, 151]); let node10 = new GraphNode(); node10.setLocation([1046, -14]); let node11 = new GraphNode(); node11.setLocation([714, 267]); let node12 = new GraphNode(); node12.setLocation([767, 36]); let node13 = new GraphNode(); node13.setLocation([807, 219]); let node14 = new GraphNode(); node14.setLocation([1031, 70]); let node15 = new GraphNode(); node15.setLocation([906, 389]); let node16 = new GraphNode(); node16.setLocation([936, 131]); let node17 = new GraphNode(); node17.setLocation([689, 249]); let node18 = new GraphNode(); node18.setLocation([1153, 343]); let node19 = new GraphNode(); node19.setLocation([626, 209]); blueprint.addNode(node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, node14, node15, node16, node17, node18, node19);
|
||||
|
||||
document.querySelector('body').appendChild(blueprint)
|
||||
let Pin = new UGraphPin()
|
||||
let Pin = new GraphPin()
|
||||
let a = Pin.serialize()
|
||||
let c = "ciao"
|
||||
</script>
|
||||
|
||||
212
ueblueprint.js
212
ueblueprint.js
@@ -13,7 +13,7 @@ class Pointing {
|
||||
constructor(target, blueprint, options) {
|
||||
/** @type {HTMLElement} */
|
||||
this.target = target;
|
||||
/** @type {import("../UEBlueprint").EBlueprint}" */
|
||||
/** @type {import("../UEBlueprint").default}" */
|
||||
this.blueprint = blueprint;
|
||||
this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class MouseWheel extends Pointing {
|
||||
/**
|
||||
*
|
||||
* @param {HTMLElement} target
|
||||
* @param {import("../UEBlueprint").EBlueprint} blueprint
|
||||
* @param {import("../UEBlueprint").default} blueprint
|
||||
* @param {Object} options
|
||||
*/
|
||||
constructor(target, blueprint, options) {
|
||||
@@ -526,7 +526,7 @@ class GraphEntity extends HTMLElement {
|
||||
*/
|
||||
constructor(template) {
|
||||
super();
|
||||
/** @type {import("./UEBlueprint").EBlueprint}" */
|
||||
/** @type {import("./UEBlueprint").default}" */
|
||||
this.blueprint = null;
|
||||
this.template = template;
|
||||
}
|
||||
@@ -613,7 +613,7 @@ class BlueprintTemplate extends Template {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {import("./UEBlueprintObject").default} UEBlueprintObject
|
||||
* @typedef {import("./GraphNode").default} GrapNode
|
||||
*/
|
||||
class UEBlueprint extends GraphEntity {
|
||||
|
||||
@@ -623,7 +623,7 @@ class UEBlueprint extends GraphEntity {
|
||||
|
||||
constructor() {
|
||||
super(new BlueprintTemplate());
|
||||
/** @type {UEBlueprintObject[]}" */
|
||||
/** @type {GrapNode[]}" */
|
||||
this.nodes = new Array();
|
||||
this.expandGridSize = 400;
|
||||
/** @type {HTMLElement} */
|
||||
@@ -648,7 +648,7 @@ class UEBlueprint extends GraphEntity {
|
||||
this.headerElement = null;
|
||||
/** @type {FastSelectionModel} */
|
||||
this.selectionModel = null;
|
||||
/** @type {(node: UEBlueprintObject) => BoundariesInfo} */
|
||||
/** @type {(node: GrapNode) => BoundariesInfo} */
|
||||
this.nodeBoundariesSupplier = (node) => {
|
||||
let rect = node.getBoundingClientRect();
|
||||
let gridRect = this.nodesContainerElement.getBoundingClientRect();
|
||||
@@ -661,7 +661,7 @@ class UEBlueprint extends GraphEntity {
|
||||
secondarySup: (rect.bottom - gridRect.bottom) * scaleCorrection
|
||||
}
|
||||
};
|
||||
/** @type {(node: UEBlueprintObject, selected: bool) => void}} */
|
||||
/** @type {(node: GrapNode, selected: bool) => void}} */
|
||||
this.nodeSelectToggleFunction = (node, selected) => {
|
||||
node.setSelected(selected);
|
||||
};
|
||||
@@ -935,7 +935,7 @@ class UEBlueprint extends GraphEntity {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {...UEBlueprintObject} blueprintNodes
|
||||
* @param {...GrapNode} blueprintNodes
|
||||
*/
|
||||
addNode(...blueprintNodes) {
|
||||
[...blueprintNodes].reduce(
|
||||
@@ -952,6 +952,101 @@ class UEBlueprint extends GraphEntity {
|
||||
|
||||
customElements.define('u-blueprint', UEBlueprint);
|
||||
|
||||
class Guid {
|
||||
static generateGuid() {
|
||||
let result = "";
|
||||
let random = new Uint32Array(4);
|
||||
crypto.getRandomValues(random);
|
||||
random.forEach(n => {
|
||||
this.result += ('00000000' + n.toString(16).toUpperCase()).slice(-8);
|
||||
});
|
||||
return result
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
if (guid?.constructor?.name === 'String') {
|
||||
this.value = guid;
|
||||
} else if (guid?.constructor?.name === 'FGuid') {
|
||||
this.value = guid.value;
|
||||
} else {
|
||||
this.value = Guid.generateGuid();
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
|
||||
class GraphPin {
|
||||
constructor(Options) {
|
||||
this.PinId = new Guid(Options?.PinId);
|
||||
this.PinName = Options?.PinName ?? "";
|
||||
this.PinToolTip = Options?.PinToolTip ?? "";
|
||||
this.PinType = {
|
||||
PinCategory: Options?.PinType?.PinCategory ?? "object",
|
||||
PinSubCategory: Options?.PinType?.PinSubCategory ?? "",
|
||||
PinSubCategoryMemberReference: Options?.PinType?.PinSubCategoryMemberReference ?? "",
|
||||
PinValueType: Options?.PinType?.PinValueType ?? "",
|
||||
PinValueType: Options?.PinType?.ContainerType ?? "None",
|
||||
bIsReference: Options?.PinType?.bIsReference ?? false,
|
||||
bIsConst: Options?.PinType?.bIsConst ?? false,
|
||||
bIsWeakPointer: Options?.PinType?.bIsWeakPointer ?? false,
|
||||
bIsUObjectWrapper: Options?.PinType?.bIsUObjectWrapper ?? false
|
||||
};
|
||||
this.LinkedTo = Options?.LinkedTo ?? null;
|
||||
this.DefaultValue = Options?.DefaultValue ?? true;
|
||||
this.AutogeneratedDefaultValue = Options?.AutogeneratedDefaultValue ?? false;
|
||||
this.PersistentGuid = Options?.PersistentGuid ?? null;
|
||||
this.bHidden = Options?.bHidden ?? false;
|
||||
this.bNotConnectable = Options?.bNotConnectable ?? false;
|
||||
this.bDefaultValueIsReadOnly = Options?.bDefaultValueIsReadOnly ?? false;
|
||||
this.bDefaultValueIsIgnored = Options?.bDefaultValueIsIgnored ?? false;
|
||||
this.bAdvancedView = Options?.bAdvancedView ?? false;
|
||||
this.bOrphanedPin = Options?.bOrphanedPin ?? false;
|
||||
}
|
||||
|
||||
static serializeValue(value) {
|
||||
// No quotes
|
||||
if (value === null) {
|
||||
return '()'
|
||||
}
|
||||
if (value?.constructor?.name === 'Boolean') {
|
||||
return value ? 'True' : 'False'
|
||||
}
|
||||
if (value?.constructor?.name === 'ETypesNames' || value?.constructor?.name === 'FGuid') {
|
||||
return value.toString()
|
||||
}
|
||||
// Quotes
|
||||
if (value?.constructor?.name === 'String') {
|
||||
return `"${value}"`
|
||||
}
|
||||
}
|
||||
|
||||
static subSerialize(prefix, object) {
|
||||
let result = "";
|
||||
prefix += prefix != "" ? "." : "";
|
||||
for (const property in object) {
|
||||
if (object[property]?.constructor?.name === 'Object') {
|
||||
result += GraphPin.subSerialize(prefix + property, object[property]);
|
||||
} else {
|
||||
result += `${prefix + property}=${GraphPin.serializeValue(object[property])},`;
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
serialize() {
|
||||
let result = `CustomProperties Pin (${this.constructor.subSerialize('', this)})`;
|
||||
return result
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.serialize()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Drag extends MouseClickDrag {
|
||||
constructor(target, blueprint, options) {
|
||||
super(target, blueprint, options);
|
||||
@@ -1123,7 +1218,7 @@ class NodeTemplate extends Template {
|
||||
}
|
||||
}
|
||||
|
||||
class UEBlueprintObject extends SelectableDraggable {
|
||||
class GraphNode extends SelectableDraggable {
|
||||
|
||||
constructor() {
|
||||
super(new NodeTemplate());
|
||||
@@ -1143,101 +1238,6 @@ class UEBlueprintObject extends SelectableDraggable {
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('u-object', UEBlueprintObject);
|
||||
customElements.define('u-object', GraphNode);
|
||||
|
||||
class Guid {
|
||||
static generateGuid() {
|
||||
let result = "";
|
||||
let random = new Uint32Array(4);
|
||||
crypto.getRandomValues(random);
|
||||
random.forEach(n => {
|
||||
this.result += ('00000000' + n.toString(16).toUpperCase()).slice(-8);
|
||||
});
|
||||
return result
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
if (guid?.constructor?.name === 'String') {
|
||||
this.value = guid;
|
||||
} else if (guid?.constructor?.name === 'FGuid') {
|
||||
this.value = guid.value;
|
||||
} else {
|
||||
this.value = Guid.generateGuid();
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
|
||||
class GraphPin {
|
||||
constructor(Options) {
|
||||
this.PinId = new Guid(Options?.PinId);
|
||||
this.PinName = Options?.PinName ?? "";
|
||||
this.PinToolTip = Options?.PinToolTip ?? "";
|
||||
this.PinType = {
|
||||
PinCategory: Options?.PinType?.PinCategory ?? "object",
|
||||
PinSubCategory: Options?.PinType?.PinSubCategory ?? "",
|
||||
PinSubCategoryMemberReference: Options?.PinType?.PinSubCategoryMemberReference ?? "",
|
||||
PinValueType: Options?.PinType?.PinValueType ?? "",
|
||||
PinValueType: Options?.PinType?.ContainerType ?? "None",
|
||||
bIsReference: Options?.PinType?.bIsReference ?? false,
|
||||
bIsConst: Options?.PinType?.bIsConst ?? false,
|
||||
bIsWeakPointer: Options?.PinType?.bIsWeakPointer ?? false,
|
||||
bIsUObjectWrapper: Options?.PinType?.bIsUObjectWrapper ?? false
|
||||
};
|
||||
this.LinkedTo = Options?.LinkedTo ?? null;
|
||||
this.DefaultValue = Options?.DefaultValue ?? true;
|
||||
this.AutogeneratedDefaultValue = Options?.AutogeneratedDefaultValue ?? false;
|
||||
this.PersistentGuid = Options?.PersistentGuid ?? null;
|
||||
this.bHidden = Options?.bHidden ?? false;
|
||||
this.bNotConnectable = Options?.bNotConnectable ?? false;
|
||||
this.bDefaultValueIsReadOnly = Options?.bDefaultValueIsReadOnly ?? false;
|
||||
this.bDefaultValueIsIgnored = Options?.bDefaultValueIsIgnored ?? false;
|
||||
this.bAdvancedView = Options?.bAdvancedView ?? false;
|
||||
this.bOrphanedPin = Options?.bOrphanedPin ?? false;
|
||||
}
|
||||
|
||||
static serializeValue(value) {
|
||||
// No quotes
|
||||
if (value === null) {
|
||||
return '()'
|
||||
}
|
||||
if (value?.constructor?.name === 'Boolean') {
|
||||
return value ? 'True' : 'False'
|
||||
}
|
||||
if (value?.constructor?.name === 'ETypesNames' || value?.constructor?.name === 'FGuid') {
|
||||
return value.toString()
|
||||
}
|
||||
// Quotes
|
||||
if (value?.constructor?.name === 'String') {
|
||||
return `"${value}"`
|
||||
}
|
||||
}
|
||||
|
||||
static subSerialize(prefix, object) {
|
||||
let result = "";
|
||||
prefix += prefix != "" ? "." : "";
|
||||
for (const property in object) {
|
||||
if (object[property]?.constructor?.name === 'Object') {
|
||||
result += GraphPin.subSerialize(prefix + property, object[property]);
|
||||
} else {
|
||||
result += `${prefix + property}=${GraphPin.serializeValue(object[property])},`;
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
serialize() {
|
||||
let result = `CustomProperties Pin (${this.constructor.subSerialize('', this)})`;
|
||||
return result
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.serialize()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { UEBlueprint, UEBlueprintObject, GraphPin as UGraphPin };
|
||||
export { GraphNode, UEBlueprint, GraphPin as UGraphPin };
|
||||
|
||||
Reference in New Issue
Block a user