Compare commits

...

8 Commits

Author SHA1 Message Date
barsdeveloper
3a68b2863c Fix indentation 2025-04-04 23:52:08 +03:00
barsdeveloper
9c0e172630 Sound cue nodes and bottom graph type right text 2025-04-04 23:48:34 +03:00
barsdeveloper
fb7fc9fc66 Required mark for PCG pins 2025-04-03 23:40:52 +03:00
BarsDev
5ef585eb34 Update README.md 2025-02-26 13:19:39 +02:00
BarsDev
db53d20762 Update README.md 2025-02-26 11:00:24 +02:00
BarsDev
d1cd8d4b3e Update CONTRIBUTING.md 2025-02-26 10:56:15 +02:00
barsdeveloper
c4911fe583 More knots fixes 2025-02-09 16:25:19 +02:00
BarsDev
6ba2705386 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
2025-02-07 00:36:03 +02:00
349 changed files with 10467 additions and 6485 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
.vscode/extensions.json vendored Normal file → Executable file
View File

27
.vscode/launch.json vendored
View File

@@ -5,31 +5,12 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Launch index.html", "name": "Launch Blueprintue",
"type": "firefox", "type": "firefox",
"request": "launch", "request": "launch",
"reAttach": true, "reAttach": true,
"file": "${workspaceFolder}/index.html" "url": "http://127.0.0.1:8080/debug.html",
"tmpDir": "~/.tmp/"
}, },
{
"name": "Launch localhost",
"type": "firefox",
"request": "launch",
"reAttach": true,
"url": "http://localhost/index.html",
"webRoot": "${workspaceFolder}"
},
{
"name": "Attach",
"type": "firefox",
"request": "attach"
},
{
"name": "Launch WebExtension",
"type": "firefox",
"request": "launch",
"reAttach": true,
"addonPath": "${workspaceFolder}"
}
] ]
} }

0
.vscode/settings.json vendored Normal file → Executable file
View File

20
CONTRIBUTING.md Normal file → Executable file
View File

@@ -47,20 +47,28 @@ And refresh the HTML page possibly holding `Shift`.
There are a few concepts that must be assimilated in order to understand the design. Those concepts are in general each mapped into a subfolder in `js/`. There are a few concepts that must be assimilated in order to understand the design. Those concepts are in general each mapped into a subfolder in `js/`.
### Entity ### Entity
An Entity is just a data holder object that does not really do anything by itself, it has a purely information storage related purpose. The top class at the hierarchy of entities is `IEntity`. It is responsible for the initialization of the entity in its constructor according to the information contained in the object provided as an argument or from the attributes static field. This ended up being a somewhat wacky runtime type system. Each subclass can specify its attributes in the form of a static member variable of type vanilla object where each entry is a subclass of IEntity. The entities moreover are responsible for their serialization and deserialization: each class has a `serialize()` method and a `grammar` attribute to parse entities. An **Entity** is a simple object that only stores data, it doesnt perform any actions. The base class for all entities is `IEntity`. Its main job is to initialize an entity using data from an input object or a predefined attributes field. This setup has resulted in a somewhat unconventional runtime type system. Each subclass of `IEntity` defines its `attributes` as a object static field, where each entry represents another `IEntity` subclass (class object, not instance). Additionally, entities handle their own serialization and deserialization using the `serialize()` method and a `grammar` attribute, which parses entity data from the blueprint code.
### Element ### Element
Each element is just a custom HTML element type and its tag name is defined in the class file. The top level of the hierarchy is `IElement` and it inherits from `LitElement`. This class can be thought as an association between an entity and a template (and those are the arguments of the constructor). The top class `IElement` does propagate the lifecycle provided by `LitElement` to the template so that a template can hook into it. An **Element** is a custom HTML element, with its tag name defined in the class file. At the top of the hierarchy is `IElement`, which extends `LitElement`. You can think of `IElement` as a bridge between an *Entity* and a *Template*, these are passed as arguments to its constructor. Moreover, `IElement` ensures that the lifecycle events provided by `LitElement` are passed down to the template, allowing the template to hook into them.
### Template ### Template
When looking at the Lit documentation, it might be noticed that usually HTML templates are returned as part of the `render()` method of an Element. The problem with such approach is that it makes it hard to have very different templates and UI behavior for the same element in a natural way (by means of inheritance because a custom element cannot be mapped to multiple classes). Take for example a `<ueb-pin>` in a graph node, it may or may not have any input and if it has one, the input might be a checkbox, a vector or something completely different like a texture. For this reason the responsibility to render the HTML content is moved from the Element to the Template and inheritance is replaced with composition so that two same elements can have different templates. In Lit, HTML templates are typically returned from an elements `render()` method. However, this approach makes it difficult to apply different templates and UI behaviors to the same element, since a custom element can only be associated with one class.
Templates do have access to the same lifecycle as elements have, this is implemented in the IElement class that calls, for each method in the lifecycle, the relative method in the template. Moreover the templates hierarchy can also introduce new behaviors that can be replaced by subclasses, one example of such is IInputPinTemplate. For example, consider a `<ueb-pin>` element inside a graph node. It may or may not have an input, and if it does, the input type could be text, a checkbox, a vector. To handle this flexibility, rendering is moved from the *Element* to the *Template*. Instead of using inheritance (which is limiting), we use composition, allowing the same element to have different templates.
Templates have access to the same lifecycle methods as elements. This is achieved in `IElement`, which forwards lifecycle calls to the corresponding methods in the template. The template hierarchy can introduce new behaviors that subclasses can override. For example, `IInputPinTemplate` defines behaviors that can be customized by its subclasses.
### Input ### Input
Classes used to map input events (generated from a mouse or a keyboard for example) to operations on the graph. They do model advanced user interaction (like mouse drag) that are originated by input JavaScript events. Simpler events (like click or focus), are implemented in the lit templates directly. These classes handle input events (such as mouse and keyboard interactions) and map them to operations on the graph. They support complex interactions, like dragging with the mouse, which originate from JavaScript input events. In contrast, simpler events such as click or focus are handled directly within Lit templates.
### Selection ### Selection
It contains just a few classes related exclusively to the operation of selecting nodes. It is an (arguably useless) attempt to optimize the selection in case of graphs with a very large numbers of nodes (it is not really usefull because in the case of many many nodes, the bootleneck becomes the DOM rendering, not deciding in JavaScript which nodes are selected and which are not even though this happens every frame). Selection has two models: one very simple that checks every frame all the nodes in the graph to see whether or not they are selected by the selector, and the fast model that attemps to optimize the number of nodes that are looked up at, much more complicated and not super usefull as stated before. This module contains a few classes focused solely on selecting nodes. It was originally designed to optimize selection for graphs with a very large number of nodes, but in practice, this optimization is of limited use. The real performance bottleneck in such cases is DOM rendering, not the JavaScript logic that determines which nodes are selected.
There are two selection models:
1. Simple Model: every frame, it checks all nodes in the graph to determine whether they are selected.
2. Fast Model: uses a structured index of nodes to limit lookups, reducing the need to scan the entire graph.
### Decoding
This handles blueprint interpretation, defining node *Template* classes, colors, icons, and other attributes like the title of a node.
## Code Style ## Code Style

0
LICENSE Normal file → Executable file
View File

11
README.md Normal file → Executable file
View File

@@ -1,6 +1,8 @@
# UEBlueprint # UEBlueprint
A stand alone editor implementation of the UE's Blueprint visual language. A stand alone implementation of the UE's Blueprint visual language editor
https://github.com/barsdeveloper/ueblueprint ⭐
https://www.npmjs.com/package/ueblueprint https://www.npmjs.com/package/ueblueprint
@@ -34,7 +36,7 @@ npx http-server
You can check `index.html` for a working example, the main steps are the following: You can check `index.html` for a working example, the main steps are the following:
1. Make the `dist` directory available in your website by copying it or installing through npm `npm i ueblueprint`. 1. Make the `dist` directory available in your website by copying it or installing through npm `npm i ueblueprint`.
2. Include `dist/css/ueb-style.css` stylesheet in your page. 2. Include `dist/css/ueb-style.min.css` stylesheet in your page.
3. Define eventual CSS variables. 3. Define eventual CSS variables.
```HTML ```HTML
<style> <style>
@@ -50,6 +52,11 @@ You can check `index.html` for a working example, the main steps are the followi
</script> </script>
``` ```
5. Define your blueprint by writing the code inside a `template`, inside a `ueb-blueprint` element. 5. Define your blueprint by writing the code inside a `template`, inside a `ueb-blueprint` element.
Configuration:
- Height: `<ueb-blueprint style="--ueb-height: 500px">`
- Light mode: `<ueb-blueprint class="ueb-light-mode">`
- Initial zoom: `<ueb-blueprint data-zoom="-4">`
- Graph type: `<ueb-blueprint data-type="MATERIAL FUNCTION">`
```HTML ```HTML
<ueb-blueprint> <ueb-blueprint>
<template> <template>

0
assets/fonts/roboto-bold.woff2 Normal file → Executable file
View File

0
assets/fonts/roboto-condensed-bold.woff2 Normal file → Executable file
View File

0
assets/fonts/roboto-light.woff2 Normal file → Executable file
View File

0
assets/fonts/roboto-regular.woff2 Normal file → Executable file
View File

24
debug.html Executable file
View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>UE Blueprint</title>
<link rel="stylesheet" href="dist/css/ueb-style.css">
<style>
body {
margin: 0;
padding: 0;
--ueb-height: 100vh;
}
</style>
</head>
<body>
<script type="module">
import { Blueprint } from "./dist/ueblueprint.js"
</script>
<ueb-blueprint></ueb-blueprint>
</body>
</html>

144
dist/css/ueb-style.css vendored Normal file → Executable file
View File

@@ -11,6 +11,9 @@
ueb-blueprint { ueb-blueprint {
--ueb-scale: 1; --ueb-scale: 1;
--ueb-grid-actual-size: var(--ueb-grid-size); --ueb-grid-actual-size: var(--ueb-grid-size);
--ueb-grid-line-color: #353535;
--ueb-grid-set-line-color: #161616;
--ueb-grid-axis-line-color: #000;
display: block; display: block;
position: relative; position: relative;
font-family: Roboto, Noto, Oxygen, Ubuntu, "Open Sans", "Helvetica Neue", sans-serif; font-family: Roboto, Noto, Oxygen, Ubuntu, "Open Sans", "Helvetica Neue", sans-serif;
@@ -34,6 +37,15 @@ ueb-blueprint svg {
z-index: 1; z-index: 1;
} }
.ueb-viewport-about {
margin-top: -6px;
padding: 0 8px;
align-self: center;
font-size: 20px;
font-weight: bolder;
cursor: pointer;
}
@keyframes ueb-zoom-animation { @keyframes ueb-zoom-animation {
0% { 0% {
color: #7f7f7f; color: #7f7f7f;
@@ -43,7 +55,7 @@ ueb-blueprint svg {
} }
} }
.ueb-zoom-changed .ueb-viewport-zoom { .ueb-zoom-changed .ueb-viewport-zoom {
animation: 600ms ueb-zoom-animation; animation: 1500ms ueb-zoom-animation;
} }
.ueb-viewport-zoom { .ueb-viewport-zoom {
@@ -56,6 +68,18 @@ ueb-blueprint svg {
letter-spacing: -1px; letter-spacing: -1px;
} }
.ueb-viewport-type {
position: absolute;
right: 10px;
bottom: 5px;
font-size: 60px;
font-weight: 900;
color: rgba(128, 128, 128, 0.2509803922);
font-stretch: condensed;
z-index: 1;
pointer-events: none;
}
.ueb-viewport-body { .ueb-viewport-body {
position: relative; position: relative;
height: var(--ueb-height, 30rem); height: var(--ueb-height, 30rem);
@@ -90,7 +114,6 @@ ueb-blueprint[data-scrolling=false] .ueb-grid {
ueb-blueprint.ueb-zoom--4 { ueb-blueprint.ueb-zoom--4 {
--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2); --ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2);
--ueb-node-radius: 0 !important;
} }
ueb-blueprint.ueb-zoom--6 { ueb-blueprint.ueb-zoom--6 {
@@ -145,6 +168,50 @@ ueb-selector > * {
overflow: hidden; overflow: hidden;
} }
.ueb-info-dialog {
border: 6px solid #202020;
padding: 5px 30px;
background: #121212;
color: #f0f0f0;
box-shadow: 0 2px 10px 0 #000;
}
.ueb-info-dialog a:link,
.ueb-info-dialog a:visited,
.ueb-info-dialog a:hover,
.ueb-info-dialog a:active {
outline: none;
color: #f0f0f0;
}
.ueb-info-dialog::backdrop {
background-color: rgba(0, 0, 0, 0.6274509804);
backdrop-filter: blur(4px);
}
/* Light mode */
ueb-blueprint.ueb-light-mode {
--ueb-grid-line-color: #ddd;
--ueb-grid-set-line-color: #c0c0c0;
--ueb-grid-axis-line-color: #a0a0a0;
}
ueb-blueprint.ueb-light-mode .ueb-grid {
background-color: #f6f6f6;
}
ueb-blueprint.ueb-light-mode ueb-node.ueb-node-style-glass .ueb-node-wrapper {
background-color: rgba(0, 0, 0, 0.5647058824);
}
ueb-blueprint.ueb-light-mode ueb-link .ueb-link-path {
filter: saturate(200%) brightness(0.6);
}
ueb-blueprint.ueb-light-mode .ueb-viewport-header {
background: rgba(0, 0, 0, 0.3);
color: #101010;
}
ueb-node.ueb-node-style-minimal { ueb-node.ueb-node-style-minimal {
box-shadow: none; box-shadow: none;
} }
@@ -176,9 +243,7 @@ ueb-node.ueb-node-style-minimal[data-selected=true] .ueb-node-border {
ueb-link { ueb-link {
position: absolute; position: absolute;
--ueb-link-color: rgb(var(--ueb-link-color-rgb)); --ueb-link-color: rgb(var(--ueb-link-color-rgb));
--ueb-from-input-coefficient: calc(2 * var(--ueb-from-input) - 1);
/* when from-y > to-y */ /* when from-y > to-y */
--ueb-y-reflected: clamp(0, var(--ueb-from-y) - var(--ueb-to-y) - 1, 1);
display: block; display: block;
margin-left: calc(var(--ueb-link-start) * -1px); margin-left: calc(var(--ueb-link-start) * -1px);
min-width: calc(var(--ueb-link-min-width) * 1px); min-width: calc(var(--ueb-link-min-width) * 1px);
@@ -190,12 +255,11 @@ ueb-link {
} }
ueb-link > svg { ueb-link > svg {
--ueb-y-reflected-coefficient: calc(2 * var(--ueb-y-reflected) - 1);
position: absolute; position: absolute;
width: 100% !important; width: 100% !important;
height: 100% !important; height: 100% !important;
min-height: 1px !important; min-height: 1px !important;
transform: scaleY(calc(var(--ueb-y-reflected-coefficient) * var(--ueb-from-input-coefficient))); transform: scaleX(var(--ueb-link-scale-x)) scaleY(var(--ueb-link-scale-y));
z-index: 1; z-index: 1;
} }
@@ -222,10 +286,12 @@ ueb-link[data-dragging=true] .ueb-link-message {
} }
.ueb-link-message { .ueb-link-message {
--ueb-link-message-top: calc(50% * (var(--ueb-link-scale-y) + 1) + 22px);
--ueb-link-message-left: calc(100% - var(--ueb-start-percentage) + 15px);
display: none; display: none;
position: absolute; position: absolute;
top: calc(100% * (1 - var(--ueb-y-reflected)) + 22px); top: var(--ueb-link-message-top);
left: calc((1 - var(--ueb-from-input)) * 100% + (var(--ueb-from-input-coefficient)) * var(--ueb-start-percentage) + 15px); left: var(--ueb-link-message-left);
border: 1px solid #000; border: 1px solid #000;
border-radius: 2px; border-radius: 2px;
background: linear-gradient(to bottom, #2a2a2a 0, #151515 50%, #2a2a2a 100%); background: linear-gradient(to bottom, #2a2a2a 0, #151515 50%, #2a2a2a 100%);
@@ -234,6 +300,11 @@ ueb-link[data-dragging=true] .ueb-link-message {
z-index: 1000000; z-index: 1000000;
} }
ueb-link[data-from-input=true] .ueb-link-message {
--ueb-link-message-top: calc(-50% * (var(--ueb-link-scale-y) - 1) + 22px);
--ueb-link-message-left: calc(var(--ueb-start-percentage) + 15px);
}
.ueb-link-message-icon { .ueb-link-message-icon {
display: inline-block; display: inline-block;
padding: 4px; padding: 4px;
@@ -267,10 +338,6 @@ ueb-node.ueb-node-style-comment {
min-width: 0; min-width: 0;
} }
.ueb-zoom--2 ueb-node {
box-shadow: none;
}
.ueb-node-border { .ueb-node-border {
margin: -3px; margin: -3px;
padding: 3px; padding: 3px;
@@ -310,6 +377,10 @@ ueb-node[data-selected=true] > .ueb-node-border {
overflow: hidden; overflow: hidden;
} }
.ueb-zoom--2 .ueb-node-wrapper {
background: rgb(14, 16, 10);
}
ueb-node.ueb-node-style-operation .ueb-node-wrapper { ueb-node.ueb-node-style-operation .ueb-node-wrapper {
grid-template-rows: min-content auto auto min-content min-content; grid-template-rows: min-content auto auto min-content min-content;
grid-template-columns: 50% 0% 1fr; grid-template-columns: 50% 0% 1fr;
@@ -335,7 +406,6 @@ ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-draggable {
} }
.ueb-zoom--2 .ueb-node-wrapper { .ueb-zoom--2 .ueb-node-wrapper {
box-shadow: none;
padding: 0; padding: 0;
background: #101010; background: #101010;
} }
@@ -372,10 +442,6 @@ ueb-node.ueb-node-style-event .ueb-node-top {
background: linear-gradient(rgba(255, 255, 255, 0.1882352941) 1px, transparent 1px), linear-gradient(170deg, rgb(var(--ueb-node-color)) 0%, rgb(var(--ueb-node-color)) 50%, transparent 100%); background: linear-gradient(rgba(255, 255, 255, 0.1882352941) 1px, transparent 1px), linear-gradient(170deg, rgb(var(--ueb-node-color)) 0%, rgb(var(--ueb-node-color)) 50%, transparent 100%);
} }
.ueb-zoom--2 .ueb-node-top {
box-shadow: none;
}
.ueb-zoom--2 .ueb-node-style-default .ueb-node-top { .ueb-zoom--2 .ueb-node-style-default .ueb-node-top {
background: rgb(var(--ueb-node-color)); background: rgb(var(--ueb-node-color));
} }
@@ -524,6 +590,10 @@ ueb-node.ueb-node-style-glass .ueb-node-wrapper {
background-repeat: repeat, no-repeat; background-repeat: repeat, no-repeat;
} }
.ueb-zoom--2 ueb-node.ueb-node-style-glass .ueb-node-wrapper {
background: #101010;
}
ueb-node.ueb-node-style-glass .ueb-node-name { ueb-node.ueb-node-style-glass .ueb-node-name {
padding-right: 0; padding-right: 0;
padding-left: 0; padding-left: 0;
@@ -723,6 +793,19 @@ ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-pin-wrapper:hover
background: none !important; background: none !important;
} }
.ueb-pin-required-mark {
width: 0;
}
.ueb-pin-required-mark::before {
content: "";
display: block;
width: 6px;
height: 4px;
background: var(--ueb-pin-color);
margin-left: -13px;
border-radius: 0 2px 2px 0;
}
.ueb-pin-content { .ueb-pin-content {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -811,6 +894,23 @@ ueb-node[data-type="/Script/BlueprintGraph.K2Node_VariableSet"] ueb-pin[data-dir
outline: none; outline: none;
} }
.ueb-pin-input[type=checkbox] {
display: grid;
place-content: center;
appearance: none;
width: 18px;
height: 18px;
border: 1px solid #353535;
background: #0f0f0f;
}
.ueb-pin-input[type=checkbox]:checked::before {
content: "";
height: 0.7em;
width: 0.8em;
clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
background: #0070e0;
}
ueb-pin[data-linked=true] .ueb-pin-input, ueb-pin[data-linked=true] .ueb-pin-input,
ueb-pin[data-linked=true] .ueb-pin-input-wrapper { ueb-pin[data-linked=true] .ueb-pin-input-wrapper {
display: none; display: none;
@@ -861,7 +961,7 @@ ueb-pin[data-type="/Script/CoreUObject.LinearColor"] .ueb-pin-input {
max-height: 16em; max-height: 16em;
/* 97% is to get an effective font size of 12.6px from --ueb-font-size which is 13 px by default */ /* 97% is to get an effective font size of 12.6px from --ueb-font-size which is 13 px by default */
font-size: 97%; font-size: 97%;
white-space: nowrap; white-space: pre;
background: none; background: none;
color: inherit; color: inherit;
overflow: auto; overflow: auto;
@@ -1276,4 +1376,12 @@ ueb-ui-slider {
color: #c0c0c0; color: #c0c0c0;
} }
/* To improve a bit performance */
.ueb-zoom--2 * {
border: none !important;
border-radius: 0 !important;
box-shadow: none !important;
text-shadow: none !important;
}
/*# sourceMappingURL=ueb-style.css.map */ /*# sourceMappingURL=ueb-style.css.map */

2
dist/css/ueb-style.css.map vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

2
dist/css/ueb-style.min.css vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

2
dist/css/ueb-style.min.css.map vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

0
dist/font/roboto-bold.woff vendored Normal file → Executable file
View File

0
dist/font/roboto-bold.woff2 vendored Normal file → Executable file
View File

0
dist/font/roboto-condensed-bold.woff2 vendored Normal file → Executable file
View File

0
dist/font/roboto-condensed-regular.woff2 vendored Normal file → Executable file
View File

0
dist/font/roboto-light.woff vendored Normal file → Executable file
View File

0
dist/font/roboto-light.woff2 vendored Normal file → Executable file
View File

0
dist/font/roboto-regular.woff vendored Normal file → Executable file
View File

0
dist/font/roboto-regular.woff2 vendored Normal file → Executable file
View File

2468
dist/ueblueprint.js vendored

File diff suppressed because one or more lines are too long

12
dist/ueblueprint.min.js vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

View File

@@ -1,25 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>UE Blueprint</title>
<link rel="stylesheet" href="dist/css/ueb-style.css">
<style>
body {
margin: 0;
padding: 0;
--ueb-height: 100vh;
}
</style>
</head>
<body>
<script type="module">
import { Blueprint } from "./dist/ueblueprint.js"
</script>
<ueb-blueprint></ueb-blueprint>
</body>
</html>

View File

@@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>UE Blueprint</title> <title>UE Blueprint</title>
<link rel="stylesheet" href="dist/css/ueb-style.css"> <link rel="stylesheet" href="dist/css/ueb-style.min.css">
<style> <style>
body { body {
margin: 0; margin: 0;

View File

@@ -5,12 +5,18 @@ import LinkElement from "./element/LinkElement.js"
import NodeElement from "./element/NodeElement.js" import NodeElement from "./element/NodeElement.js"
import BlueprintEntity from "./entity/BlueprintEntity.js" import BlueprintEntity from "./entity/BlueprintEntity.js"
import BooleanEntity from "./entity/BooleanEntity.js" import BooleanEntity from "./entity/BooleanEntity.js"
import NiagaraClipboardContent from "./entity/objects/NiagaraClipboardContent.js"
import BlueprintTemplate from "./template/BlueprintTemplate.js" import BlueprintTemplate from "./template/BlueprintTemplate.js"
/** @extends {IElement<BlueprintEntity, BlueprintTemplate>} */ /** @extends {IElement<BlueprintEntity, BlueprintTemplate>} */
export default class Blueprint extends IElement { export default class Blueprint extends IElement {
static properties = { static properties = {
blueprintType: {
type: String,
attribute: "data-type",
reflect: true,
},
selecting: { selecting: {
type: Boolean, type: Boolean,
attribute: "data-selecting", attribute: "data-selecting",
@@ -84,10 +90,10 @@ export default class Blueprint extends IElement {
nodesNames = new Map() nodesNames = new Map()
/** @type {Coordinates} */ /** @type {Coordinates} */
mousePosition = [0, 0] mousePosition = [0, 0]
waitingExpandUpdate = false
constructor() { constructor() {
super() super()
this.blueprintType = ""
this.selecting = false this.selecting = false
this.scrolling = false this.scrolling = false
this.focused = false this.focused = false
@@ -297,29 +303,11 @@ export default class Blueprint extends IElement {
return [x, y] return [x, y]
} }
getNodes( getNodes(selected = false) {
selected = false,
[t, r, b, l] = [
Number.MIN_SAFE_INTEGER,
Number.MAX_SAFE_INTEGER,
Number.MAX_SAFE_INTEGER,
Number.MIN_SAFE_INTEGER,
]
) {
let result = this.nodes let result = this.nodes
if (selected) { if (selected) {
result = result.filter(n => n.selected) result = result.filter(n => n.selected)
} }
if (
t > Number.MIN_SAFE_INTEGER
|| r < Number.MAX_SAFE_INTEGER
|| b < Number.MAX_SAFE_INTEGER
|| l > Number.MIN_SAFE_INTEGER
) {
result = result.filter(n => {
return n.topBoundary() >= t && n.rightBoundary() <= r && n.bottomBoundary() <= b && n.leftBoundary() >= l
})
}
return result return result
} }
@@ -354,25 +342,25 @@ export default class Blueprint extends IElement {
getLinks(a = null, b = null) { getLinks(a = null, b = null) {
if ((a == null) != (b == null)) { if ((a == null) != (b == null)) {
const pin = a ?? b const pin = a ?? b
return this.links.filter(link => link.source == pin || link.destination == pin) return this.links.filter(link => link.origin == pin || link.target == pin)
} }
if (a != null && b != null) { if (a != null && b != null) {
return this.links.filter(link => return this.links.filter(link =>
link.source == a && link.destination == b link.origin == a && link.target == b
|| link.source == b && link.destination == a || link.origin == b && link.target == a
) )
} }
return this.links return this.links
} }
/** /**
* @param {PinElement} sourcePin * @param {PinElement} originPin
* @param {PinElement} destinationPin * @param {PinElement} targetPin
*/ */
getLink(sourcePin, destinationPin, strictDirection = false) { getLink(originPin, targetPin, strictDirection = false) {
return this.links.find(link => return this.links.find(link =>
link.source == sourcePin && link.destination == destinationPin link.origin == originPin && link.target == targetPin
|| !strictDirection && link.source == destinationPin && link.destination == sourcePin || !strictDirection && link.origin == targetPin && link.target == originPin
) )
} }
@@ -384,23 +372,39 @@ export default class Blueprint extends IElement {
this.getNodes().forEach(node => Blueprint.nodeSelectToggleFunction(node, false)) this.getNodes().forEach(node => Blueprint.nodeSelectToggleFunction(node, false))
} }
getSerializedText() {
const nodes = this.blueprint.getNodes(true).map(n => n.entity)
let exports = false
let result = nodes
.filter(n => {
exports ||= n.exported
return !n.exported
})
.reduce((acc, cur) => acc + cur.serialize(), "")
if (exports) {
const object = new NiagaraClipboardContent(this.blueprint.entity, nodes)
result = object.serialize() + result
}
return result
}
/** @param {...IElement} graphElements */ /** @param {...IElement} graphElements */
addGraphElement(...graphElements) { addGraphElement(...graphElements) {
/** @param {CustomEvent} event */ /** @param {CustomEvent} event */
const removeEventHandler = event => { const removeEventHandler = event => {
const target = event.currentTarget const target = event.currentTarget
target.removeEventListener(Configuration.removeEventName, removeEventHandler) target.removeEventListener(Configuration.removeEventName, removeEventHandler)
const [graphElementsArray, entity] = target instanceof NodeElement const [container, entity] = target instanceof NodeElement
? [this.nodes, target.entity] ? [this.nodes, target.entity]
: target instanceof LinkElement : target instanceof LinkElement
? [this.links] ? [this.links]
: null : null
// @ts-expect-error // @ts-expect-error
const index = graphElementsArray?.indexOf(target) const index = container?.indexOf(target)
if (index >= 0) { if (index >= 0) {
const last = graphElementsArray.pop() const last = container.pop()
if (index < graphElementsArray.length) { if (index < container.length) {
graphElementsArray[index] = last container[index] = last
} }
} }
if (entity) { if (entity) {
@@ -410,14 +414,17 @@ export default class Blueprint extends IElement {
for (const element of graphElements) { for (const element of graphElements) {
element.blueprint = this element.blueprint = this
if (element instanceof NodeElement && !this.nodes.includes(element)) { if (element instanceof NodeElement && !this.nodes.includes(element)) {
const name = element.entity.getObjectName()
this.entity.updateNameIndex(name)
if (element.getType() == Configuration.paths.niagaraClipboardContent) { if (element.getType() == Configuration.paths.niagaraClipboardContent) {
this.entity = this.entity.mergeWith(element.entity) this.entity = this.entity.mergeWith(element.entity)
const additionalSerialization = atob(element.entity.ExportedNodes.toString()) const additionalSerialization = atob(element.entity.ExportedNodes?.toString() ?? "")
this.template.getPasteInputObject().pasted(additionalSerialization) if (additionalSerialization) {
.forEach(node => node.entity._exported = true) this.template.getPasteInputObject().pasted(additionalSerialization)
.forEach(node => node.entity.exported = true)
}
continue continue
} }
const name = element.entity.getObjectName()
const homonym = this.entity.getHomonymObjectEntity(element.entity) const homonym = this.entity.getHomonymObjectEntity(element.entity)
if (homonym) { if (homonym) {
const newName = this.entity.takeFreeName(name) const newName = this.entity.takeFreeName(name)
@@ -428,6 +435,9 @@ export default class Blueprint extends IElement {
this.entity.addObjectEntity(element.entity) this.entity.addObjectEntity(element.entity)
element.addEventListener(Configuration.removeEventName, removeEventHandler) element.addEventListener(Configuration.removeEventName, removeEventHandler)
this.template.nodesContainerElement?.appendChild(element) this.template.nodesContainerElement?.appendChild(element)
if (!this.blueprintType) {
this.blueprintType = element.entity.getBlueprintType()
}
} else if (element instanceof LinkElement && !this.links.includes(element)) { } else if (element instanceof LinkElement && !this.links.includes(element)) {
this.links.push(element) this.links.push(element)
element.addEventListener(Configuration.removeEventName, removeEventHandler) element.addEventListener(Configuration.removeEventName, removeEventHandler)
@@ -454,6 +464,9 @@ export default class Blueprint extends IElement {
} }
element.remove() element.remove()
} }
if (this.nodes.length == 0) {
this.blueprintType = ""
}
} }
setFocused(value = true) { setFocused(value = true) {

View File

@@ -1,6 +1,7 @@
import { css } from "lit" import { css } from "lit"
export default class Configuration { export default class Configuration {
static VERSION = "2.0.0"
static nodeColors = { static nodeColors = {
black: css`20, 20, 20`, black: css`20, 20, 20`,
blue: css`84, 122, 156`, blue: css`84, 122, 156`,
@@ -23,7 +24,7 @@ export default class Configuration {
static colorWindowName = "Color Picker" static colorWindowName = "Color Picker"
static defaultCommentHeight = 96 static defaultCommentHeight = 96
static defaultCommentWidth = 400 static defaultCommentWidth = 400
static distanceThreshold = 5 // px static distanceThreshold = 20 // px
static dragEventName = "ueb-drag" static dragEventName = "ueb-drag"
static dragGeneralEventName = "ueb-drag-general" static dragGeneralEventName = "ueb-drag-general"
static edgeScrollThreshold = 50 static edgeScrollThreshold = 50
@@ -37,12 +38,9 @@ export default class Configuration {
end: "blueprint-unfocus", end: "blueprint-unfocus",
} }
static fontSize = css`13px` static fontSize = css`13px`
static gridAxisLineColor = css`black`
static gridExpandThreshold = 0.25 // remaining size factor threshold to cause an expansion event static gridExpandThreshold = 0.25 // remaining size factor threshold to cause an expansion event
static gridLineColor = css`#353535`
static gridLineWidth = 1 // px static gridLineWidth = 1 // px
static gridSet = 8 static gridSet = 8
static gridSetLineColor = css`#161616`
static gridShrinkThreshold = 4 // exceding size factor threshold to cause a shrink event static gridShrinkThreshold = 4 // exceding size factor threshold to cause a shrink event
static gridSize = 16 // px static gridSize = 16 // px
static hexColorRegex = /^\s*#(?<r>[0-9a-fA-F]{2})(?<g>[0-9a-fA-F]{2})(?<b>[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?<rs>[0-9a-fA-F])(?<gs>[0-9a-fA-F])(?<bs>[0-9a-fA-F])\s*$/ static hexColorRegex = /^\s*#(?<r>[0-9a-fA-F]{2})(?<g>[0-9a-fA-F]{2})(?<b>[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?<rs>[0-9a-fA-F])(?<gs>[0-9a-fA-F])(?<bs>[0-9a-fA-F])\s*$/
@@ -79,9 +77,13 @@ export default class Configuration {
* @param {Number} c1 * @param {Number} c1
* @param {Number} c2 * @param {Number} c2
*/ */
static linkRightSVGPath = (start, c1, c2) => { static linkRightSVGPath = (start, c1, c2, arc = false) => {
let end = 100 - start const end = 100 - start
return `M ${start} 0 C ${c1.toFixed(3)} 0, ${c2.toFixed(3)} 0, 50 50 S ${(end - c1 + start).toFixed(3)} 100, ` const mid = arc
? 50 + (c2 - start)
: 50
const fin = arc ? end + c1 - start : end - c1 + start
return `M ${start} 0 C ${c1.toFixed(2)} 0, ${c2.toFixed(2)} 0, ${mid.toFixed(2)} 50 S ${fin.toFixed(2)} 100, `
+ `${end.toFixed(3)} 100` + `${end.toFixed(3)} 100`
} }
static maxZoom = 7 static maxZoom = 7
@@ -91,9 +93,9 @@ export default class Configuration {
static mouseWheelZoomThreshold = 80 static mouseWheelZoomThreshold = 80
static nodeDragEventName = "ueb-node-drag" static nodeDragEventName = "ueb-node-drag"
static nodeDragGeneralEventName = "ueb-node-drag-general" static nodeDragGeneralEventName = "ueb-node-drag-general"
static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeRadius = 8 // px static nodeRadius = 8 // px
static nodeReflowEventName = "ueb-node-reflow" static nodeTitle = (name, counter) => `${name}_${counter}`
static nodeUpdateEventName = "ueb-node-update"
static paths = { static paths = {
actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent", actorBoundEvent: "/Script/BlueprintGraph.K2Node_ActorBoundEvent",
addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate", addDelegate: "/Script/BlueprintGraph.K2Node_AddDelegate",
@@ -149,6 +151,7 @@ export default class Configuration {
isValid: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:IsValid", isValid: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:IsValid",
kismetArrayLibrary: "/Script/Engine.KismetArrayLibrary", kismetArrayLibrary: "/Script/Engine.KismetArrayLibrary",
kismetMathLibrary: "/Script/Engine.KismetMathLibrary", kismetMathLibrary: "/Script/Engine.KismetMathLibrary",
kismetStringLibrary: "/Script/Engine.KismetStringLibrary",
knot: "/Script/BlueprintGraph.K2Node_Knot", knot: "/Script/BlueprintGraph.K2Node_Knot",
linearColor: "/Script/CoreUObject.LinearColor", linearColor: "/Script/CoreUObject.LinearColor",
literal: "/Script/BlueprintGraph.K2Node_Literal", literal: "/Script/BlueprintGraph.K2Node_Literal",
@@ -178,12 +181,16 @@ export default class Configuration {
multiGate: "/Script/BlueprintGraph.K2Node_MultiGate", multiGate: "/Script/BlueprintGraph.K2Node_MultiGate",
niagaraBool: "/Script/Niagara.NiagaraBool", niagaraBool: "/Script/Niagara.NiagaraBool",
niagaraClipboardContent: "/Script/NiagaraEditor.NiagaraClipboardContent", niagaraClipboardContent: "/Script/NiagaraEditor.NiagaraClipboardContent",
niagaraDataInterfaceCollisionQuery: "/Script/Niagara.NiagaraDataInterfaceCollisionQuery",
niagaraDataInterfaceCurlNoise: "/Script/Niagara.NiagaraDataInterfaceCurlNoise",
niagaraDataInterfaceVolumeTexture: "/Script/Niagara.NiagaraDataInterfaceVolumeTexture", niagaraDataInterfaceVolumeTexture: "/Script/Niagara.NiagaraDataInterfaceVolumeTexture",
niagaraFloat: "/Script/Niagara.NiagaraFloat", niagaraFloat: "/Script/Niagara.NiagaraFloat",
niagaraMatrix: "/Script/Niagara.NiagaraMatrix", niagaraInt32: "/Script/Niagara.NiagaraInt32",
niagaraNodeConvert: "/Script/NiagaraEditor.NiagaraNodeConvert",
niagaraNodeFunctionCall: "/Script/NiagaraEditor.NiagaraNodeFunctionCall", niagaraNodeFunctionCall: "/Script/NiagaraEditor.NiagaraNodeFunctionCall",
niagaraNodeInput: "/Script/NiagaraEditor.NiagaraNodeInput",
niagaraNodeOp: "/Script/NiagaraEditor.NiagaraNodeOp", niagaraNodeOp: "/Script/NiagaraEditor.NiagaraNodeOp",
niagaraNumeric: "/Script/Niagara.NiagaraNumeric", niagaraParameterMap: "/Script/Niagara.NiagaraParameterMap",
niagaraPosition: "/Script/Niagara.NiagaraPosition", niagaraPosition: "/Script/Niagara.NiagaraPosition",
pawn: "/Script/Engine.Pawn", pawn: "/Script/Engine.Pawn",
pcgEditorGraphNode: "/Script/PCGEditor.PCGEditorGraphNode", pcgEditorGraphNode: "/Script/PCGEditor.PCGEditorGraphNode",
@@ -199,6 +206,8 @@ export default class Configuration {
select: "/Script/BlueprintGraph.K2Node_Select", select: "/Script/BlueprintGraph.K2Node_Select",
self: "/Script/BlueprintGraph.K2Node_Self", self: "/Script/BlueprintGraph.K2Node_Self",
slateBlueprintLibrary: "/Script/UMG.SlateBlueprintLibrary", slateBlueprintLibrary: "/Script/UMG.SlateBlueprintLibrary",
soundCueGraphNode: "/Script/AudioEditor.SoundCueGraphNode",
soundNodeWavePlayer: "/Script/Engine.SoundNodeWavePlayer",
spawnActorFromClass: "/Script/BlueprintGraph.K2Node_SpawnActorFromClass", spawnActorFromClass: "/Script/BlueprintGraph.K2Node_SpawnActorFromClass",
switchEnum: "/Script/BlueprintGraph.K2Node_SwitchEnum", switchEnum: "/Script/BlueprintGraph.K2Node_SwitchEnum",
switchGameplayTag: "/Script/GameplayTagsEditor.GameplayTagsK2Node_SwitchGameplayTag", switchGameplayTag: "/Script/GameplayTagsEditor.GameplayTagsK2Node_SwitchGameplayTag",
@@ -208,16 +217,19 @@ export default class Configuration {
timeline: "/Script/BlueprintGraph.K2Node_Timeline", timeline: "/Script/BlueprintGraph.K2Node_Timeline",
timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary", timeManagementBlueprintLibrary: "/Script/TimeManagement.TimeManagementBlueprintLibrary",
transform: "/Script/CoreUObject.Transform", transform: "/Script/CoreUObject.Transform",
typedElementHandleLibrary: "/Script/TypedElementFramework.TypedElementHandleLibrary",
userDefinedEnum: "/Script/Engine.UserDefinedEnum", userDefinedEnum: "/Script/Engine.UserDefinedEnum",
variableGet: "/Script/BlueprintGraph.K2Node_VariableGet", variableGet: "/Script/BlueprintGraph.K2Node_VariableGet",
variableSet: "/Script/BlueprintGraph.K2Node_VariableSet", variableSet: "/Script/BlueprintGraph.K2Node_VariableSet",
vector: "/Script/CoreUObject.Vector", vector: "/Script/CoreUObject.Vector",
vector2D: "/Script/CoreUObject.Vector2D", vector2D: "/Script/CoreUObject.Vector2D",
vector2f: "/Script/CoreUObject.Vector2f",
vector3f: "/Script/CoreUObject.Vector3f", vector3f: "/Script/CoreUObject.Vector3f",
vector4f: "/Script/CoreUObject.Vector4f", vector4f: "/Script/CoreUObject.Vector4f",
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop", whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
} }
static pinInputWrapWidth = 145 // px static pinInputWrapWidth = 145 // px
static pinUpdateEventName = "ueb-pin-update"
static removeEventName = "ueb-element-delete" static removeEventName = "ueb-element-delete"
static scale = { static scale = {
[-12]: 0.133333, [-12]: 0.133333,

7
js/SVGIcon.js Normal file → Executable file
View File

@@ -388,6 +388,13 @@ export default class SVGIcon {
</svg> </svg>
` `
static staticPin = html`
<svg width="16" height="12" viewBox="1 0 16 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path class="ueb-pin-tofill" d="M1 7C1 4 3 1 7 1C10 1 14 3 17 6C18 7 18 7 17 8C14 11 10 13 7 13C3 13 1 10 1 7Z" fill="none" stroke="currentColor" stroke-width="2" />
<path class="ueb-pin-tostroke" d="M 9 4 V 3.5 H 5 V 7 H 9 V 10.5 H 5 V 10" stroke="currentColor" stroke-width="2" />
</svg>
`
static switch = html` static switch = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3" y="2" width="6" height="2" fill="white" /> <rect x="3" y="2" width="6" height="2" fill="white" />

0
js/Shortcuts.js Normal file → Executable file
View File

View File

@@ -80,7 +80,7 @@ export default class Utility {
} }
/** /**
* @param {Attribute} entity * @param {IEntity} entity
* @param {String} key * @param {String} key
* @returns {Boolean} * @returns {Boolean}
*/ */
@@ -147,29 +147,31 @@ export default class Utility {
/** /**
* @template T * @template T
* @param {Array<T>} a * @param {T[]} reference
* @param {Array<T>} b * @param {T[]} additional
* @param {(v: T) => void} adding - Process added element
* @param {(l: T, r: T) => Boolean} predicate * @param {(l: T, r: T) => Boolean} predicate
* @returns {T[]}
*/ */
static mergeArrays(a = [], b = [], predicate = (l, r) => l == r) { static mergeArrays(reference = [], additional = [], predicate = (l, r) => l == r, adding = v => { }) {
let result = [] let result = []
a = [...a] reference = [...reference]
b = [...b] additional = [...additional]
restart: restart:
while (true) { while (true) {
for (let j = 0; j < b.length; ++j) { for (let j = 0; j < additional.length; ++j) {
for (let i = 0; i < a.length; ++i) { for (let i = 0; i < reference.length; ++i) {
if (predicate(a[i], b[j])) { if (predicate(reference[i], additional[j])) {
// Found an element in common in the two arrays // Found an element in common in the two arrays
result.push( result.push(
// Take and append all the elements skipped from a // Take and append all the elements skipped from a
...a.splice(0, i), ...reference.splice(0, i),
// Take and append all the elements skippend from b // Take and append all the elements skippend from b
...b.splice(0, j), ...additional.splice(0, j).map(v => (adding(v), v)),
// Take and append the element in common // Take and append the element in common
...a.splice(0, 1) ...reference.splice(0, 1)
) )
b.shift() // Remove the same element from b additional.shift() // Remove the same element from b
continue restart continue restart
} }
} }
@@ -177,7 +179,13 @@ export default class Utility {
break restart break restart
} }
// Append remaining the elements in the arrays and make it unique // Append remaining the elements in the arrays and make it unique
return [...(new Set(result.concat(...a, ...b)))] result.push(...reference)
result.push(
...additional
.filter(vb => !result.some(vr => predicate(vr, vb)))
.map((v, k) => (adding(v), v))
)
return result
} }
/** @param {String} value */ /** @param {String} value */

0
js/action/RemoveAllNodes.js Normal file → Executable file
View File

76
js/decoding/nodeColor.js Normal file → Executable file
View File

@@ -1,54 +1,61 @@
import Configuration from "../Configuration.js" import Configuration from "../Configuration.js"
import LinearColorEntity from "../entity/LinearColorEntity.js" import LinearColorEntity from "../entity/LinearColorEntity.js"
const p = Configuration.paths
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
export default function nodeColor(entity) { export default function nodeColor(entity) {
switch (entity.getType()) { switch (entity.getType()) {
case Configuration.paths.materialExpressionConstant2Vector: case p.materialExpressionConstant2Vector:
case Configuration.paths.materialExpressionConstant3Vector: case p.materialExpressionConstant3Vector:
case Configuration.paths.materialExpressionConstant4Vector: case p.materialExpressionConstant4Vector:
return Configuration.nodeColors.yellow return Configuration.nodeColors.yellow
case Configuration.paths.materialExpressionFunctionInput: case p.materialExpressionFunctionInput:
case Configuration.paths.materialExpressionTextureCoordinate: case p.materialExpressionTextureCoordinate:
case Configuration.paths.materialExpressionWorldPosition: case p.materialExpressionWorldPosition:
case Configuration.paths.pcgEditorGraphNodeInput: case p.pcgEditorGraphNodeInput:
case Configuration.paths.pcgEditorGraphNodeOutput: case p.pcgEditorGraphNodeOutput:
return Configuration.nodeColors.red return Configuration.nodeColors.red
case Configuration.paths.makeStruct: case p.makeStruct:
return Configuration.nodeColors.darkBlue return Configuration.nodeColors.darkBlue
case Configuration.paths.materialExpressionMaterialFunctionCall: case p.materialExpressionMaterialFunctionCall:
return Configuration.nodeColors.blue return Configuration.nodeColors.blue
case Configuration.paths.materialExpressionTextureSample: case p.materialExpressionTextureSample:
return Configuration.nodeColors.darkTurquoise return Configuration.nodeColors.darkTurquoise
case p.niagaraNodeInput:
switch (entity["Usage"]?.toString()) {
case "Attribute": return Configuration.nodeColors.intenseGreen
case "Parameter": return Configuration.nodeColors.red
case "RapidIterationParameter": return Configuration.nodeColors.black
case "SystemConstant": return Configuration.nodeColors.gray
case "TranslatorConstant": return Configuration.nodeColors.gray
default: return Configuration.nodeColors.red
}
} }
switch (entity.getClass()) { switch (entity.getClass()) {
case Configuration.paths.callFunction: case p.niagaraNodeFunctionCall:
return entity.bIsPureFunc?.valueOf()
? Configuration.nodeColors.green
: Configuration.nodeColors.blue
case Configuration.paths.niagaraNodeFunctionCall:
return Configuration.nodeColors.darkerBlue return Configuration.nodeColors.darkerBlue
case Configuration.paths.dynamicCast: case p.dynamicCast:
return Configuration.nodeColors.turquoise return Configuration.nodeColors.turquoise
case Configuration.paths.inputDebugKey: case p.inputDebugKey:
case Configuration.paths.inputKey: case p.inputKey:
return Configuration.nodeColors.red return Configuration.nodeColors.red
case Configuration.paths.createDelegate: case p.createDelegate:
case Configuration.paths.enumLiteral: case p.enumLiteral:
case Configuration.paths.makeArray: case p.makeArray:
case Configuration.paths.makeMap: case p.makeMap:
case Configuration.paths.materialGraphNode: case p.materialGraphNode:
case Configuration.paths.select: case p.select:
return Configuration.nodeColors.green return Configuration.nodeColors.green
case Configuration.paths.executionSequence: case p.executionSequence:
case Configuration.paths.ifThenElse: case p.ifThenElse:
case Configuration.paths.macro: case p.macro:
case Configuration.paths.multiGate: case p.multiGate:
return Configuration.nodeColors.gray return Configuration.nodeColors.gray
case Configuration.paths.functionEntry: case p.functionEntry:
case Configuration.paths.functionResult: case p.functionResult:
return Configuration.nodeColors.violet return Configuration.nodeColors.violet
case Configuration.paths.timeline: case p.timeline:
return Configuration.nodeColors.yellow return Configuration.nodeColors.yellow
} }
if (entity.switchTarget()) { if (entity.switchTarget()) {
@@ -73,8 +80,11 @@ export default function nodeColor(entity) {
return Configuration.nodeColors.intenseGreen return Configuration.nodeColors.intenseGreen
} }
} }
if (entity.bIsPureFunc?.valueOf()) { if (entity.bIsPureFunc?.valueOf() || entity.bDefaultsToPureFunc?.valueOf()) {
return Configuration.nodeColors.green return Configuration.nodeColors.green
} }
if (entity["Input"]?.["Name"]) {
return Configuration.nodeColors.gray
}
return Configuration.nodeColors.blue return Configuration.nodeColors.blue
} }

74
js/decoding/nodeIcon.js Normal file → Executable file
View File

@@ -2,50 +2,52 @@ import Configuration from "../Configuration.js"
import SVGIcon from "../SVGIcon.js" import SVGIcon from "../SVGIcon.js"
import nodeTitle from "./nodeTitle.js" import nodeTitle from "./nodeTitle.js"
const p = Configuration.paths
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
export default function nodeIcon(entity) { export default function nodeIcon(entity) {
if (entity.isMaterial() || entity.isPcg() || entity.isNiagara()) { if (entity.isMaterial() || entity.isPcg() || entity.isSoundCue() || entity.isNiagara()) {
return null return null
} }
switch (entity.getType()) { switch (entity.getType()) {
case Configuration.paths.addDelegate: case p.addDelegate:
case Configuration.paths.asyncAction: case p.asyncAction:
case Configuration.paths.callDelegate: case p.callDelegate:
case Configuration.paths.clearDelegate: case p.clearDelegate:
case Configuration.paths.createDelegate: case p.createDelegate:
case Configuration.paths.functionEntry: case p.functionEntry:
case Configuration.paths.functionResult: case p.functionResult:
case Configuration.paths.removeDelegate: case p.removeDelegate:
return SVGIcon.node return SVGIcon.node
case Configuration.paths.customEvent: return SVGIcon.event case p.customEvent: return SVGIcon.event
case Configuration.paths.doN: return SVGIcon.doN case p.doN: return SVGIcon.doN
case Configuration.paths.doOnce: return SVGIcon.doOnce case p.doOnce: return SVGIcon.doOnce
case Configuration.paths.dynamicCast: return SVGIcon.cast case p.dynamicCast: return SVGIcon.cast
case Configuration.paths.enumLiteral: return SVGIcon.enum case p.enumLiteral: return SVGIcon.enum
case Configuration.paths.event: return SVGIcon.event case p.event: return SVGIcon.event
case Configuration.paths.executionSequence: case p.executionSequence:
case Configuration.paths.multiGate: case p.multiGate:
return SVGIcon.sequence return SVGIcon.sequence
case Configuration.paths.flipflop: case p.flipflop:
return SVGIcon.flipflop return SVGIcon.flipflop
case Configuration.paths.forEachElementInEnum: case p.forEachElementInEnum:
case Configuration.paths.forLoop: case p.forLoop:
case Configuration.paths.forLoopWithBreak: case p.forLoopWithBreak:
case Configuration.paths.whileLoop: case p.whileLoop:
return SVGIcon.loop return SVGIcon.loop
case Configuration.paths.forEachLoop: case p.forEachLoop:
case Configuration.paths.forEachLoopWithBreak: case p.forEachLoopWithBreak:
return SVGIcon.forEachLoop return SVGIcon.forEachLoop
case Configuration.paths.ifThenElse: return SVGIcon.branchNode case p.ifThenElse: return SVGIcon.branchNode
case Configuration.paths.isValid: return SVGIcon.questionMark case p.isValid: return SVGIcon.questionMark
case Configuration.paths.makeArray: return SVGIcon.makeArray case p.makeArray: return SVGIcon.makeArray
case Configuration.paths.makeMap: return SVGIcon.makeMap case p.makeMap: return SVGIcon.makeMap
case Configuration.paths.makeSet: return SVGIcon.makeSet case p.makeSet: return SVGIcon.makeSet
case Configuration.paths.makeStruct: return SVGIcon.makeStruct case p.makeStruct: return SVGIcon.makeStruct
case Configuration.paths.metasoundEditorGraphExternalNode: return SVGIcon.metasoundFunction case p.metasoundEditorGraphExternalNode: return SVGIcon.metasoundFunction
case Configuration.paths.select: return SVGIcon.select case p.select: return SVGIcon.select
case Configuration.paths.spawnActorFromClass: return SVGIcon.spawnActor case p.spawnActorFromClass: return SVGIcon.spawnActor
case Configuration.paths.timeline: return SVGIcon.timer case p.timeline: return SVGIcon.timer
} }
if (entity.switchTarget()) { if (entity.switchTarget()) {
return SVGIcon.switch return SVGIcon.switch
@@ -53,7 +55,7 @@ export default function nodeIcon(entity) {
if (nodeTitle(entity).startsWith("Break")) { if (nodeTitle(entity).startsWith("Break")) {
return SVGIcon.breakStruct return SVGIcon.breakStruct
} }
if (entity.getClass() === Configuration.paths.macro) { if (entity.getClass() === p.macro) {
return SVGIcon.macro return SVGIcon.macro
} }
const hidValue = entity.getHIDAttribute()?.toString() const hidValue = entity.getHIDAttribute()?.toString()
@@ -73,7 +75,7 @@ export default function nodeIcon(entity) {
if (entity.getDelegatePin()) { if (entity.getDelegatePin()) {
return SVGIcon.event return SVGIcon.event
} }
if (entity.ObjectRef?.type === Configuration.paths.ambientSound) { if (entity.ObjectRef?.type === p.ambientSound) {
return SVGIcon.sound return SVGIcon.sound
} }
return SVGIcon.functionSymbol return SVGIcon.functionSymbol

11
js/decoding/nodeSubtitle.js Normal file → Executable file
View File

@@ -2,20 +2,23 @@ import Configuration from "../Configuration.js"
import Utility from "../Utility.js" import Utility from "../Utility.js"
import pinTitle from "./pinTitle.js" import pinTitle from "./pinTitle.js"
const p = Configuration.paths
/** /**
* @param {ObjectEntity} entity * @param {ObjectEntity} entity
* @returns {String?} * @returns {String?}
*/ */
export default function nodeSubtitle(entity) { export default function nodeSubtitle(entity) {
switch (entity.getType()) { switch (entity.getType()) {
case Configuration.paths.addDelegate: case p.addDelegate:
case Configuration.paths.clearDelegate: case p.clearDelegate:
case Configuration.paths.removeDelegate: case p.callDelegate:
case p.removeDelegate:
return null return null
} }
const targetPin = entity const targetPin = entity
.getPinEntities() .getPinEntities()
.find(pin => pin.PinName?.toString() === "self" && pinTitle(pin) === "Target") .find(pin => !pin.isHidden() && pin.PinName?.toString() === "self" && pinTitle(pin) === "Target")
if (targetPin) { if (targetPin) {
const target = entity.FunctionReference?.MemberParent?.getName() const target = entity.FunctionReference?.MemberParent?.getName()
?? targetPin.PinType?.PinSubCategoryObject?.getName() ?? targetPin.PinType?.PinSubCategoryObject?.getName()

116
js/decoding/nodeTemplate.js Normal file → Executable file
View File

@@ -9,22 +9,89 @@ import VariableAccessNodeTemplate from "../template/node/VariableAccessNodeTempl
import VariableConversionNodeTemplate from "../template/node/VariableConversionNodeTemplate.js" import VariableConversionNodeTemplate from "../template/node/VariableConversionNodeTemplate.js"
import VariableOperationNodeTemplate from "../template/node/VariableOperationNodeTemplate.js" import VariableOperationNodeTemplate from "../template/node/VariableOperationNodeTemplate.js"
const niagaraOperationNodes = [
"Boolean::LogicEq",
"Boolean::LogicNEq",
"Integer::EnumNEq",
"Integer::EnumEq",
...[
"Abs",
"Add",
"ArcCosine(Degrees)",
"ArcCosine(Radians)",
"ArcSine(Degrees)",
"ArcSine(Radians)",
"ArcTangent(Degrees)",
"ArcTangent(Radians)",
"Ceil",
"CmpEQ",
"CmpGE",
"CmpGT",
"CmpLE",
"CmpLT",
"CmpNEQ",
"Cosine(Degrees)",
"Cosine(Radians)",
"DegreesToRadians",
"Div",
"Dot",
"Exp",
"Exp2",
"Floor",
"FMod",
"Frac",
"Length",
"Lerp",
"Log",
"Log2",
"Madd",
"Max",
"Min",
"Mul",
"Negate",
"Normalize",
"OneMinus",
"PI",
"RadiansToDegrees",
"Rcp",
"RcpFast",
"Round",
"RSqrt",
"Sign",
"Sine(Degrees)",
"Sine(Radians)",
"Sqrt",
"Step",
"Subtract",
"Tangent(Degrees)",
"Tangent(Radians)",
"Trunc",
"TWO_PI",
].map(v => "Numeric::" + v),
"Vector3::Cross",
]
const p = Configuration.paths
/** /**
* @param {ObjectEntity} nodeEntity * @param {ObjectEntity} nodeEntity
* @return {new () => NodeTemplate} * @return {new () => NodeTemplate}
*/ */
export default function nodeTemplateClass(nodeEntity) { export default function nodeTemplateClass(nodeEntity) {
const className = nodeEntity.getClass()
if ( if (
nodeEntity.getClass() === Configuration.paths.callFunction className === p.callFunction
|| nodeEntity.getClass() === Configuration.paths.commutativeAssociativeBinaryOperator || className === p.commutativeAssociativeBinaryOperator
|| nodeEntity.getClass() === Configuration.paths.callArrayFunction || className === p.callArrayFunction
) { ) {
const memberParent = nodeEntity.FunctionReference?.MemberParent?.path ?? "" const memberParent = nodeEntity.FunctionReference?.MemberParent?.path ?? ""
const memberName = nodeEntity.FunctionReference?.MemberName?.toString() const memberName = nodeEntity.FunctionReference?.MemberName?.toString()
if ( if (
memberName && ( memberName && (
memberParent === Configuration.paths.kismetMathLibrary memberParent === p.kismetArrayLibrary
|| memberParent === Configuration.paths.kismetArrayLibrary || memberParent === p.kismetMathLibrary
|| memberParent === p.kismetStringLibrary
|| memberParent === p.typedElementHandleLibrary
)) { )) {
if (memberName.startsWith("Conv_")) { if (memberName.startsWith("Conv_")) {
return VariableConversionNodeTemplate return VariableConversionNodeTemplate
@@ -51,6 +118,7 @@ export default function nodeTemplateClass(nodeEntity) {
case "BMin": case "BMin":
case "CrossProduct2D": case "CrossProduct2D":
case "DotProduct2D": case "DotProduct2D":
case "Equal":
case "Exp": case "Exp":
case "FMax": case "FMax":
case "FMin": case "FMin":
@@ -77,45 +145,37 @@ export default function nodeTemplateClass(nodeEntity) {
return VariableOperationNodeTemplate return VariableOperationNodeTemplate
} }
} }
if (memberParent === Configuration.paths.blueprintSetLibrary) { if (memberParent === p.blueprintSetLibrary) {
return VariableOperationNodeTemplate return VariableOperationNodeTemplate
} }
if (memberParent === Configuration.paths.blueprintMapLibrary) { if (memberParent === p.blueprintMapLibrary) {
return VariableOperationNodeTemplate return VariableOperationNodeTemplate
} }
} }
switch (nodeEntity.getClass()) { switch (className) {
case Configuration.paths.comment: case p.comment:
case Configuration.paths.materialGraphNodeComment: case p.materialGraphNodeComment:
return CommentNodeTemplate return CommentNodeTemplate
case Configuration.paths.createDelegate: case p.createDelegate:
return NodeTemplate return NodeTemplate
case Configuration.paths.metasoundEditorGraphExternalNode: case p.metasoundEditorGraphExternalNode:
if (nodeEntity["ClassName"]?.["Name"] == "Add") { if (nodeEntity["ClassName"]?.["Name"] == "Add") {
return MetasoundOperationTemplate return MetasoundOperationTemplate
} }
return MetasoundNodeTemplate return MetasoundNodeTemplate
case Configuration.paths.niagaraNodeOp: case p.niagaraNodeOp:
if ( if (niagaraOperationNodes.includes(nodeEntity.OpName?.toString())) {
[
"Boolean::LogicEq",
"Boolean::LogicNEq",
"Numeric::Abs",
"Numeric::Add",
"Numeric::Mul",
].includes(nodeEntity.OpName?.toString())
) {
return VariableOperationNodeTemplate return VariableOperationNodeTemplate
} }
break break
case Configuration.paths.promotableOperator: case p.promotableOperator:
return VariableOperationNodeTemplate return VariableOperationNodeTemplate
case Configuration.paths.knot: case p.knot:
return KnotNodeTemplate return KnotNodeTemplate
case Configuration.paths.literal: case p.literal:
case Configuration.paths.self: case p.self:
case Configuration.paths.variableGet: case p.variableGet:
case Configuration.paths.variableSet: case p.variableSet:
return VariableAccessNodeTemplate return VariableAccessNodeTemplate
} }
if (nodeEntity.isEvent()) { if (nodeEntity.isEvent()) {

248
js/decoding/nodeTitle.js Normal file → Executable file
View File

@@ -34,6 +34,68 @@ const keyNameValue = {
"Subtract": "Num -", "Subtract": "Num -",
"Tilde": "`", "Tilde": "`",
} }
const niagaraNodeNames = {
"Boolean::LogicAnd": "Logic AND",
"Boolean::LogicEq": "==",
"Boolean::LogicNEq": "!=",
"Boolean::LogicNot": "Logic NOT",
"Boolean::LogicOr": "Logic OR",
"Integer::BitAnd": "Bitwise AND",
"Integer::BitLShift": "Bitwise Left Shift",
"Integer::BitNot": "Bitwise NOT",
"Integer::BitOr": "Bitwise OR",
"Integer::BitRShift": "Bitwise Right Shift",
"Integer::BitXOr": "Bitwise XOR",
"Integer::EnumEq": "==",
"Integer::EnumNEq": "!=",
"Matrix::MatrixMultiply": "Multiply (Matrix * Matrix)",
"Matrix::MatrixVectorMultiply": "Multiply (Matrix * Vector4)",
// Numeric::
...Object.fromEntries(Object.entries({
"Add": "+",
"ArcCosine": "ArcCosine",
"ArcCosine(Degrees)": "ArcCos(D)",
"ArcCosine(Radians)": "ArcCos(R)",
"ArcSine": "ArcSine",
"ArcSine(Degrees)": "ArcSin(D)",
"ArcSine(Radians)": "ArcSin(R)",
"ArcTangent(Degrees)": "ArcTan(D)",
"ArcTangent(Radians)": "ArcTan(R)",
"CmpEQ": "==",
"CmpGE": ">=",
"CmpGT": ">",
"CmpLE": "<=",
"CmpLT": "<",
"CmpNEQ": "!=",
"Cosine(Degrees)": "Cos(D)",
"Cosine(Radians)": "Cos(R)",
"DegreesToRadians": "DegToRad",
"DistancePos": "Distance",
"Div": String.fromCharCode(0x00f7),
"FMod": "%",
"FModFast": "Modulo Fast",
"Length": "Len",
"Madd": `(A${String.fromCharCode(0x2a2f)}B)+C`,
"Mul": String.fromCharCode(0x2a2f),
"Negate": "-A",
"OneMinus": "1-A",
"PI": String.fromCharCode(0x03C0),
"RadiansToDegrees": "RadToDeg",
"Rand Float": "Random Float",
"Rand Integer": "Random Integer",
"Rand": "Random",
"Rcp": "Reciprocal",
"RSqrt": "Rcp Sqrt",
"Sine(Degrees)": "Sin(D)",
"Sine(Radians)": "Sin(R)",
"Subtract": "-",
"Tangent(Degrees)": "Tan(D)",
"Tangent(Radians)": "Tan(R)",
"TWO_PI": `2 ${String.fromCharCode(0x03C0)}`,
}).map(([k, v]) => ["Numeric::" + k, v])),
}
const p = Configuration.paths
const format = Utility.formatStringName
/** @param {String} value */ /** @param {String} value */
function numberFromText(value = "") { function numberFromText(value = "") {
@@ -78,58 +140,58 @@ function keyName(value) {
export default function nodeTitle(entity) { export default function nodeTitle(entity) {
let value let value
switch (entity.getType()) { switch (entity.getType()) {
case Configuration.paths.addDelegate: case p.addDelegate:
value ??= "Bind Event to " value ??= "Bind Event to "
case Configuration.paths.clearDelegate: case p.clearDelegate:
value ??= "Unbind all Events from " value ??= "Unbind all Events from "
case Configuration.paths.removeDelegate: case p.removeDelegate:
value ??= "Unbind Event from " value ??= "Unbind Event from "
return value + Utility.formatStringName( return value + format(
entity.DelegateReference?.MemberName?.toString().replace(/Delegate$/, "") ?? "None" entity.DelegateReference?.MemberName?.toString().replace(/Delegate$/, "") ?? "None"
) )
case Configuration.paths.asyncAction: case p.asyncAction:
if (entity.ProxyFactoryFunctionName) { if (entity.ProxyFactoryFunctionName) {
return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString()) return format(entity.ProxyFactoryFunctionName?.toString())
} }
case Configuration.paths.actorBoundEvent: case p.actorBoundEvent:
case Configuration.paths.componentBoundEvent: case p.componentBoundEvent:
return `${Utility.formatStringName(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})` return `${format(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})`
case Configuration.paths.callDelegate: case p.callDelegate:
return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}` return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}`
case Configuration.paths.createDelegate: case p.createDelegate:
return "Create Event" return "Create Event"
case Configuration.paths.customEvent: case p.customEvent:
if (entity.CustomFunctionName) { if (entity.CustomFunctionName) {
return entity.CustomFunctionName?.toString() return entity.CustomFunctionName?.toString()
} }
case Configuration.paths.dynamicCast: case p.dynamicCast:
if (!entity.TargetType) { if (!entity.TargetType) {
return "Bad cast node" // Target type not found return "Bad cast node" // Target type not found
} }
return `Cast To ${entity.TargetType?.getName()}` return `Cast To ${entity.TargetType?.getName()}`
case Configuration.paths.enumLiteral: case p.enumLiteral:
return `Literal enum ${entity.Enum?.getName()}` return `Literal enum ${entity.Enum?.getName()}`
case Configuration.paths.event: case p.event:
return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}` return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}`
case Configuration.paths.executionSequence: case p.executionSequence:
return "Sequence" return "Sequence"
case Configuration.paths.forEachElementInEnum: case p.forEachElementInEnum:
return `For Each ${entity.Enum?.getName()}` return `For Each ${entity.Enum?.getName()}`
case Configuration.paths.forEachLoopWithBreak: case p.forEachLoopWithBreak:
return "For Each Loop with Break" return "For Each Loop with Break"
case Configuration.paths.functionEntry: case p.functionEntry:
return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript" return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript"
? "Construction Script" ? "Construction Script"
: entity.FunctionReference?.MemberName?.toString() : entity.FunctionReference?.MemberName?.toString()
case Configuration.paths.functionResult: case p.functionResult:
return "Return Node" return "Return Node"
case Configuration.paths.ifThenElse: case p.ifThenElse:
return "Branch" return "Branch"
case Configuration.paths.makeStruct: case p.makeStruct:
if (entity.StructType) { if (entity.StructType) {
return `Make ${entity.StructType.getName()}` return `Make ${entity.StructType.getName()}`
} }
case Configuration.paths.materialExpressionComponentMask: { case p.materialExpressionComponentMask: {
const materialObject = entity.getMaterialSubobject() const materialObject = entity.getMaterialSubobject()
if (materialObject) { if (materialObject) {
return `Mask ( ${Configuration.rgba return `Mask ( ${Configuration.rgba
@@ -138,15 +200,15 @@ export default function nodeTitle(entity) {
.join("")})` .join("")})`
} }
} }
case Configuration.paths.materialExpressionConstant: case p.materialExpressionConstant:
value ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue] value ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue]
case Configuration.paths.materialExpressionConstant2Vector: case p.materialExpressionConstant2Vector:
value ??= [ value ??= [
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue, entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue,
entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue, entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue,
] ]
case Configuration.paths.materialExpressionConstant3Vector: case p.materialExpressionConstant3Vector:
case Configuration.paths.materialExpressionConstant4Vector: case p.materialExpressionConstant4Vector:
if (!value) { if (!value) {
const vector = entity.getCustomproperties() const vector = entity.getCustomproperties()
.find(pinEntity => pinEntity.PinName?.toString() == "Constant") .find(pinEntity => pinEntity.PinName?.toString() == "Constant")
@@ -160,32 +222,32 @@ export default function nodeTitle(entity) {
} }
value = undefined value = undefined
break break
case Configuration.paths.materialExpressionFunctionInput: { case p.materialExpressionFunctionInput: {
const materialObject = entity.getMaterialSubobject() const materialObject = entity.getMaterialSubobject()
const inputName = materialObject?.InputName ?? "In" const inputName = materialObject?.InputName ?? "In"
const inputType = materialObject?.InputType?.value.match(/^.+?_(\w+)$/)?.[1] ?? "Vector3" const inputType = materialObject?.InputType?.value.match(/^.+?_(\w+)$/)?.[1] ?? "Vector3"
return `Input ${inputName} (${inputType})` return `Input ${inputName} (${inputType})`
} }
case Configuration.paths.materialExpressionLogarithm: case p.materialExpressionLogarithm:
return "Ln" return "Ln"
case Configuration.paths.materialExpressionLogarithm10: case p.materialExpressionLogarithm10:
return "Log10" return "Log10"
case Configuration.paths.materialExpressionLogarithm2: case p.materialExpressionLogarithm2:
return "Log2" return "Log2"
case Configuration.paths.materialExpressionMaterialFunctionCall: case p.materialExpressionMaterialFunctionCall:
const materialFunction = entity.getMaterialSubobject()?.MaterialFunction const materialFunction = entity.getMaterialSubobject()?.MaterialFunction
if (materialFunction) { if (materialFunction) {
return materialFunction.getName() return materialFunction.getName()
} }
break break
case Configuration.paths.materialExpressionSquareRoot: case p.materialExpressionSquareRoot:
return "Sqrt" return "Sqrt"
case Configuration.paths.materialExpressionSubtract: case p.materialExpressionSubtract:
const materialObject = entity.getMaterialSubobject() const materialObject = entity.getMaterialSubobject()
if (materialObject) { if (materialObject) {
return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})` return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})`
} }
case Configuration.paths.metasoundEditorGraphExternalNode: { case p.metasoundEditorGraphExternalNode: {
const name = entity["ClassName"]?.["Name"] const name = entity["ClassName"]?.["Name"]
if (name) { if (name) {
switch (name) { switch (name) {
@@ -194,11 +256,26 @@ export default function nodeTitle(entity) {
} }
} }
} }
case Configuration.paths.pcgEditorGraphNodeInput: case p.niagaraNodeConvert:
/** @type {String} */
const targetType = (entity["AutowireMakeType"]?.["ClassStructOrEnum"] ?? "")
.toString()
.match(/(?:Niagara)?(\w+)['"]*$/)
?.[1]
?? ""
return `Make ${targetType}`
case p.pcgEditorGraphNodeInput:
return "Input" return "Input"
case Configuration.paths.pcgEditorGraphNodeOutput: case p.pcgEditorGraphNodeOutput:
return "Output" return "Output"
case Configuration.paths.spawnActorFromClass: case p.soundNodeWavePlayer:
return `Wave Player : ${entity.getSounCueSubobject()
?.SoundWaveAssetPtr
?.type
.match(/([^.]+)$/)
?.[0]
?? "NONE"}`
case p.spawnActorFromClass:
let className = entity.getCustomproperties() let className = entity.getCustomproperties()
.find(pinEntity => pinEntity.PinName.toString() == "ReturnValue") .find(pinEntity => pinEntity.PinName.toString() == "ReturnValue")
?.PinType ?.PinType
@@ -207,20 +284,21 @@ export default function nodeTitle(entity) {
if (className === "Actor") { if (className === "Actor") {
className = null className = null
} }
return `SpawnActor ${Utility.formatStringName(className ?? "NONE")}` return `SpawnActor ${format(className ?? "NONE")}`
case Configuration.paths.switchEnum: case p.switchEnum:
return `Switch on ${entity.Enum?.getName() ?? "Enum"}` return `Switch on ${entity.Enum?.getName() ?? "Enum"}`
case Configuration.paths.switchInteger: case p.switchInteger:
return `Switch on Int` return `Switch on Int`
case Configuration.paths.variableGet: case p.variableGet:
return "" return ""
case Configuration.paths.variableSet: case p.variableSet:
return "SET" return "SET"
} }
const className = entity.getClass()
let switchTarget = entity.switchTarget() let switchTarget = entity.switchTarget()
if (switchTarget) { if (switchTarget) {
if (switchTarget[0] !== "E") { if (switchTarget[0] !== "E") {
switchTarget = Utility.formatStringName(switchTarget) switchTarget = format(switchTarget)
} }
return `Switch on ${switchTarget}` return `Switch on ${switchTarget}`
} }
@@ -230,19 +308,20 @@ export default function nodeTitle(entity) {
const keyNameSymbol = entity.getHIDAttribute() const keyNameSymbol = entity.getHIDAttribute()
if (keyNameSymbol) { if (keyNameSymbol) {
const name = keyNameSymbol.toString() const name = keyNameSymbol.toString()
let title = keyName(name) ?? Utility.formatStringName(name) let title = keyName(name) ?? format(name)
if (entity.getClass() === Configuration.paths.inputDebugKey) { if (className === p.inputDebugKey) {
title = "Debug Key " + title title = "Debug Key " + title
} else if (entity.getClass() === Configuration.paths.getInputAxisKeyValue) { } else if (className === p.getInputAxisKeyValue) {
title = "Get " + title title = "Get " + title
} }
return title return title
} }
if (entity.getClass() === Configuration.paths.macro) { if (className === p.macro) {
return Utility.formatStringName(entity.MacroGraphReference?.getMacroName()) return format(entity.MacroGraphReference?.getMacroName())
} }
if (entity.isMaterial() && entity.getMaterialSubobject()) { const materialSubobject = entity.getMaterialSubobject()
let result = nodeTitle(entity.getMaterialSubobject()) if (materialSubobject) {
let result = nodeTitle(materialSubobject)
result = result.match(/Material Expression (.+)/)?.[1] ?? result result = result.match(/Material Expression (.+)/)?.[1] ?? result
return result return result
} }
@@ -251,25 +330,29 @@ export default function nodeTitle(entity) {
let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle.toString() : nodeTitle(pcgSubobject) let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle.toString() : nodeTitle(pcgSubobject)
return result return result
} }
const soundCueSubobject = entity.getSounCueSubobject()
if (soundCueSubobject) {
return Utility.formatStringName(soundCueSubobject.getObjectName(true).replace(/^SoundNode/, ""))
}
const subgraphObject = entity.getSubgraphObject() const subgraphObject = entity.getSubgraphObject()
if (subgraphObject) { if (subgraphObject) {
return subgraphObject.Graph.getName() return subgraphObject.Graph.getName()
} }
const settingsObject = entity.getSettingsObject() const settingsObject = entity.getSettingsObject()
if (settingsObject) { if (settingsObject) {
if (settingsObject.ExportPath.type === Configuration.paths.pcgHiGenGridSizeSettings) { if (settingsObject.ExportPath?.valueOf()?.type === p.pcgHiGenGridSizeSettings) {
return `Grid Size: ${( return `Grid Size: ${(
settingsObject.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00") settingsObject.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00")
?? settingsObject.HiGenGridSize?.toString().match(/^\w+$/)?.[0] ?? settingsObject.HiGenGridSize?.toString().match(/^\w+$/)?.[0]
) ?? "256"}` ) ?? "256"}`
} }
if (settingsObject.BlueprintElementInstance) { if (settingsObject.BlueprintElementInstance) {
return Utility.formatStringName(settingsObject.BlueprintElementType.getName()) return format(settingsObject.BlueprintElementType.getName())
} }
if (settingsObject.Operation) { if (settingsObject.Operation) {
const match = settingsObject.Name?.toString().match(/PCGMetadata(\w+)Settings_\d+/) const match = settingsObject.Name?.toString().match(/PCGMetadata(\w+)Settings_\d+/)
if (match) { if (match) {
return Utility.formatStringName(match[1] + ": " + settingsObject.Operation) return format(match[1] + ": " + settingsObject.Operation)
} }
} }
const settingsSubgraphObject = settingsObject.getSubgraphObject() const settingsSubgraphObject = settingsObject.getSubgraphObject()
@@ -284,7 +367,7 @@ export default function nodeTitle(entity) {
case "AddKey": case "AddKey":
let result = memberParent.match(sequencerScriptingNameRegex) let result = memberParent.match(sequencerScriptingNameRegex)
if (result) { if (result) {
return `Add Key (${Utility.formatStringName(result[1])})` return `Add Key (${format(result[1])})`
} }
case "Concat_StrStr": case "Concat_StrStr":
return "Append" return "Append"
@@ -295,14 +378,16 @@ export default function nodeTitle(entity) {
+ (memberNameTraceLineMatch[1] === "Multi" ? " Multi " : " ") + (memberNameTraceLineMatch[1] === "Multi" ? " Multi " : " ")
+ (memberNameTraceLineMatch[2] === "" + (memberNameTraceLineMatch[2] === ""
? "By Channel" ? "By Channel"
: Utility.formatStringName(memberNameTraceLineMatch[2]) : format(memberNameTraceLineMatch[2])
) )
} }
switch (memberParent) { switch (memberParent) {
case Configuration.paths.blueprintGameplayTagLibrary: case p.blueprintGameplayTagLibrary:
case Configuration.paths.kismetMathLibrary: case p.kismetMathLibrary:
case Configuration.paths.slateBlueprintLibrary: case p.kismetStringLibrary:
case Configuration.paths.timeManagementBlueprintLibrary: case p.slateBlueprintLibrary:
case p.timeManagementBlueprintLibrary:
case p.typedElementHandleLibrary:
const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/) const leadingLetter = memberName.match(/[BF]([A-Z]\w+)/)
if (leadingLetter) { if (leadingLetter) {
// Some functions start with B or F (Like FCeil, FMax, BMin) // Some functions start with B or F (Like FCeil, FMax, BMin)
@@ -313,6 +398,7 @@ export default function nodeTitle(entity) {
case "BooleanAND": return "AND" case "BooleanAND": return "AND"
case "BooleanNAND": return "NAND" case "BooleanNAND": return "NAND"
case "BooleanOR": return "OR" case "BooleanOR": return "OR"
case "Equal": return "=="
case "Exp": return "e" case "Exp": return "e"
case "LineTraceSingle": return "Line Trace By Channel" case "LineTraceSingle": return "Line Trace By Channel"
case "Max": return "MAX" case "Max": return "MAX"
@@ -386,23 +472,23 @@ export default function nodeTitle(entity) {
return "^" return "^"
} }
break break
case Configuration.paths.blueprintSetLibrary: case p.blueprintSetLibrary:
{ {
const setOperationMatch = memberName.match(/Set_(\w+)/) const setOperationMatch = memberName.match(/Set_(\w+)/)
if (setOperationMatch) { if (setOperationMatch) {
return Utility.formatStringName(setOperationMatch[1]).toUpperCase() return format(setOperationMatch[1]).toUpperCase()
} }
} }
break break
case Configuration.paths.blueprintMapLibrary: case p.blueprintMapLibrary:
{ {
const setOperationMatch = memberName.match(/Map_(\w+)/) const setOperationMatch = memberName.match(/Map_(\w+)/)
if (setOperationMatch) { if (setOperationMatch) {
return Utility.formatStringName(setOperationMatch[1]).toUpperCase() return format(setOperationMatch[1]).toUpperCase()
} }
} }
break break
case Configuration.paths.kismetArrayLibrary: case p.kismetArrayLibrary:
{ {
const arrayOperationMath = memberName.match(/Array_(\w+)/) const arrayOperationMath = memberName.match(/Array_(\w+)/)
if (arrayOperationMath) { if (arrayOperationMath) {
@@ -411,29 +497,27 @@ export default function nodeTitle(entity) {
} }
break break
} }
return Utility.formatStringName(memberName) return format(memberName)
} }
if (entity.OpName) { if (entity.OpName) {
switch (entity.OpName.toString()) { return niagaraNodeNames[entity.OpName.toString()]
case "Boolean::LogicAnd": return "Logic AND" ?? format(entity.OpName.toString().replaceAll(/(?:^\w+(?<!^Matrix))?::/g, " "))
case "Boolean::LogicEq": return "=="
case "Boolean::LogicNEq": return "!="
case "Boolean::LogicNot": return "Logic NOT"
case "Boolean::LogicOr": return "Logic OR"
case "Matrix::MatrixMultiply": return "Multiply (Matrix * Matrix)"
case "Matrix::MatrixVectorMultiply": return "Multiply (Matrix * Vector4)"
case "Numeric::Abs": return "Abs"
case "Numeric::Add": return "+"
case "Numeric::DistancePos": return "Distance"
case "Numeric::Mul": return String.fromCharCode(0x2a2f)
}
return Utility.formatStringName(entity.OpName.toString()).replaceAll("::", " ")
} }
if (entity.FunctionDisplayName) { if (entity.FunctionDisplayName) {
return Utility.formatStringName(entity.FunctionDisplayName.toString()) return format(entity.FunctionDisplayName.toString())
} }
if (entity.ObjectRef) { if (entity.ObjectRef) {
return entity.ObjectRef.getName() return entity.ObjectRef.getName()
} }
return Utility.formatStringName(entity.getNameAndCounter()[0]) let prefix
if (
className.startsWith(prefix = "/Script/NiagaraEditor.NiagaraNodeParameter")
|| className.startsWith(prefix = "/Script/NiagaraEditor.NiagaraNode")
) {
return entity["Input"]?.["Name"]?.toString() ?? format(className.substring(prefix.length))
}
if (entity.ParameterName) {
return entity.ParameterName.toString()
}
return format(entity.getNameAndCounter()[0])
} }

19
js/decoding/nodeVariadic.js Normal file → Executable file
View File

@@ -8,6 +8,7 @@ import StringEntity from "../entity/StringEntity.js"
/** @param {PinEntity} pinEntity */ /** @param {PinEntity} pinEntity */
const indexFromUpperCaseLetterName = pinEntity => const indexFromUpperCaseLetterName = pinEntity =>
pinEntity.PinName?.toString().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0) pinEntity.PinName?.toString().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0)
const p = Configuration.paths
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
export default function nodeVariadic(entity) { export default function nodeVariadic(entity) {
@@ -21,8 +22,8 @@ export default function nodeVariadic(entity) {
let prefix let prefix
let name let name
switch (type) { switch (type) {
case Configuration.paths.commutativeAssociativeBinaryOperator: case p.commutativeAssociativeBinaryOperator:
case Configuration.paths.promotableOperator: case p.promotableOperator:
name = entity.FunctionReference?.MemberName?.toString() name = entity.FunctionReference?.MemberName?.toString()
switch (name) { switch (name) {
default: default:
@@ -60,9 +61,9 @@ export default function nodeVariadic(entity) {
break break
} }
break break
case Configuration.paths.executionSequence: case p.executionSequence:
prefix ??= "Then" prefix ??= "Then"
case Configuration.paths.multiGate: case p.multiGate:
prefix ??= "Out" prefix ??= "Out"
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
pinIndexFromEntity ??= pinEntity => Number( pinIndexFromEntity ??= pinEntity => Number(
@@ -71,7 +72,7 @@ export default function nodeVariadic(entity) {
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => pinNameFromIndex ??= (index, min = -1, max = -1, newPin) =>
`${prefix} ${index >= 0 ? index : min > 0 ? `${prefix} 0` : max + 1}` `${prefix} ${index >= 0 ? index : min > 0 ? `${prefix} 0` : max + 1}`
break break
// case Configuration.paths.niagaraNodeOp: // case p.niagaraNodeOp:
// pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isInput()) // pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isInput())
// pinIndexFromEntity ??= indexFromUpperCaseLetterName // pinIndexFromEntity ??= indexFromUpperCaseLetterName
// pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { // pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => {
@@ -81,12 +82,12 @@ export default function nodeVariadic(entity) {
// return result // return result
// } // }
// break // break
case Configuration.paths.switchInteger: case p.switchInteger:
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.toString().match(/^\s*(\d+)\s*$/)?.[1]) pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.toString().match(/^\s*(\d+)\s*$/)?.[1])
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => (index < 0 ? max + 1 : index).toString() pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => (index < 0 ? max + 1 : index).toString()
break break
case Configuration.paths.switchGameplayTag: case p.switchGameplayTag:
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => {
const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}` const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`
entity.PinNames ??= new ArrayEntity() entity.PinNames ??= new ArrayEntity()
@@ -95,8 +96,8 @@ export default function nodeVariadic(entity) {
entity.PinTags.valueOf()[entity.PinTags.length] = null entity.PinTags.valueOf()[entity.PinTags.length] = null
return result return result
} }
case Configuration.paths.switchName: case p.switchName:
case Configuration.paths.switchString: case p.switchString:
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.toString().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]) pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.toString().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1])
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => {

49
js/decoding/pinColor.js Normal file → Executable file
View File

@@ -1,25 +1,14 @@
import { css } from "lit" import { css } from "lit"
import Configuration from "../Configuration.js" import Configuration from "../Configuration.js"
const p = Configuration.paths
const colors = { const colors = {
[Configuration.paths.niagaraBool]: css`146, 0, 0`,
[Configuration.paths.niagaraDataInterfaceVolumeTexture]: css`0, 168, 242`,
[Configuration.paths.niagaraFloat]: css`160, 250, 68`,
[Configuration.paths.niagaraMatrix]: css`0, 88, 200`,
[Configuration.paths.niagaraNumeric]: css`0, 88, 200`,
[Configuration.paths.niagaraPosition]: css`251, 146, 251`,
[Configuration.paths.quat4f]: css`0, 88, 200`,
[Configuration.paths.rotator]: css`157, 177, 251`,
[Configuration.paths.transform]: css`227, 103, 0`,
[Configuration.paths.vector]: css`251, 198, 34`,
[Configuration.paths.vector3f]: css`250, 200, 36`,
[Configuration.paths.vector4f]: css`0, 88, 200`,
"Any": css`132, 132, 132`, "Any": css`132, 132, 132`,
"Any[]": css`132, 132, 132`, "Any[]": css`132, 132, 132`,
"audio": css`252, 148, 252`, "audio": css`252, 148, 252`,
"blue": css`0, 0, 255`, "blue": css`0, 0, 255`,
"bool": css`146, 0, 0`, "bool": css`146, 0, 0`,
"byte": css`0, 109, 99`, "byte": css`0, 110, 100`,
"class": css`88, 0, 186`, "class": css`88, 0, 186`,
"default": css`255, 255, 255`, "default": css`255, 255, 255`,
"delegate": css`255, 56, 56`, "delegate": css`255, 56, 56`,
@@ -27,16 +16,16 @@ const colors = {
"exec": css`240, 240, 240`, "exec": css`240, 240, 240`,
"float": css`160, 252, 70`, "float": css`160, 252, 70`,
"green": css`0, 255, 0`, "green": css`0, 255, 0`,
"int": css`31, 224, 172`, "int": css`30, 224, 172`,
"int32": css`30, 224, 172`, "int32": css`30, 224, 172`,
"int64": css`169, 223, 172`, "int64": css`170, 224, 172`,
"interface": css`238, 252, 168`, "interface": css`238, 252, 168`,
"name": css`201, 128, 251`, "name": css`200, 128, 252`,
"object": css`0, 168, 242`, "object": css`0, 168, 242`,
"Param": css`255, 166, 39`, "Param": css`255, 166, 40`,
"Param[]": css`255, 166, 39`, "Param[]": css`255, 166, 40`,
"Point": css`63, 137, 255`, "Point": css`64, 138, 255`,
"Point[]": css`63, 137, 255`, "Point[]": css`64, 137, 255`,
"real": css`54, 208, 0`, "real": css`54, 208, 0`,
"red": css`255, 0, 0`, "red": css`255, 0, 0`,
"string": css`251, 0, 208`, "string": css`251, 0, 208`,
@@ -48,6 +37,21 @@ const colors = {
"Volume": css`230, 69, 188`, "Volume": css`230, 69, 188`,
"Volume[]": css`230, 69, 188`, "Volume[]": css`230, 69, 188`,
"wildcard": css`128, 120, 120`, "wildcard": css`128, 120, 120`,
[p.linearColor]: css`0, 88, 200`,
[p.niagaraBool]: css`146, 0, 0`,
[p.niagaraDataInterfaceCollisionQuery]: css`0, 168, 242`,
[p.niagaraDataInterfaceCurlNoise]: css`0, 168, 242`,
[p.niagaraDataInterfaceVolumeTexture]: css`0, 168, 242`,
[p.niagaraFloat]: css`160, 250, 68`,
[p.niagaraInt32]: css`30, 224, 172`,
[p.niagaraPosition]: css`251, 146, 251`,
[p.quat4f]: css`0, 88, 200`,
[p.rotator]: css`157, 177, 251`,
[p.transform]: css`227, 103, 0`,
[p.vector]: css`251, 198, 34`,
[p.vector2f]: css`0, 88, 200`,
[p.vector3f]: css`250, 200, 36`,
[p.vector4f]: css`0, 88, 200`,
} }
const pinColorMaterial = css`120, 120, 120` const pinColorMaterial = css`120, 120, 120`
@@ -62,7 +66,8 @@ export default function pinColor(entity) {
} else if (entity.PinType.PinCategory?.toString() === "optional") { } else if (entity.PinType.PinCategory?.toString() === "optional") {
return pinColorMaterial return pinColorMaterial
} }
return colors[entity.getType()] const type = entity.getType()
return colors[type]
?? colors[entity.PinType.PinCategory?.toString().toLowerCase()] ?? colors[entity.PinType.PinCategory?.toString().toLowerCase()]
?? colors["default"] ?? (type.startsWith("/Script/Niagara.") ? colors["struct"] : colors["default"])
} }

30
js/decoding/pinTemplate.js Normal file → Executable file
View File

@@ -7,6 +7,7 @@ import IntPinTemplate from "../template/pin/IntPinTemplate.js"
import LinearColorPinTemplate from "../template/pin/LinearColorPinTemplate.js" import LinearColorPinTemplate from "../template/pin/LinearColorPinTemplate.js"
import NamePinTemplate from "../template/pin/NamePinTemplate.js" import NamePinTemplate from "../template/pin/NamePinTemplate.js"
import PinTemplate from "../template/pin/PinTemplate.js" import PinTemplate from "../template/pin/PinTemplate.js"
import ReadonlyNamePinTemplate from "../template/pin/ReadonlyInputPinTemplate.js"
import RealPinTemplate from "../template/pin/RealPinTemplate.js" import RealPinTemplate from "../template/pin/RealPinTemplate.js"
import ReferencePinTemplate from "../template/pin/ReferencePinTemplate.js" import ReferencePinTemplate from "../template/pin/ReferencePinTemplate.js"
import RotatorPinTemplate from "../template/pin/RotatorPinTemplate.js" import RotatorPinTemplate from "../template/pin/RotatorPinTemplate.js"
@@ -14,11 +15,14 @@ import StringPinTemplate from "../template/pin/StringPinTemplate.js"
import Vector2DPinTemplate from "../template/pin/Vector2DPinTemplate.js" import Vector2DPinTemplate from "../template/pin/Vector2DPinTemplate.js"
import Vector4DPinTemplate from "../template/pin/Vector4DPinTemplate.js" import Vector4DPinTemplate from "../template/pin/Vector4DPinTemplate.js"
import VectorPinTemplate from "../template/pin/VectorPinTemplate.js" import VectorPinTemplate from "../template/pin/VectorPinTemplate.js"
import pinTitle from "./pinTitle.js"
const p = Configuration.paths
const inputPinTemplates = { const inputPinTemplates = {
"bool": BoolPinTemplate, "bool": BoolPinTemplate,
"byte": IntPinTemplate, "byte": IntPinTemplate,
"enum": EnumPinTemplate, "enum": EnumPinTemplate,
"float": RealPinTemplate,
"int": IntPinTemplate, "int": IntPinTemplate,
"int64": Int64PinTemplate, "int64": Int64PinTemplate,
"MUTABLE_REFERENCE": ReferencePinTemplate, "MUTABLE_REFERENCE": ReferencePinTemplate,
@@ -26,14 +30,17 @@ const inputPinTemplates = {
"real": RealPinTemplate, "real": RealPinTemplate,
"rg": Vector2DPinTemplate, "rg": Vector2DPinTemplate,
"string": StringPinTemplate, "string": StringPinTemplate,
[Configuration.paths.linearColor]: LinearColorPinTemplate, [p.linearColor]: LinearColorPinTemplate,
[Configuration.paths.niagaraBool]: BoolPinTemplate, [p.niagaraBool]: BoolPinTemplate,
[Configuration.paths.niagaraPosition]: VectorPinTemplate, [p.niagaraFloat]: RealPinTemplate,
[Configuration.paths.rotator]: RotatorPinTemplate, [p.niagaraInt32]: IntPinTemplate,
[Configuration.paths.vector]: VectorPinTemplate, [p.niagaraPosition]: VectorPinTemplate,
[Configuration.paths.vector2D]: Vector2DPinTemplate, [p.rotator]: RotatorPinTemplate,
[Configuration.paths.vector3f]: VectorPinTemplate, [p.vector]: VectorPinTemplate,
[Configuration.paths.vector4f]: Vector4DPinTemplate, [p.vector2D]: Vector2DPinTemplate,
[p.vector2f]: Vector2DPinTemplate,
[p.vector3f]: VectorPinTemplate,
[p.vector4f]: Vector4DPinTemplate,
} }
/** @param {PinEntity<IEntity>} entity */ /** @param {PinEntity<IEntity>} entity */
@@ -44,9 +51,12 @@ export default function pinTemplate(entity) {
if (entity.PinType.bIsReference?.valueOf() && !entity.PinType.bIsConst?.valueOf()) { if (entity.PinType.bIsReference?.valueOf() && !entity.PinType.bIsConst?.valueOf()) {
return inputPinTemplates["MUTABLE_REFERENCE"] return inputPinTemplates["MUTABLE_REFERENCE"]
} }
const type = entity.getType() if (entity.isExecution()) {
if (type === "exec") {
return ExecPinTemplate return ExecPinTemplate
} }
if (entity.PinName?.toString() === "self" && pinTitle(entity) === "Target") {
return ReadonlyNamePinTemplate
}
const type = entity.getType()
return (entity.isInput() ? inputPinTemplates[type] : PinTemplate) ?? PinTemplate return (entity.isInput() ? inputPinTemplates[type] : PinTemplate) ?? PinTemplate
} }

1
js/decoding/pinTitle.js Normal file → Executable file
View File

@@ -11,5 +11,6 @@ export default function pinTitle(entity) {
return match[1] // In case they match, then keep the case of the PinToolTip return match[1] // In case they match, then keep the case of the PinToolTip
} }
} }
result = result.replace(/^Module\./, "")
return result return result
} }

0
js/element/ColorHandlerElement.js Normal file → Executable file
View File

0
js/element/ColorSliderElement.js Normal file → Executable file
View File

0
js/element/DropdownElement.js Normal file → Executable file
View File

0
js/element/ElementFactory.js Normal file → Executable file
View File

0
js/element/IDraggableControlElement.js Normal file → Executable file
View File

0
js/element/IDraggableElement.js Normal file → Executable file
View File

0
js/element/IElement.js Normal file → Executable file
View File

36
js/element/IFromToPositionedElement.js Normal file → Executable file
View File

@@ -9,19 +9,19 @@ export default class IFromToPositionedElement extends IElement {
static properties = { static properties = {
...super.properties, ...super.properties,
fromX: { originX: {
type: Number, type: Number,
attribute: false, attribute: false,
}, },
fromY: { originY: {
type: Number, type: Number,
attribute: false, attribute: false,
}, },
toX: { targetX: {
type: Number, type: Number,
attribute: false, attribute: false,
}, },
toY: { targetY: {
type: Number, type: Number,
attribute: false, attribute: false,
}, },
@@ -29,35 +29,35 @@ export default class IFromToPositionedElement extends IElement {
constructor() { constructor() {
super() super()
this.fromX = 0 this.originX = 0
this.fromY = 0 this.originY = 0
this.toX = 0 this.targetX = 0
this.toY = 0 this.targetY = 0
} }
/** @param {Coordinates} param0 */ /** @param {Coordinates} param0 */
setBothLocations([x, y]) { setBothLocations([x, y]) {
this.fromX = x this.originX = x
this.fromY = y this.originY = y
this.toX = x this.targetX = x
this.toY = y this.targetY = y
} }
/** /**
* @param {Number} x * @param {Number} x
* @param {Number} y * @param {Number} y
*/ */
addSourceLocation(x, y) { addOriginLocation(x, y) {
this.fromX += x this.originX += x
this.fromY += y this.originY += y
} }
/** /**
* @param {Number} x * @param {Number} x
* @param {Number} y * @param {Number} y
*/ */
addDestinationLocation(x, y) { addTargetLocation(x, y) {
this.toX += x this.targetX += x
this.toY += y this.targetY += y
} }
} }

0
js/element/ISelectableDraggableElement.js Normal file → Executable file
View File

0
js/element/InputElement.js Normal file → Executable file
View File

249
js/element/LinkElement.js Normal file → Executable file
View File

@@ -5,6 +5,7 @@ import Utility from "../Utility.js"
import BooleanEntity from "../entity/BooleanEntity.js" import BooleanEntity from "../entity/BooleanEntity.js"
import LinkTemplate from "../template/LinkTemplate.js" import LinkTemplate from "../template/LinkTemplate.js"
import IFromToPositionedElement from "./IFromToPositionedElement.js" import IFromToPositionedElement from "./IFromToPositionedElement.js"
import LinearColorEntity from "../entity/LinearColorEntity.js"
/** @extends {IFromToPositionedElement<Object, LinkTemplate>} */ /** @extends {IFromToPositionedElement<Object, LinkTemplate>} */
export default class LinkElement extends IFromToPositionedElement { export default class LinkElement extends IFromToPositionedElement {
@@ -17,9 +18,34 @@ export default class LinkElement extends IFromToPositionedElement {
converter: BooleanEntity.booleanConverter, converter: BooleanEntity.booleanConverter,
reflect: true, reflect: true,
}, },
originNode: {
type: String,
attribute: "data-origin-node",
reflect: true,
},
originPin: {
type: String,
attribute: "data-origin-pin",
reflect: true,
},
targetNode: {
type: String,
attribute: "data-target-node",
reflect: true,
},
targetPin: {
type: String,
attribute: "data-target-pin",
reflect: true,
},
originatesFromInput: { originatesFromInput: {
type: Boolean, type: Boolean,
attribute: false, attribute: "data-from-input",
converter: BooleanEntity.booleanConverter,
reflect: true,
},
color: {
type: LinearColorEntity,
}, },
svgPathD: { svgPathD: {
type: String, type: String,
@@ -36,30 +62,58 @@ export default class LinkElement extends IFromToPositionedElement {
} }
/** @type {PinElement} */ /** @type {PinElement} */
#source #origin
get source() { get origin() {
return this.#source return this.#origin
} }
set source(pin) { set origin(pin) {
this.#setPin(pin, false) this.#setPin(pin, false)
} }
/** @type {PinElement} */ /** @type {PinElement} */
#destination #target
get destination() { get target() {
return this.#destination return this.#target
} }
set destination(pin) { set target(pin) {
this.#setPin(pin, true) this.#setPin(pin, true)
} }
/** @param {UEBNodeUpdateEvent} e */
#nodeUpdateHandler = e => {
if (this.#origin.nodeElement === e.target) {
if (this.originNode != this.#origin.nodeElement.nodeTitle) {
this.originNode = this.#origin.nodeElement.nodeTitle
}
this.setOriginLocation()
} else if (this.#target.nodeElement === e.target) {
if (this.targetNode != this.#target.nodeElement.nodeTitle) {
this.targetNode = this.#target.nodeElement.nodeTitle
}
this.setTargetLocation()
} else {
throw new Error("Unexpected node update")
}
}
/** @param {UEBNodeUpdateEvent} e */
#pinUpdateHandler = e => {
const colorReferencePin = this.getOutputPin(true)
if (!this.color?.equals(colorReferencePin.color)) {
this.color = colorReferencePin.color
}
}
#nodeDeleteHandler = () => this.remove() #nodeDeleteHandler = () => this.remove()
/** @param {UEBDragEvent} e */ /** @param {UEBDragEvent} e */
#nodeDragSourceHandler = e => this.addSourceLocation(...e.detail.value) #nodeDragOriginHandler = e => this.addOriginLocation(...e.detail.value)
/** @param {UEBDragEvent} e */ /** @param {UEBDragEvent} e */
#nodeDragDestinatonHandler = e => this.addDestinationLocation(...e.detail.value) #nodeDragTargetHandler = e => this.addTargetLocation(...e.detail.value)
#nodeReflowSourceHandler = e => this.setSourceLocation() #nodeReflowOriginHandler = e => {
#nodeReflowDestinatonHandler = e => this.setDestinationLocation() if (this.origin.isKnot()) {
this.originatesFromInput = this.origin.isInputVisually()
}
this.setOriginLocation()
}
#nodeReflowTargetHandler = e => this.setTargetLocation()
/** @type {TemplateResult | nothing} */ /** @type {TemplateResult | nothing} */
linkMessageIcon = nothing linkMessageIcon = nothing
@@ -72,178 +126,197 @@ export default class LinkElement extends IFromToPositionedElement {
constructor() { constructor() {
super() super()
this.dragging = false this.dragging = false
this.originNode = ""
this.originPin = ""
this.targetNode = ""
this.targetPin = ""
this.originatesFromInput = false this.originatesFromInput = false
this.color = new LinearColorEntity()
this.startPercentage = 0 this.startPercentage = 0
this.svgPathD = "" this.svgPathD = ""
this.startPixels = 0 this.startPixels = 0
} }
/** /**
* @param {PinElement} source * @param {PinElement} origin
* @param {PinElement?} destination * @param {PinElement?} target
*/ */
static newObject(source, destination) { static newObject(origin, target) {
const result = new LinkElement() const result = new LinkElement()
result.initialize(source, destination) result.initialize(origin, target)
return result return result
} }
/** /**
* @param {PinElement} source * @param {PinElement} origin
* @param {PinElement?} destination * @param {PinElement?} target
*/ */
// @ts-expect-error // @ts-expect-error
initialize(source, destination) { initialize(origin, target) {
super.initialize({}, new LinkTemplate()) super.initialize({}, new LinkTemplate())
if (source) { if (origin) {
this.source = source this.origin = origin
if (!destination) { if (!target) {
this.toX = this.fromX this.targetX = this.originX
this.toY = this.fromY this.targetY = this.originY
} }
} }
if (destination) { if (target) {
this.destination = destination this.target = target
if (!source) { if (!origin) {
this.fromX = this.toX this.originX = this.targetX
this.fromY = this.toY this.originY = this.targetY
} }
} }
} }
/** /**
* @param {PinElement} pin * @param {PinElement} pin
* @param {Boolean} isDestinationPin * @param {Boolean} isTargetPin
*/ */
#setPin(pin, isDestinationPin) { #setPin(pin, isTargetPin) {
const getCurrentPin = () => isDestinationPin ? this.destination : this.source const getCurrentPin = () => isTargetPin ? this.target : this.origin
if (getCurrentPin() == pin) { if (getCurrentPin() == pin) {
return return
} }
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement() const nodeElement = getCurrentPin().getNodeElement()
nodeElement.removeEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler)
nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler) nodeElement.removeEventListener(Configuration.removeEventName, this.#nodeDeleteHandler)
nodeElement.removeEventListener( nodeElement.removeEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
)
nodeElement.removeEventListener(
Configuration.nodeReflowEventName,
isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler
) )
getCurrentPin().removeEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
this.#unlinkPins() this.#unlinkPins()
} }
isDestinationPin if (isTargetPin) {
? this.#destination = pin this.#target = pin
: this.#source = pin this.targetNode = pin?.nodeElement.nodeTitle
this.targetPin = pin?.pinId.toString()
} else {
this.#origin = pin
this.originNode = pin?.nodeElement.nodeTitle
this.originPin = pin?.pinId.toString()
}
if (getCurrentPin()) { if (getCurrentPin()) {
const nodeElement = getCurrentPin().getNodeElement() const nodeElement = getCurrentPin().getNodeElement()
nodeElement.addEventListener(Configuration.nodeUpdateEventName, this.#nodeUpdateHandler)
nodeElement.addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler) nodeElement.addEventListener(Configuration.removeEventName, this.#nodeDeleteHandler)
nodeElement.addEventListener( nodeElement.addEventListener(
Configuration.nodeDragEventName, Configuration.nodeDragEventName,
isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler isTargetPin ? this.#nodeDragTargetHandler : this.#nodeDragOriginHandler
) )
nodeElement.addEventListener( getCurrentPin().addEventListener(Configuration.pinUpdateEventName, this.#pinUpdateHandler)
Configuration.nodeReflowEventName, isTargetPin
isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler ? this.setTargetLocation()
) : (this.setOriginLocation(), this.originatesFromInput = this.origin.isInputVisually())
isDestinationPin
? this.setDestinationLocation()
: (this.setSourceLocation(), this.originatesFromInput = this.source.isInput())
this.#linkPins() this.#linkPins()
} }
this.color = this.getOutputPin(true)?.color
} }
#linkPins() { #linkPins() {
if (this.source && this.destination) { if (this.origin && this.target) {
this.source.linkTo(this.destination) this.origin.linkTo(this.target)
this.destination.linkTo(this.source) this.target.linkTo(this.origin)
} }
} }
#unlinkPins() { #unlinkPins() {
if (this.source && this.destination) { if (this.origin && this.target) {
this.source.unlinkFrom(this.destination, false) this.origin.unlinkFrom(this.target, false)
this.destination.unlinkFrom(this.source, false) this.target.unlinkFrom(this.origin, false)
} }
} }
cleanup() { cleanup() {
super.cleanup() super.cleanup()
this.#unlinkPins() this.#unlinkPins()
this.source = null this.origin = null
this.destination = null this.target = null
} }
/** @param {Coordinates} location */ /** @param {Coordinates} location */
setSourceLocation(location = null, canPostpone = true) { setOriginLocation(location = null, canPostpone = true) {
if (location == null) { if (location == null) {
const self = this const self = this
if (canPostpone && (!this.hasUpdated || !this.source.hasUpdated)) { if (canPostpone && (!this.hasUpdated || !this.origin.hasUpdated)) {
Promise.all([this.updateComplete, this.source.updateComplete]) Promise.all([this.updateComplete, this.origin.updateComplete])
.then(() => self.setSourceLocation(null, false)) .then(() => self.setOriginLocation(null, false))
return return
} }
location = this.source.template.getLinkLocation() location = this.origin.template.getLinkLocation()
} }
const [x, y] = location const [x, y] = location
this.fromX = x this.originX = x
this.fromY = y this.originY = y
} }
/** @param {Coordinates} location */ /** @param {Coordinates} location */
setDestinationLocation(location = null, canPostpone = true) { setTargetLocation(location = null, canPostpone = true) {
if (location == null) { if (location == null) {
const self = this const self = this
if (canPostpone && (!this.hasUpdated || !this.destination.hasUpdated)) { if (canPostpone && (!this.hasUpdated || !this.target.hasUpdated)) {
Promise.all([this.updateComplete, this.destination.updateComplete]) Promise.all([this.updateComplete, this.target.updateComplete])
.then(() => self.setDestinationLocation(null, false)) .then(() => self.setTargetLocation(null, false))
return return
} }
location = this.destination.template.getLinkLocation() location = this.target.template.getLinkLocation()
} }
this.toX = location[0] this.targetX = location[0]
this.toY = location[1] this.targetY = location[1]
} }
getInputPin(getSomething = false) { getInputPin(getSomething = false) {
if (this.source?.isInput()) { if (this.origin?.isInput()) {
return this.source return this.origin
} }
if (this.destination?.isInput()) { if (this.target?.isInput()) {
return this.destination return this.target
} }
if (getSomething) { if (getSomething) {
return this.source ?? this.destination return this.origin ?? this.target
} }
} }
/** @param {PinElement} pin */ /** @param {PinElement} pin */
setInputPin(pin) { setInputPin(pin) {
if (this.source?.isInput()) { if (this.origin?.isInput()) {
this.source = pin this.origin = pin
} }
this.destination = pin this.target = pin
} }
getOutputPin(getSomething = false) { getOutputPin(getSomething = false) {
if (this.source?.isOutput()) { if (this.origin?.isOutput()) {
return this.source return this.origin
} }
if (this.destination?.isOutput()) { if (this.target?.isOutput()) {
return this.destination return this.target
} }
if (getSomething) { if (getSomething) {
return this.source ?? this.destination return this.origin ?? this.target
} }
} }
/** @param {PinElement} pin */ /** @param {PinElement} pin */
setOutputPin(pin) { setOutputPin(pin) {
if (this.destination?.isOutput()) { if (this.target?.isOutput()) {
this.destination = pin this.target = pin
}
this.origin = pin
}
/** @param {NodeElement} node */
getOtherPin(node) {
if (this.origin?.nodeElement === node) {
return this.target
}
if (this.target?.nodeElement === node) {
return this.origin
} }
this.source = pin
} }
startDragging() { startDragging() {
@@ -261,7 +334,7 @@ export default class LinkElement extends IFromToPositionedElement {
setMessageConvertType() { setMessageConvertType() {
this.linkMessageIcon = SVGIcon.convert this.linkMessageIcon = SVGIcon.convert
this.linkMessageText = html`Convert ${this.source.pinType} to ${this.destination.pinType}.` this.linkMessageText = html`Convert ${this.origin.pinType} to ${this.target.pinType}.`
} }
setMessageCorrect() { setMessageCorrect() {

37
js/element/NodeElement.js Normal file → Executable file
View File

@@ -101,13 +101,13 @@ export default class NodeElement extends ISelectableDraggableElement {
/** @param {String} name */ /** @param {String} name */
#redirectLinksBeforeRename(name) { #redirectLinksBeforeRename(name) {
for (let sourcePinElement of this.getPinElements()) { for (let originPinElement of this.getPinElements()) {
for (let targetPinReference of sourcePinElement.getLinks()) { for (let targetPinReference of originPinElement.getLinks()) {
this.blueprint.getPin(targetPinReference).redirectLink( this.blueprint.getPin(targetPinReference).redirectLink(
sourcePinElement, originPinElement,
new PinReferenceEntity( new PinReferenceEntity(
new SymbolEntity(name), new SymbolEntity(name),
sourcePinElement.entity.PinId, originPinElement.entity.PinId,
) )
) )
} }
@@ -135,21 +135,14 @@ export default class NodeElement extends ISelectableDraggableElement {
"Name", "Name",
/** @param {InstanceType<typeof ObjectEntity.attributes.Name>} newName */ /** @param {InstanceType<typeof ObjectEntity.attributes.Name>} newName */
newName => { newName => {
this.#redirectLinksBeforeRename(newName.value) this.#redirectLinksBeforeRename(newName?.toString())
this.nodeTitle = newName.value this.nodeTitle = newName?.toString()
this.nodeDisplayName = nodeTitle(entity) this.nodeDisplayName = nodeTitle(entity)
this.acknowledgeUpdate()
} }
) )
} }
async getUpdateComplete() {
let result = await super.getUpdateComplete()
for (const pin of this.getPinElements()) {
result &&= await pin.updateComplete
}
return result
}
/** @param {NodeElement} commentNode */ /** @param {NodeElement} commentNode */
bindToComment(commentNode) { bindToComment(commentNode) {
if (commentNode != this && !this.boundComments.includes(commentNode)) { if (commentNode != this && !this.boundComments.includes(commentNode)) {
@@ -192,14 +185,14 @@ export default class NodeElement extends ISelectableDraggableElement {
setNodeWidth(value) { setNodeWidth(value) {
this.entity.setNodeWidth(value) this.entity.setNodeWidth(value)
this.sizeX = value this.sizeX = value
this.acknowledgeReflow() this.acknowledgeUpdate(true)
} }
/** @param {Number} value */ /** @param {Number} value */
setNodeHeight(value) { setNodeHeight(value) {
this.entity.setNodeHeight(value) this.entity.setNodeHeight(value)
this.sizeY = value this.sizeY = value
this.acknowledgeReflow() this.acknowledgeUpdate(true)
} }
/** @param {IElement[]} nodesWhitelist */ /** @param {IElement[]} nodesWhitelist */
@@ -222,11 +215,13 @@ export default class NodeElement extends ISelectableDraggableElement {
super.setLocation(x, y, acknowledge) super.setLocation(x, y, acknowledge)
} }
acknowledgeReflow() { acknowledgeUpdate(resize = false) {
this.requestUpdate() const event = new CustomEvent(Configuration.nodeUpdateEventName)
this.updateComplete.then(() => this.computeSizes()) if (resize) {
let reflowEvent = new CustomEvent(Configuration.nodeReflowEventName) this.requestUpdate()
this.dispatchEvent(reflowEvent) this.updateComplete.then(() => this.computeSizes())
}
this.dispatchEvent(event)
} }
setShowAdvancedPinDisplay(value) { setShowAdvancedPinDisplay(value) {

106
js/element/PinElement.js Normal file → Executable file
View File

@@ -1,5 +1,5 @@
import Configuration from "../Configuration.js"
import pinTemplate from "../decoding/pinTemplate.js" import pinTemplate from "../decoding/pinTemplate.js"
import ArrayEntity from "../entity/ArrayEntity.js"
import BooleanEntity from "../entity/BooleanEntity.js" import BooleanEntity from "../entity/BooleanEntity.js"
import GuidEntity from "../entity/GuidEntity.js" import GuidEntity from "../entity/GuidEntity.js"
import LinearColorEntity from "../entity/LinearColorEntity.js" import LinearColorEntity from "../entity/LinearColorEntity.js"
@@ -44,7 +44,8 @@ export default class PinElement extends IElement {
fromAttribute: (value, type) => value fromAttribute: (value, type) => value
? LinearColorEntity.getLinearColorFromAnyFormat().parse(value) ? LinearColorEntity.getLinearColorFromAnyFormat().parse(value)
: null, : null,
toAttribute: (value, type) => value ? LinearColorEntity.printLinearColor(value) : null, /** @param {LinearColorEntity} value */
toAttribute: (value, type) => value?.toString() ?? "",
}, },
attribute: "data-color", attribute: "data-color",
reflect: true, reflect: true,
@@ -96,10 +97,11 @@ export default class PinElement extends IElement {
this.connectable = !entity.bNotConnectable?.valueOf() this.connectable = !entity.bNotConnectable?.valueOf()
super.initialize(entity, template) super.initialize(entity, template)
this.pinId = this.entity.PinId this.pinId = this.entity.PinId
this.pinType = this.entity.getType() this.updateType()
this.defaultValue = this.entity.getDefaultValue() this.defaultValue = this.entity.getDefaultValue()
this.color = PinElement.properties.color.converter.fromAttribute(this.getColor().toString())
this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden" this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden"
/** @type {LinearColorEntity} */
this.color = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString())
} }
setup() { setup() {
@@ -107,6 +109,15 @@ export default class PinElement extends IElement {
this.nodeElement = this.closest("ueb-node") this.nodeElement = this.closest("ueb-node")
} }
updateType() {
this.pinType = this.entity.getType()
const newColor = PinElement.properties.color.converter.fromAttribute(this.entity.pinColor().toString())
if (!this.color?.equals(newColor)) {
this.color = newColor
this.acknowledgeUpdate()
}
}
createPinReference() { createPinReference() {
return new PinReferenceEntity(new SymbolEntity(this.nodeElement.getNodeName()), this.getPinId()) return new PinReferenceEntity(new SymbolEntity(this.nodeElement.getNodeName()), this.getPinId())
} }
@@ -123,21 +134,68 @@ export default class PinElement extends IElement {
return this.entity.pinTitle() return this.entity.pinTitle()
} }
/** @return {CSSResult} */ /** @param {PinElement} pin */
getColor() { #traverseKnots(pin) {
return this.entity.pinColor() while (pin?.isKnot()) {
const pins = pin.nodeElement.getPinElements()
pin = pin === pins[0] ? pins[1] : pins[0]
pin = pin.isLinked ? this.blueprint.getPin(pin.getLinks()[0]) : null
}
return pin?.isKnot() ? undefined : pin
} }
isInput() { isInput(ignoreKnots = false) {
return this.entity.isInput() /** @type {PinElement} */
let result = this
if (ignoreKnots) {
return this.#traverseKnots(result)?.isInput()
}
return result.entity.isInput()
} }
isOutput() { /** @returns {boolean} True when the pin is the input part of a knot that can switch direction */
return this.entity.isOutput() isInputLoosely() {
return this.isInput(false) && this.isInput(true) === undefined
} }
getLinkLocation() { /** @returns {boolean} True when the pin is input and if it is a knot it appears input */
return this.template.getLinkLocation() isInputVisually() {
const template = /** @type {KnotNodeTemplate} */(this.nodeElement.template)
const isKnot = this.isKnot()
return isKnot && this.isInput() != template.switchDirectionsVisually
|| !isKnot && this.isInput()
}
isOutput(ignoreKnots = false) {
/** @type {PinElement} */
let result = this
if (ignoreKnots) {
return this.#traverseKnots(result)?.isOutput()
}
return result.entity.isOutput()
}
/** @returns {boolean} True when the pin is the output part of a knot that can switch direction */
isOutputLoosely() {
return this.isOutput(false) && this.isOutput(true) === undefined
}
/** @returns {boolean} True when the pin is output and if it is a knot it appears output */
isOutputVisually() {
const template = /** @type {KnotNodeTemplate} */(this.nodeElement.template)
const isKnot = this.isKnot()
return isKnot && this.isOutput() != template.switchDirectionsVisually
|| !isKnot && this.isOutput()
}
/** @returns {value is InstanceType<PinElement<>>} */
isKnot() {
return this.nodeElement?.getType() == Configuration.paths.knot
}
getLinkLocation(oppositeDirection = false) {
return this.template.getLinkLocation(oppositeDirection)
} }
getNodeElement() { getNodeElement() {
@@ -188,14 +246,17 @@ export default class PinElement extends IElement {
const pinReference = this.createPinReference() const pinReference = this.createPinReference()
if ( if (
this.isLinked this.isLinked
&& this.isOutput() && this.entity.isExecution()
&& (this.pinType === "exec" || targetPinElement.pinType === "exec") && this.isOutput(true)
&& !this.getLinks().some(ref => pinReference.equals(ref))) { && this.getLinks().some(ref => !pinReference.equals(ref))
) {
if (this.isKnot()) {
}
this.unlinkFromAll() this.unlinkFromAll()
} }
if (this.entity.linkTo(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity)) { if (this.entity.linkTo(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity)) {
this.isLinked = this.entity.isLinked() this.isLinked = this.entity.isLinked()
this.nodeElement?.template.linksChanged()
if (this.entity.recomputesNodeTitleOnChange) { if (this.entity.recomputesNodeTitleOnChange) {
this.nodeElement?.computeNodeDisplayName() this.nodeElement?.computeNodeDisplayName()
} }
@@ -206,7 +267,6 @@ export default class PinElement extends IElement {
unlinkFrom(targetPinElement, removeLink = true) { unlinkFrom(targetPinElement, removeLink = true) {
if (this.entity.unlinkFrom(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity)) { if (this.entity.unlinkFrom(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity)) {
this.isLinked = this.entity.isLinked() this.isLinked = this.entity.isLinked()
this.nodeElement?.template.linksChanged()
if (removeLink) { if (removeLink) {
this.blueprint.getLink(this, targetPinElement)?.remove() // Might be called after the link is removed this.blueprint.getLink(this, targetPinElement)?.remove() // Might be called after the link is removed
} }
@@ -217,11 +277,8 @@ export default class PinElement extends IElement {
} }
unlinkFromAll() { unlinkFromAll() {
const isLinked = this.getLinks().length
this.getLinks().map(ref => this.blueprint.getPin(ref)).forEach(pin => this.unlinkFrom(pin)) this.getLinks().map(ref => this.blueprint.getPin(ref)).forEach(pin => this.unlinkFrom(pin))
if (isLinked) { const isLinked = false
this.nodeElement?.template.linksChanged()
}
} }
/** /**
@@ -239,4 +296,9 @@ export default class PinElement extends IElement {
} }
return false return false
} }
acknowledgeUpdate() {
let event = new CustomEvent(Configuration.pinUpdateEventName)
this.dispatchEvent(event)
}
} }

12
js/element/SelectorElement.js Normal file → Executable file
View File

@@ -37,16 +37,16 @@ export default class SelectorElement extends IFromToPositionedElement {
/** @param {Coordinates} finalPosition */ /** @param {Coordinates} finalPosition */
selectTo(finalPosition) { selectTo(finalPosition) {
this.selectionModel.selectTo(finalPosition) this.selectionModel.selectTo(finalPosition)
this.toX = finalPosition[0] this.targetX = finalPosition[0]
this.toY = finalPosition[1] this.targetY = finalPosition[1]
} }
endSelect() { endSelect() {
this.blueprint.selecting = false this.blueprint.selecting = false
this.selectionModel = null this.selectionModel = null
this.fromX = 0 this.originX = 0
this.fromY = 0 this.originY = 0
this.toX = 0 this.targetX = 0
this.toY = 0 this.targetY = 0
} }
} }

0
js/element/WindowElement.js Normal file → Executable file
View File

0
js/element/defineElements.js Normal file → Executable file
View File

0
js/entity/AlternativesEntity.js Normal file → Executable file
View File

3
js/entity/ArrayEntity.js Normal file → Executable file
View File

@@ -33,8 +33,7 @@ export default class ArrayEntity extends IEntity {
if ((trailing !== undefined) !== Self.trailing) { if ((trailing !== undefined) !== Self.trailing) {
Self = Self.flagTrailing(trailing !== undefined) Self = Self.flagTrailing(trailing !== undefined)
} }
const result = new Self(values) return new Self(values)
return result
}).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`) }).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`)
} }

133
js/entity/BlueprintEntity.js Normal file → Executable file
View File

@@ -1,6 +1,7 @@
import Configuration from "../Configuration.js" import Configuration from "../Configuration.js"
import Utility from "../Utility.js" import Utility from "../Utility.js"
import ObjectEntity from "./ObjectEntity.js" import ObjectEntity from "./ObjectEntity.js"
import ScriptVariableEntity from "./ScriptVariableEntity.js"
export default class BlueprintEntity extends ObjectEntity { export default class BlueprintEntity extends ObjectEntity {
@@ -13,6 +14,18 @@ export default class BlueprintEntity extends ObjectEntity {
return this.#objectEntities return this.#objectEntities
} }
static attributes = {
...super.attributes,
ScriptVariables: super.attributes.ScriptVariables.asUniqueClass(true).withDefault(),
}
constructor(...args) {
super(...args)
if (!this.Name) {
this.Name = new (/** @type {typeof ObjectEntity} */(this.constructor).attributes.Name)("Blueprint")
}
}
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
getHomonymObjectEntity(entity) { getHomonymObjectEntity(entity) {
const name = entity.getObjectName() const name = entity.getObjectName()
@@ -27,6 +40,16 @@ export default class BlueprintEntity extends ObjectEntity {
return Configuration.nodeTitle(name, counter) return Configuration.nodeTitle(name, counter)
} }
/** @param {String} name */
updateNameIndex(name) {
const match = name.match(/(.+)_(\d+)$/)
if (match) {
name = match[1]
const index = Number(match[2])
this.#objectEntitiesNameCounter.set(name, Math.max(index, this.#objectEntitiesNameCounter.get(name) ?? 0))
}
}
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
addObjectEntity(entity) { addObjectEntity(entity) {
if (!this.#objectEntities.includes(entity)) { if (!this.#objectEntities.includes(entity)) {
@@ -54,35 +77,121 @@ export default class BlueprintEntity extends ObjectEntity {
return false return false
} }
/**
* @param {ObjectReferenceEntity} variable
* @param {IEntity} entity
*/
renameScriptVariable(variable, entity) {
const name = variable.getName()
const newName = this.takeFreeName(name)
{
[true, false].forEach(v => {
/** @type {ObjectEntity} */
let object = this[Configuration.subObjectAttributeNameFromReference(variable, v)]
object.Name.value = newName
object.Name = object.Name
})
}
variable.path.replace(name, newName)
return newName
}
/**
* @param {ScriptVariableEntity} scriptVariableEntity
* @returns {String}
*/
variableName(scriptVariableEntity) {
return this[Configuration.subObjectAttributeNameFromReference(scriptVariableEntity.ScriptVariable, true)]
?.["Variable"]
?.["Name"]
?.toString()
}
/** @param {String} variableName */
variableIndex(variableName) {
let i = 0
for (const v of this.ScriptVariables?.valueOf()) {
if (variableName == this.variableName(v)) {
return i
}
++i
}
}
/** @param {ObjectEntity} entity */ /** @param {ObjectEntity} entity */
mergeWith(entity) { mergeWith(entity) {
if (!entity.ScriptVariables || entity.ScriptVariables.length === 0) { if ((entity.ScriptVariables?.length ?? 0) === 0) {
// The entity does not add new variables
return this return this
} }
if (!this.ScriptVariables || this.ScriptVariables.length === 0) { const variableObjectNames = this.ScriptVariables.valueOf().map(v => v.ScriptVariable.getName())
this.ScriptVariables = entity.ScriptVariables
}
let scriptVariables = Utility.mergeArrays( let scriptVariables = Utility.mergeArrays(
this.ScriptVariables.valueOf(), this.ScriptVariables.valueOf(),
entity.ScriptVariables.valueOf(), entity.ScriptVariables.valueOf(),
(l, r) => l.OriginalChangeId.value == r.OriginalChangeId.value (l, r) => this.variableName(l) == this.variableName(r),
added => {
let name = added.ScriptVariable.getName()
if (variableObjectNames.includes(name)) {
name = this.renameScriptVariable(added.ScriptVariable, entity)
}
this.updateNameIndex(name)
}
) )
if (scriptVariables.length === this.ScriptVariables.length) { if (scriptVariables.length === this.ScriptVariables.length) {
// The entity does not add new variables
return this return this
} }
scriptVariables.reverse()
const blueprintEntity = /** @type {typeof BlueprintEntity} */(this.constructor)
const entries = scriptVariables.concat(scriptVariables).map((v, i) => { const entries = scriptVariables.concat(scriptVariables).map((v, i) => {
const name = Configuration.subObjectAttributeNameFromReference(v.ScriptVariable, i >= scriptVariables.length) const name = Configuration.subObjectAttributeNameFromReference(
return [ v.ScriptVariable,
name, i >= scriptVariables.length // First take all the small objects then all name only
this[name] ?? entity[name] )
] const object = this[name] ?? entity[name]
return object ? [name, object] : null
}) })
.filter(v => v)
entries.push( entries.push(
...Object.entries(this).filter(([k, v]) => ...Object.entries(this).filter(([k, v]) =>
!k.startsWith(Configuration.subObjectAttributeNamePrefix) !k.startsWith(Configuration.subObjectAttributeNamePrefix)
&& k !== "ExportedNodes" && k !== "ExportedNodes"
) ),
["ScriptVariables", new (blueprintEntity.attributes.ScriptVariables)(scriptVariables.reverse())]
) )
return new BlueprintEntity(Object.fromEntries(entries)) const result = new BlueprintEntity(Object.fromEntries(entries))
result.mirrorNameInExportPaths(entity.Name?.toString())
result.#objectEntitiesNameCounter = this.#objectEntitiesNameCounter
result.#objectEntities = this.#objectEntities
return result
}
/** @param {ObjectEntity[]} entities */
getVariablesAttributesReferringTo(...entities) {
let pins = new Set(...entities.flatMap(entity => entity.getPinEntities()).map(pin => pin.PinName.toString()))
let attributes = this.ScriptVariables
.valueOf()
.map(v => {
const keySimple = Configuration.subObjectAttributeNameFromReference(v.ScriptVariable, false)
const keyFull = Configuration.subObjectAttributeNameFromReference(v.ScriptVariable, true)
return {
simple: [keySimple, this[keySimple]],
full: [keyFull, this[keyFull]],
variable: v,
}
})
.filter(v => pins.has(v.full?.["Variable"]?.["Name"]))
.reduce(
(acc, cur) => {
acc.simple.push([cur.simple[0], cur.simple[1]])
acc.full.push([cur.full[0], cur.full[1]])
acc.ScriptVariables.push(cur.variable)
return acc
},
({ simple: [], full: [], ScriptVariables: [] })
)
return {
}
} }
} }

0
js/entity/ColorChannelEntity.js Normal file → Executable file
View File

0
js/entity/ComputedTypeEntity.js Normal file → Executable file
View File

0
js/entity/FormatTextEntity.js Normal file → Executable file
View File

10
js/entity/IEntity.js Normal file → Executable file
View File

@@ -44,6 +44,7 @@ export default class IEntity {
this.#keys = [... new Set(value)] this.#keys = [... new Set(value)]
} }
// @ts-expect-error
#lookbehind = /** @type {String} */(this.constructor.lookbehind) #lookbehind = /** @type {String} */(this.constructor.lookbehind)
get lookbehind() { get lookbehind() {
return this.#lookbehind.trim() return this.#lookbehind.trim()
@@ -145,9 +146,9 @@ export default class IEntity {
* @this {T} * @this {T}
* @returns {T} * @returns {T}
*/ */
static asUniqueClass() { static asUniqueClass(alwaysCreate = false) {
let result = this let result = this
if (this.name.length) { if (this.name.length || alwaysCreate) {
// @ts-expect-error // @ts-expect-error
result = (() => class extends this { })() // Comes from a lambda otherwise the class will have name "result" result = (() => class extends this { })() // Comes from a lambda otherwise the class will have name "result"
result.grammar = result.createGrammar() // Reassign grammar to capture the correct this from subclass result.grammar = result.createGrammar() // Reassign grammar to capture the correct this from subclass
@@ -429,4 +430,9 @@ export default class IEntity {
} }
return true return true
} }
/** @returns {IEntity | Boolean | Number | String | BigInt | (IEntity | Boolean | Number | String | BigInt)[]} */
valueOf() {
return this
}
} }

10
js/entity/InvariantTextEntity.js Normal file → Executable file
View File

@@ -19,18 +19,22 @@ export default class InvariantTextEntity extends IEntity {
P.reg(new RegExp(`${this.lookbehind}\\s*\\(`)), P.reg(new RegExp(`${this.lookbehind}\\s*\\(`)),
P.doubleQuotedString, P.doubleQuotedString,
P.reg(/\s*\)/) P.reg(/\s*\)/)
).map(([_0, value, _2]) => Number(value)), ).map(([_0, value, _2]) => value),
P.reg(new RegExp(this.lookbehind)).map(() => 0) // InvariantTextEntity can not have arguments P.reg(new RegExp(this.lookbehind)).map(() => "") // InvariantTextEntity can have no arguments
) )
.map(value => new this(value)) .map(value => new this(value))
.label("InvariantTextEntity") .label("InvariantTextEntity")
} }
doSerialize() { doSerialize() {
return this.lookbehind + "(" + this.value + ")" return this.lookbehind + '("' + this.value + '")'
} }
valueOf() { valueOf() {
return this.value return this.value
} }
toString() {
return this.value
}
} }

0
js/entity/KeyBindingEntity.js Normal file → Executable file
View File

0
js/entity/LinearColorEntity.js Normal file → Executable file
View File

10
js/entity/MirroredEntity.js Normal file → Executable file
View File

@@ -66,13 +66,13 @@ export default class MirroredEntity extends IEntity {
return this.getter?.().equals(other) return this.getter?.().equals(other)
} }
valueOf() { /** @returns {InstanceType<T>} */
this.valueOf = this.getter().valueOf.bind(this.getter()) valueOf(arg) {
return this.valueOf() // @ts-expect-error
return this.getter(arg).valueOf()
} }
toString() { toString() {
this.toString = this.getter().toString.bind(this.getter()) return this.getter().toString()
return this.toString()
} }
} }

0
js/entity/NullEntity.js Normal file → Executable file
View File

View File

@@ -47,7 +47,7 @@ export default class ObjectEntity extends IEntity {
Class: ObjectReferenceEntity, Class: ObjectReferenceEntity,
Name: StringEntity, Name: StringEntity,
Archetype: ObjectReferenceEntity, Archetype: ObjectReferenceEntity,
ExportPath: ObjectReferenceEntity, ExportPath: MirroredEntity.of(ObjectReferenceEntity),
ObjectRef: ObjectReferenceEntity, ObjectRef: ObjectReferenceEntity,
BlueprintElementType: ObjectReferenceEntity, BlueprintElementType: ObjectReferenceEntity,
BlueprintElementInstance: ObjectReferenceEntity, BlueprintElementInstance: ObjectReferenceEntity,
@@ -63,6 +63,7 @@ export default class ObjectEntity extends IEntity {
bIsPureFunc: BooleanEntity, bIsPureFunc: BooleanEntity,
bIsConstFunc: BooleanEntity, bIsConstFunc: BooleanEntity,
bIsCaseSensitive: BooleanEntity, bIsCaseSensitive: BooleanEntity,
bDefaultsToPureFunc: BooleanEntity,
VariableReference: VariableReferenceEntity, VariableReference: VariableReferenceEntity,
SelfContextInfo: SymbolEntity, SelfContextInfo: SymbolEntity,
DelegatePropertyName: StringEntity, DelegatePropertyName: StringEntity,
@@ -107,14 +108,19 @@ export default class ObjectEntity extends IEntity {
SizeX: MirroredEntity.of(IntegerEntity), SizeX: MirroredEntity.of(IntegerEntity),
SizeY: MirroredEntity.of(IntegerEntity), SizeY: MirroredEntity.of(IntegerEntity),
Text: MirroredEntity.of(StringEntity), Text: MirroredEntity.of(StringEntity),
ParameterName: StringEntity,
ExpressionGUID: GuidEntity,
MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity), MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity),
MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity), MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity),
MaterialExpressionGuid: GuidEntity,
NodeTitle: StringEntity, NodeTitle: StringEntity,
NodeTitleColor: LinearColorEntity, NodeTitleColor: LinearColorEntity,
PositionX: MirroredEntity.of(IntegerEntity), PositionX: MirroredEntity.of(IntegerEntity),
PositionY: MirroredEntity.of(IntegerEntity), PositionY: MirroredEntity.of(IntegerEntity),
SettingsInterface: ObjectReferenceEntity, SettingsInterface: ObjectReferenceEntity,
PCGNode: ObjectReferenceEntity, PCGNode: ObjectReferenceEntity,
SoundNode: ObjectReferenceEntity,
SoundWaveAssetPtr: ObjectReferenceEntity,
HiGenGridSize: SymbolEntity, HiGenGridSize: SymbolEntity,
Operation: SymbolEntity, Operation: SymbolEntity,
NodePosX: IntegerEntity, NodePosX: IntegerEntity,
@@ -136,10 +142,13 @@ export default class ObjectEntity extends IEntity {
NodeGuid: GuidEntity, NodeGuid: GuidEntity,
ErrorType: IntegerEntity, ErrorType: IntegerEntity,
ErrorMsg: StringEntity, ErrorMsg: StringEntity,
ScriptVariables: ArrayEntity.of(ScriptVariableEntity), ScriptVariables: ArrayEntity.flagInlined().of(ScriptVariableEntity),
Node: MirroredEntity.of(ObjectReferenceEntity), Node: MirroredEntity.of(ObjectReferenceEntity),
ExportedNodes: StringEntity, ExportedNodes: StringEntity,
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(), CustomProperties: ArrayEntity
.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity))
.withDefault()
.flagSilent(),
} }
static customPropertyGrammar = P.seq( static customPropertyGrammar = P.seq(
P.reg(/CustomProperties\s+/), P.reg(/CustomProperties\s+/),
@@ -154,29 +163,28 @@ export default class ObjectEntity extends IEntity {
Grammar.symbolQuoted.map(v => [v, true]), Grammar.symbolQuoted.map(v => [v, true]),
Grammar.symbol.map(v => [v, false]), Grammar.symbol.map(v => [v, false]),
), ),
P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) // Number in parentheses then equal
) ).chain(
.chain( /** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */ ([[symbol, quoted], index]) =>
([[symbol, quoted], index]) => (this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue => values => {
values => { if (values[symbol] === undefined) {
if (values[symbol] === undefined) { let arrayEntity = ArrayEntity
let arrayEntity = ArrayEntity if (quoted != arrayEntity.quoted) {
if (quoted != arrayEntity.quoted) { arrayEntity = arrayEntity.flagQuoted(quoted)
arrayEntity = arrayEntity.flagQuoted(quoted)
}
if (!arrayEntity.inlined) {
arrayEntity = arrayEntity.flagInlined()
}
values[symbol] = new arrayEntity()
} }
/** @type {ArrayEntity} */ if (!arrayEntity.inlined) {
const target = values[symbol] arrayEntity = arrayEntity.flagInlined()
target.values[index] = currentValue }
values[symbol] = new arrayEntity()
} }
) /** @type {ArrayEntity} */
) const target = values[symbol]
target.values[index] = currentValue
}
)
)
static grammar = this.createGrammar() static grammar = this.createGrammar()
static grammarMultipleObjects = P.seq( static grammarMultipleObjects = P.seq(
P.whitespaceOpt, P.whitespaceOpt,
@@ -202,20 +210,21 @@ export default class ObjectEntity extends IEntity {
super(values) super(values)
// Attributes // Attributes
/** @type {ArrayEntity<typeof PinEntity | typeof UnknownPinEntity>} */ this.CustomProperties
/** @type {InstanceType<typeof ObjectEntity.attributes.AddedPins>} */ this.AddedPins /** @type {InstanceType<typeof ObjectEntity.attributes.AddedPins>} */ this.AddedPins
/** @type {InstanceType<typeof ObjectEntity.attributes.AdvancedPinDisplay>} */ this.AdvancedPinDisplay /** @type {InstanceType<typeof ObjectEntity.attributes.AdvancedPinDisplay>} */ this.AdvancedPinDisplay
/** @type {InstanceType<typeof ObjectEntity.attributes.Archetype>} */ this.Archetype /** @type {InstanceType<typeof ObjectEntity.attributes.Archetype>} */ this.Archetype
/** @type {InstanceType<typeof ObjectEntity.attributes.AxisKey>} */ this.AxisKey /** @type {InstanceType<typeof ObjectEntity.attributes.AxisKey>} */ this.AxisKey
/** @type {InstanceType<typeof ObjectEntity.attributes.bIsPureFunc>} */ this.bIsPureFunc /** @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.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.BlueprintElementType>} */ this.BlueprintElementType
/** @type {InstanceType<typeof ObjectEntity.attributes.Class>} */ this.Class /** @type {InstanceType<typeof ObjectEntity.attributes.Class>} */ this.Class
/** @type {InstanceType<typeof ObjectEntity.attributes.CommentColor>} */ this.CommentColor /** @type {InstanceType<typeof ObjectEntity.attributes.CommentColor>} */ this.CommentColor
/** @type {InstanceType<typeof ObjectEntity.attributes.ComponentPropertyName>} */ this.ComponentPropertyName /** @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 {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.DelegatePropertyName>} */ this.DelegatePropertyName
/** @type {InstanceType<typeof ObjectEntity.attributes.DelegateReference>} */ this.DelegateReference /** @type {InstanceType<typeof ObjectEntity.attributes.DelegateReference>} */ this.DelegateReference
/** @type {InstanceType<typeof ObjectEntity.attributes.EnabledState>} */ this.EnabledState /** @type {InstanceType<typeof ObjectEntity.attributes.EnabledState>} */ this.EnabledState
@@ -254,9 +263,12 @@ export default class ObjectEntity extends IEntity {
/** @type {InstanceType<typeof ObjectEntity.attributes.Operation>} */ this.Operation /** @type {InstanceType<typeof ObjectEntity.attributes.Operation>} */ this.Operation
/** @type {InstanceType<typeof ObjectEntity.attributes.OpName>} */ this.OpName /** @type {InstanceType<typeof ObjectEntity.attributes.OpName>} */ this.OpName
/** @type {InstanceType<typeof ObjectEntity.attributes.OutputPins>} */ this.OutputPins /** @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.PCGNode>} */ this.PCGNode
/** @type {InstanceType<typeof ObjectEntity.attributes.PinTags>} */ this.PinTags /** @type {InstanceType<typeof ObjectEntity.attributes.SoundNode>} */ this.SoundNode
/** @type {InstanceType<typeof ObjectEntity.attributes.SoundWaveAssetPtr>} */ this.SoundWaveAssetPtr
/** @type {InstanceType<typeof ObjectEntity.attributes.PinNames>} */ this.PinNames /** @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.PositionX>} */ this.PositionX
/** @type {InstanceType<typeof ObjectEntity.attributes.PositionY>} */ this.PositionY /** @type {InstanceType<typeof ObjectEntity.attributes.PositionY>} */ this.PositionY
/** @type {InstanceType<typeof ObjectEntity.attributes.ProxyFactoryFunctionName>} */ this.ProxyFactoryFunctionName /** @type {InstanceType<typeof ObjectEntity.attributes.ProxyFactoryFunctionName>} */ this.ProxyFactoryFunctionName
@@ -364,6 +376,7 @@ export default class ObjectEntity extends IEntity {
? outputIndex++ ? outputIndex++
: i : i
}) })
this.mirrorNameInExportPaths()
} }
/** @returns {P<ObjectEntity>} */ /** @returns {P<ObjectEntity>} */
@@ -409,12 +422,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} */ /** @type {String} */
#class #class
getClass() { getClass() {
if (!this.#class) { if (!this.#class) {
this.#class = (this.Class?.path ? this.Class.path : this.Class?.type) this.#class = (this.Class?.path ? this.Class.path : this.Class?.type)
?? this.ExportPath?.type ?? this.ExportPath?.valueOf()?.type
?? "" ?? ""
if (this.#class && !this.#class.startsWith("/")) { if (this.#class && !this.#class.startsWith("/")) {
// Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js // Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js
@@ -428,14 +475,18 @@ export default class ObjectEntity extends IEntity {
} }
getType() { getType() {
let classValue = this.getClass() const path = this.MacroGraphReference?.MacroGraph?.path
if (this.MacroGraphReference?.MacroGraph?.path) { if (path) {
return this.MacroGraphReference.MacroGraph.path return path
} }
if (this.MaterialExpression) { if (this.MaterialExpression) {
return this.MaterialExpression.type return this.MaterialExpression.type
} }
return classValue let subobject = this.getSounCueSubobject()
if (subobject) {
return subobject.getClass()
}
return this.getClass()
} }
getObjectName(dropCounter = false) { getObjectName(dropCounter = false) {
@@ -555,24 +606,10 @@ export default class ObjectEntity extends IEntity {
} }
isMaterial() { isMaterial() {
const classValue = this.getClass()
return this.getClass() === Configuration.paths.materialGraphNode return classValue.startsWith("/Script/Engine.MaterialExpression")
// return [ || classValue.startsWith("/Script/InterchangeImport.MaterialExpression")
// Configuration.paths.materialExpressionConstant, || classValue.startsWith("/Script/UnrealEd.MaterialGraph")
// 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())
} }
/** @return {ObjectEntity} */ /** @return {ObjectEntity} */
@@ -584,14 +621,33 @@ export default class ObjectEntity extends IEntity {
} }
isPcg() { isPcg() {
return this.getClass() === Configuration.paths.pcgEditorGraphNode return this.getClass() == Configuration.paths.pcgEditorGraphNode || this.getPcgSubobject() != null
|| this.getPcgSubobject() != null
} }
isNiagara() { isNiagara() {
return this.Class && (this.Class.type ? this.Class.type : this.Class.path)?.startsWith("/Script/NiagaraEditor.") return this.Class && (this.Class.type ? this.Class.type : this.Class.path)?.startsWith("/Script/NiagaraEditor.")
} }
isSoundCue() {
return this.getClass() == Configuration.paths.soundCueGraphNode
}
getBlueprintType() {
if (this.isMaterial()) {
return "MATERIAL"
}
if (this.isNiagara()) {
return "NIAGARA"
}
if (this.isPcg()) {
return "PCG Graph"
}
if (this.isSoundCue()) {
return "SOUND CUE"
}
return "BLUEPRINT"
}
/** @return {ObjectEntity} */ /** @return {ObjectEntity} */
getPcgSubobject() { getPcgSubobject() {
const node = this.PCGNode const node = this.PCGNode
@@ -600,6 +656,14 @@ export default class ObjectEntity extends IEntity {
: null : null
} }
/** @return {ObjectEntity} */
getSounCueSubobject() {
const node = this.SoundNode
return node
? this[Configuration.subObjectAttributeNameFromReference(node, true)]
: null
}
/** @return {ObjectEntity} */ /** @return {ObjectEntity} */
getSettingsObject() { getSettingsObject() {
const settings = this.SettingsInterface const settings = this.SettingsInterface
@@ -666,9 +730,10 @@ export default class ObjectEntity extends IEntity {
attributeSeparator = Self.attributeSeparator, attributeSeparator = Self.attributeSeparator,
wrap = Self.wrap, wrap = Self.wrap,
) { ) {
const isSelfOverriden = Self !== this.constructor
const deeperIndentation = indentation + Configuration.indentation const deeperIndentation = indentation + Configuration.indentation
const initial_trailing = this.trailing const initial_trailing = this.trailing
this.trailing = false this.trailing = true
const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap) const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap)
this.trailing = initial_trailing this.trailing = initial_trailing
let result = indentation + "Begin Object" let result = indentation + "Begin Object"
@@ -690,27 +755,27 @@ export default class ObjectEntity extends IEntity {
? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}` ? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}`
: "" : ""
) )
+ ((this.ExportPath?.type || this.ExportPath?.path) + ((this.ExportPath?.valueOf()?.type || this.ExportPath?.valueOf()?.path)
// && Self.attributes.ExportPath.ignored !== true // && Self.attributes.ExportPath.valueOf().ignored !== true
// && this.ExportPath.ignored !== true // && this.ExportPath.valueOf().ignored !== true
? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}` ? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}`
: "" : ""
) )
+ (content ? attributeSeparator + content : "") + attributeSeparator
+ content
+ (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true + (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true
? this.getCustomproperties() ? this.getCustomproperties()
.map(pin => .map(pin =>
attributeSeparator deeperIndentation
+ deeperIndentation
+ printKey("CustomProperties ") + printKey("CustomProperties ")
+ pin.serialize(insideString) + pin.serialize(insideString)
+ attributeSeparator
) )
.join("") .join("")
: "" : ""
) )
+ attributeSeparator
+ indentation + "End Object" + indentation + "End Object"
+ (this.trailing ? attributeSeparator : "") + (isSelfOverriden && Self.trailing || this.trailing ? attributeSeparator : "")
return result return result
} }
} }

View File

@@ -5,12 +5,6 @@ import IEntity from "./IEntity.js"
export default class ObjectReferenceEntity extends IEntity { export default class ObjectReferenceEntity extends IEntity {
/** @protected */
static _quotedParser = P.regArray(new RegExp(
`'"(${Grammar.Regex.InsideString.source})"'`
+ "|"
+ `'(${Grammar.Regex.InsideSingleQuotedString.source})'`
)).map(([_0, a, b]) => a ?? b)
static typeReference = P.reg( static typeReference = P.reg(
// @ts-expect-error // @ts-expect-error
new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source) new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source)
@@ -31,29 +25,31 @@ export default class ObjectReferenceEntity extends IEntity {
return this.#path return this.#path
} }
set path(value) { set path(value) {
this.#name = ""
this.#path = value this.#path = value
} }
#fullEscaped #serializer
/** @type {String} */
#full
get full() { get full() {
return this.#full return this.#serializer
} }
set full(value) { set full(value) {
this.#full = value this.#serializer = value
} }
#name = ""
constructor(type = "None", path = "", full = null) { /** @param {(t: String, p: String) => String} serializer */
constructor(
type = "None",
path = "",
serializer = type.includes("/") || path
? (t, p) => `"${t + (p ? (`'${p}'`) : "")}"`
: (t, p) => t) {
super() super()
this.#type = type this.#type = type
this.#path = path this.#path = path
this.#full = full ?? ( this.#serializer = serializer
this.type.includes("/") || this.path
? `"${this.type + (this.path ? (`'${this.path}'`) : "")}"`
: this.type
)
} }
/** @returns {P<ObjectReferenceEntity>} */ /** @returns {P<ObjectReferenceEntity>} */
@@ -71,10 +67,21 @@ export default class ObjectReferenceEntity extends IEntity {
new RegExp( new RegExp(
// @ts-expect-error // @ts-expect-error
"(" + this.typeReference.getParser().regexp.source + ")" "(" + this.typeReference.getParser().regexp.source + ")"
// @ts-expect-error + "(?:"
+ "(?:" + this._quotedParser.getParser().parser.regexp.source + ")" + `'"(${Grammar.Regex.InsideString.source})"'`
+ "|"
+ `'(${Grammar.Regex.InsideSingleQuotedString.source})'`
+ ")"
) )
).map(([full, type, ...path]) => new this(type, path.find(v => v), full)) ).map(([full, type, fullQuotedPath, simpleQuotedPath]) => {
let fullQuoted = fullQuotedPath ? true : false
let quotes = fullQuoted ? [`'"`, `"'`] : ["'", "'"]
return new this(
type,
fullQuoted ? fullQuotedPath : simpleQuotedPath,
(t, p) => t + quotes[0] + p + quotes[1]
)
})
} }
/** @returns {P<ObjectReferenceEntity>} */ /** @returns {P<ObjectReferenceEntity>} */
@@ -84,30 +91,34 @@ export default class ObjectReferenceEntity extends IEntity {
'"(' + Grammar.Regex.InsideString.source + "?)" '"(' + Grammar.Regex.InsideString.source + "?)"
+ "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"` + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"`
) )
).map(([full, type, path]) => new this(type, path, full)) ).map(([_0, type, path]) => new this(type, path, (t, p) => `"${t}${p ? `'${p}'` : ""}"`))
} }
/** @returns {P<ObjectReferenceEntity>} */ /** @returns {P<ObjectReferenceEntity>} */
static createTypeReferenceGrammar() { static createTypeReferenceGrammar() {
return this.typeReference.map(v => new this(v, "", v)) return this.typeReference.map(v => new this(v, "", (t, p) => t))
} }
static createNoneInstance() { static createNoneInstance() {
return new ObjectReferenceEntity("None", "", "None") return new this("None")
} }
getName(dropCounter = false) { getName(dropCounter = false) {
return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter) if (!this.#name) {
if (!dropCounter) {
return this.#name = Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter)
}
return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter)
}
return this.#name
} }
doSerialize(insideString = false) { doSerialize(insideString = false) {
let result = this.full(this.type, this.path)
if (insideString) { if (insideString) {
if (this.#fullEscaped === undefined) { result = Utility.escapeString(result, false)
this.#fullEscaped = Utility.escapeString(this.#full, false)
}
return this.#fullEscaped
} }
return this.full return result
} }
/** @param {IEntity} other */ /** @param {IEntity} other */
@@ -117,4 +128,8 @@ export default class ObjectReferenceEntity extends IEntity {
} }
return this.type == other.type && this.path == other.path return this.type == other.type && this.path == other.path
} }
toString() {
return this.full(this.type, this.path)
}
} }

View File

@@ -34,6 +34,8 @@ import Vector2DEntity from "./Vector2DEntity.js"
import Vector4DEntity from "./Vector4DEntity.js" import Vector4DEntity from "./Vector4DEntity.js"
import VectorEntity from "./VectorEntity.js" import VectorEntity from "./VectorEntity.js"
const paths = Configuration.paths
/** @template {IEntity} T */ /** @template {IEntity} T */
export default class PinEntity extends IEntity { export default class PinEntity extends IEntity {
@@ -43,27 +45,30 @@ export default class PinEntity extends IEntity {
"byte": ByteEntity, "byte": ByteEntity,
"enum": EnumEntity, "enum": EnumEntity,
"exec": StringEntity, "exec": StringEntity,
"float": NumberEntity,
"int": IntegerEntity, "int": IntegerEntity,
"int64": Integer64Entity, "int64": Integer64Entity,
"name": StringEntity, "name": StringEntity,
"real": NumberEntity, "real": NumberEntity,
"string": StringEntity, "string": StringEntity,
[Configuration.paths.linearColor]: LinearColorEntity, [paths.linearColor]: LinearColorEntity,
[Configuration.paths.niagaraPosition]: VectorEntity, [paths.niagaraBool]: BooleanEntity,
[Configuration.paths.rotator]: RotatorEntity, [paths.niagaraFloat]: NumberEntity,
[Configuration.paths.vector]: VectorEntity, [paths.niagaraPosition]: VectorEntity,
[Configuration.paths.vector2D]: Vector2DEntity, [paths.rotator]: RotatorEntity,
[Configuration.paths.vector4f]: Vector4DEntity, [paths.vector]: VectorEntity,
[paths.vector2D]: Vector2DEntity,
[paths.vector4f]: Vector4DEntity,
} }
static #alternativeTypeEntityMap = { static #alternativeTypeEntityMap = {
"enum": EnumDisplayValueEntity, "enum": EnumDisplayValueEntity,
"rg": RBSerializationVector2DEntity, "rg": RBSerializationVector2DEntity,
[Configuration.paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(), [paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(),
[Configuration.paths.rotator]: SimpleSerializationRotatorEntity, [paths.rotator]: SimpleSerializationRotatorEntity,
[Configuration.paths.vector]: SimpleSerializationVectorEntity, [paths.vector]: SimpleSerializationVectorEntity,
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity, [paths.vector2D]: SimpleSerializationVector2DEntity,
[Configuration.paths.vector3f]: SimpleSerializationVectorEntity, [paths.vector3f]: SimpleSerializationVectorEntity,
[Configuration.paths.vector4f]: SimpleSerializationVector4DEntity, [paths.vector4f]: SimpleSerializationVector4DEntity,
} }
static attributes = { static attributes = {
PinId: GuidEntity.withDefault(), PinId: GuidEntity.withDefault(),
@@ -170,9 +175,10 @@ export default class PinEntity extends IEntity {
return new PinEntity(objectEntity) return new PinEntity(objectEntity)
} }
/** @returns {String} */
getType() { getType() {
const category = this.PinType.PinCategory?.toString().toLocaleLowerCase() const category = this.PinType.PinCategory?.toString().toLocaleLowerCase()
if (category === "struct" || category === "class" || category === "object" || category === "type") { if (["struct", "class", "object", "type", "statictype"].includes(category)) {
return this.PinType.PinSubCategoryObject?.path return this.PinType.PinSubCategoryObject?.path
} }
if (this.isEnum()) { if (this.isEnum()) {
@@ -180,13 +186,9 @@ export default class PinEntity extends IEntity {
} }
if (this.objectEntity?.isPcg()) { if (this.objectEntity?.isPcg()) {
const pcgSuboject = this.objectEntity.getPcgSubobject() const pcgSuboject = this.objectEntity.getPcgSubobject()
const pinObjectReference = this.isInput() const pinObject = this.getPinObject(pcgSuboject)
? pcgSuboject.InputPins?.valueOf()[this.pinIndex] if (pinObject) {
: pcgSuboject.OutputPins?.valueOf()[this.pinIndex] let allowedTypes = pinObject["Properties"]?.AllowedTypes?.toString() ?? ""
if (pinObjectReference) {
/** @type {ObjectEntity} */
const pinObject = pcgSuboject[Configuration.subObjectAttributeNameFromReference(pinObjectReference, true)]
let allowedTypes = pinObject.Properties?.AllowedTypes?.toString() ?? ""
if (allowedTypes == "") { if (allowedTypes == "") {
allowedTypes = this.PinType.PinCategory ?? "" allowedTypes = this.PinType.PinCategory ?? ""
if (allowedTypes == "") { if (allowedTypes == "") {
@@ -195,8 +197,8 @@ export default class PinEntity extends IEntity {
} }
if (allowedTypes) { if (allowedTypes) {
if ( if (
pinObject.Properties.bAllowMultipleData?.valueOf() !== false pinObject["Properties"].bAllowMultipleData?.valueOf() !== false
&& pinObject.Properties.bAllowMultipleConnections?.valueOf() !== false && pinObject["Properties"].bAllowMultipleConnections?.valueOf() !== false
) { ) {
allowedTypes += "[]" allowedTypes += "[]"
} }
@@ -212,9 +214,9 @@ export default class PinEntity extends IEntity {
case "rg": case "rg":
return "rg" return "rg"
case "rgb": case "rgb":
return Configuration.paths.vector return paths.vector
case "rgba": case "rgba":
return Configuration.paths.linearColor return paths.linearColor
default: default:
return subCategory return subCategory
} }
@@ -250,13 +252,14 @@ export default class PinEntity extends IEntity {
isEnum() { isEnum() {
const type = this.PinType.PinSubCategoryObject?.type const type = this.PinType.PinSubCategoryObject?.type
return type === Configuration.paths.enum return type === paths.enum
|| type === Configuration.paths.userDefinedEnum || type === paths.userDefinedEnum
|| type?.toLowerCase() === "enum" || type?.toLowerCase() === "enum"
} }
isExecution() { isExecution() {
return this.PinType.PinCategory.toString() === "exec" return this.PinType.PinCategory.toString() === "exec"
|| this.getType() === paths.niagaraParameterMap
} }
isHidden() { isHidden() {
@@ -272,7 +275,7 @@ export default class PinEntity extends IEntity {
} }
isLinked() { isLinked() {
return this.LinkedTo?.length > 0 ?? false return this.LinkedTo?.length > 0
} }
/** /**
@@ -312,6 +315,17 @@ export default class PinEntity extends IEntity {
return false return false
} }
/** @param {ObjectEntity} pcgSuboject */
getPinObject(pcgSuboject) {
const pinObjectReference = this.isInput()
? pcgSuboject.InputPins?.valueOf()[this.pinIndex]
: pcgSuboject.OutputPins?.valueOf()[this.pinIndex]
if (pinObjectReference) {
/** @type {ObjectEntity} */
return pcgSuboject[Configuration.subObjectAttributeNameFromReference(pinObjectReference, true)]
}
}
getSubCategory() { getSubCategory() {
return this.PinType.PinSubCategoryObject?.path return this.PinType.PinSubCategoryObject?.path
} }

0
js/entity/RBSerializationVector2DEntity.js Normal file → Executable file
View File

0
js/entity/RotatorEntity.js Normal file → Executable file
View File

0
js/entity/ScriptVariableEntity.js Normal file → Executable file
View File

0
js/entity/SimpleSerializationRotatorEntity.js Normal file → Executable file
View File

0
js/entity/SimpleSerializationVector2DEntity.js Normal file → Executable file
View File

0
js/entity/SimpleSerializationVector4DEntity.js Normal file → Executable file
View File

0
js/entity/SimpleSerializationVectorEntity.js Normal file → Executable file
View File

0
js/entity/SymbolEntity.js Normal file → Executable file
View File

0
js/entity/TerminalTypeEntity.js Normal file → Executable file
View File

5
js/entity/UnknownKeysEntity.js Normal file → Executable file
View File

@@ -1,9 +1,14 @@
import P from "parsernostrum" import P from "parsernostrum"
import Grammar from "../serialization/Grammar.js" import Grammar from "../serialization/Grammar.js"
import GuidEntity from "./GuidEntity.js"
import IEntity from "./IEntity.js" import IEntity from "./IEntity.js"
export default class UnknownKeysEntity extends IEntity { export default class UnknownKeysEntity extends IEntity {
static attributes = {
...super.attributes,
VariableGuid: GuidEntity,
}
static grammar = this.createGrammar() static grammar = this.createGrammar()
static { static {

View File

@@ -16,7 +16,7 @@ export default class UnknownPinEntity extends PinEntity {
static createGrammar() { static createGrammar() {
return P.seq( return P.seq(
// Lookbehind // Lookbehind
P.reg(new RegExp(`(${Grammar.Regex.Symbol.source}\\s*)\\(\\s*`), 1), P.reg(new RegExp(`(${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), 1),
Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation), Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation),
P.reg(/\s*(?:,\s*)?\)/) P.reg(/\s*(?:,\s*)?\)/)
).map(([lookbehind, attributes, _2]) => { ).map(([lookbehind, attributes, _2]) => {

0
js/entity/Vector2DEntity.js Normal file → Executable file
View File

0
js/entity/Vector4DEntity.js Normal file → Executable file
View File

0
js/entity/VectorEntity.js Normal file → Executable file
View File

2
js/entity/objects/KnotEntity.js Normal file → Executable file
View File

@@ -25,7 +25,7 @@ export default class KnotEntity extends ObjectEntity {
inputPinEntity.copyTypeFrom(pinReferenceForType) inputPinEntity.copyTypeFrom(pinReferenceForType)
outputPinEntity.copyTypeFrom(pinReferenceForType) outputPinEntity.copyTypeFrom(pinReferenceForType)
} }
values["CustomProperties"] = new (ObjectEntity.attributes.CustomProperties)([inputPinEntity, outputPinEntity]) values.CustomProperties = new (ObjectEntity.attributes.CustomProperties)([inputPinEntity, outputPinEntity])
super(values) super(values)
} }
} }

View File

@@ -0,0 +1,45 @@
import Configuration from "../../Configuration.js"
import ObjectEntity from "../ObjectEntity.js"
import ObjectReferenceEntity from "../ObjectReferenceEntity.js"
import StringEntity from "../StringEntity.js"
export default class NiagaraClipboardContent extends ObjectEntity {
/**
* @param {BlueprintEntity} blueprint
* @param {ObjectEntity[]} nodes
*/
constructor(blueprint, nodes) {
const typePath = Configuration.paths.niagaraClipboardContent
const name = blueprint.takeFreeName("NiagaraClipboardContent")
const exportPath = `/Engine/Transient.${name}`
/** @type {Set<Number>} */
const variableIndexes = new Set()
let exported = ""
for (const node of nodes) {
if (node.exported) {
node.getPinEntities()
.map(pin => blueprint.variableIndex(pin.PinName.toString()))
.filter(v => v != null)
.forEach(i => variableIndexes.add(i))
exported += node.serialize()
}
}
const scriptVariables = blueprint.ScriptVariables.valueOf().filter((v, i) => variableIndexes.has(i))
const variableObjects = scriptVariables.concat(scriptVariables).map((v, i) => {
const name = Configuration.subObjectAttributeNameFromReference(
v.ScriptVariable,
i >= scriptVariables.length // First take all the small objects then all name only
)
return [name, blueprint[name]]
})
super({
Class: new ObjectReferenceEntity(typePath),
Name: new StringEntity(name),
...Object.fromEntries(variableObjects),
ExportPath: new ObjectReferenceEntity(typePath, exportPath),
ScriptVariables: new (NiagaraClipboardContent.attributes.ScriptVariables)(scriptVariables),
ExportedNodes: new StringEntity(btoa(exported))
})
}
}

0
js/input/IInput.js Normal file → Executable file
View File

0
js/input/InputCombination.js Normal file → Executable file
View File

View File

@@ -1,3 +1,4 @@
import NiagaraClipboardContent from "../../entity/objects/NiagaraClipboardContent.js"
import IInput from "../IInput.js" import IInput from "../IInput.js"
/** /**
@@ -28,20 +29,8 @@ export default class Copy extends IInput {
window.removeEventListener("copy", this.#copyHandler) window.removeEventListener("copy", this.#copyHandler)
} }
getSerializedText() {
const allNodes = this.blueprint.getNodes(true).map(n => n.entity)
const exported = allNodes.filter(n => n.exported).map(n => n.serialize())
const result = allNodes.filter(n => !n.exported).map(n => n.serialize())
if (exported.length) {
this.blueprint.entity.ExportedNodes.value = btoa(exported.join(""))
result.splice(0, 0, this.blueprint.entity.serialize(false))
delete this.blueprint.entity.ExportedNodes
}
return result.join("")
}
copied() { copied() {
const value = this.getSerializedText() const value = this.blueprint.getSerializedText()
navigator.clipboard.writeText(value) navigator.clipboard.writeText(value)
return value return value
} }

View File

@@ -33,13 +33,6 @@ export default class Cut extends IInput {
window.removeEventListener("cut", this.#cutHandler) window.removeEventListener("cut", this.#cutHandler)
} }
getSerializedText() {
return this.blueprint
.getNodes(true)
.map(node => node.entity.serialize())
.join("")
}
cut() { cut() {
this.blueprint.template.getCopyInputObject().copied() this.blueprint.template.getCopyInputObject().copied()
this.blueprint.removeGraphElement(...this.blueprint.getNodes(true)) this.blueprint.removeGraphElement(...this.blueprint.getNodes(true))

0
js/input/keyboard/KeyboardEnableZoom.js Normal file → Executable file
View File

0
js/input/keyboard/KeyboardShortcut.js Normal file → Executable file
View File

0
js/input/mouse/IMouseClickDrag.js Normal file → Executable file
View File

0
js/input/mouse/IPointing.js Normal file → Executable file
View File

0
js/input/mouse/MouseClick.js Normal file → Executable file
View File

View File

@@ -14,21 +14,15 @@ export default class MouseCreateLink extends IMouseClickDrag {
/** @type {NodeListOf<PinElement>} */ /** @type {NodeListOf<PinElement>} */
#listenedPins #listenedPins
/** @type {PinElement} */
#knotPin = null
/** @param {MouseEvent} e */ /** @param {MouseEvent} e */
#mouseenterHandler = e => { #mouseenterHandler = e => {
if (!this.enteredPin) { if (!this.enteredPin) {
this.linkValid = false this.linkValid = false
this.enteredPin = /** @type {PinElement} */(e.target) this.enteredPin = /** @type {PinElement} */(e.target)
const a = this.link.source ?? this.target // Remember target might have change const a = this.link.origin ?? this.target // Remember target might have change
const b = this.enteredPin const b = this.enteredPin
const outputPin = a.isOutput() ? a : b const outputPin = a.isOutput() ? a : b
if ( if (a.isKnot() || b.isKnot()) {
a.nodeElement.getType() === Configuration.paths.knot
|| b.nodeElement.getType() === Configuration.paths.knot
) {
// A knot can be linked to any pin, it doesn't matter the type or input/output direction // A knot can be linked to any pin, it doesn't matter the type or input/output direction
this.link.setMessageCorrect() this.link.setMessageCorrect()
this.linkValid = true this.linkValid = true
@@ -83,9 +77,6 @@ export default class MouseCreateLink extends IMouseClickDrag {
} }
startDrag(location) { startDrag(location) {
if (this.target.nodeElement.getType() == Configuration.paths.knot) {
this.#knotPin = this.target
}
/** @type {LinkElement} */ /** @type {LinkElement} */
this.link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) this.link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link"))
.newObject(this.target, null) .newObject(this.target, null)
@@ -99,11 +90,11 @@ export default class MouseCreateLink extends IMouseClickDrag {
} }
}) })
this.link.startDragging() this.link.startDragging()
this.link.setDestinationLocation(location) this.link.setTargetLocation(location)
} }
dragTo(location, movement) { dragTo(location, movement) {
this.link.setDestinationLocation(location) this.link.setTargetLocation(location)
} }
endDrag() { endDrag() {
@@ -113,28 +104,30 @@ export default class MouseCreateLink extends IMouseClickDrag {
}) })
this.#listenedPins = null this.#listenedPins = null
if (this.enteredPin && this.linkValid) { if (this.enteredPin && this.linkValid) {
const knot = this.enteredPin.isKnot()
? this.enteredPin
: this.link.origin.isKnot() ? this.link.origin : null
// Knot can use wither the input or output (by default) part indifferently, check if a switch is needed // Knot can use wither the input or output (by default) part indifferently, check if a switch is needed
if (this.#knotPin) { if (knot) {
const otherPin = this.#knotPin !== this.link.source ? this.link.source : this.enteredPin const otherPin = knot !== this.link.origin ? this.link.origin : this.enteredPin
// Knot pin direction correction // Knot pin direction correction
if (this.#knotPin.isInput() && otherPin.isInput() || this.#knotPin.isOutput() && otherPin.isOutput()) { if (knot.isInput() && otherPin.isInput() || knot.isOutput() && otherPin.isOutput()) {
const oppositePin = /** @type {KnotPinTemplate} */(this.#knotPin.template).getOppositePin() const oppositePin = /** @type {KnotPinTemplate} */(knot.template).getoppositePin()
if (this.#knotPin === this.link.source) { if (knot === this.link.origin) {
this.link.source = oppositePin this.link.origin = oppositePin
} else { } else {
this.enteredPin = oppositePin this.enteredPin = oppositePin
} }
} }
} else if (this.enteredPin.nodeElement.getType() === Configuration.paths.knot) { } else if (this.enteredPin.isKnot()) {
this.#knotPin = this.enteredPin if (this.link.origin.isOutput()) {
if (this.link.source.isOutput()) { // Knot uses by default the output pin, let's switch to keep it coherent with the origin node we have
// Knot uses by default the output pin, let's switch to keep it coherent with the source node we have this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getoppositePin()
this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getOppositePin()
} }
} }
if (!this.link.source.getLinks().find(ref => ref.equals(this.enteredPin.createPinReference()))) { if (!this.link.origin.getLinks().find(ref => ref.equals(this.enteredPin.createPinReference()))) {
this.blueprint.addGraphElement(this.link) this.blueprint.addGraphElement(this.link)
this.link.destination = this.enteredPin this.link.target = this.enteredPin
} else { } else {
this.link.remove() this.link.remove()
} }

Some files were not shown because too many files have changed in this diff Show More