New icons and types

This commit is contained in:
barsdeveloper
2022-11-16 23:01:57 +01:00
parent 704049c869
commit 8e2f44bd0d
22 changed files with 324 additions and 111 deletions

View File

@@ -51,9 +51,14 @@ export default class Configuration {
static nodeRadius = 8 // in pixel
static nodeReflowEventName = "ueb-node-reflow"
static nodeType = {
function: "/Script/BlueprintGraph.K2Node_CallFunction",
forEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",
forLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoop",
callFunction: "/Script/BlueprintGraph.K2Node_CallFunction",
ifThenElse: "/Script/BlueprintGraph.K2Node_IfThenElse",
knot: "/Script/BlueprintGraph.K2Node_Knot",
macro: "/Script/BlueprintGraph.K2Node_MacroInstance",
reverseForEachLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",
whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop",
}
static pinColor = {
"/Script/CoreUObject.LinearColor": css`3, 76, 168`,
@@ -68,6 +73,7 @@ export default class Configuration {
"name": css`203, 129, 252`,
"real": css`50, 187, 0`,
"string": css`213, 0, 176`,
"wildcard": css`128, 120, 120`
}
static selectAllKeyboardKey = "(bCtrl=True,Key=A)"
static distanceThreshold = 5 // in pixel

View File

@@ -2,6 +2,15 @@ import { html } from "lit"
export default class SVGIcon {
static branchNode = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 2H6C5.44772 2 5 2.44772 5 3V13C5 13.5523 5.44772 14 6 14H11V12H7V4H11V2Z" fill="white" />
<rect x="1" y="7" width="4" height="2" fill="white" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 6L15 3L11 0V6Z" fill="white" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M11 16L15 13L11 10V16Z" fill="white" />
</svg>
`
static close = html`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<line x1="2" y1="2" x2="30" y2="30" stroke="currentColor" stroke-width="4" />
@@ -16,21 +25,31 @@ export default class SVGIcon {
`
static execPin = html`
<svg viewBox="-2 0 16 16" class="ueb-pin-icon ueb-pin-icon-exec" xmlns="http://www.w3.org/2000/svg">
<svg viewBox="-2 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path class="ueb-pin-tofill" stroke-width="1.25" stroke="white" fill="none"
d="M 2 1 a 2 2 0 0 0 -2 2 v 10 a 2 2 0 0 0 2 2 h 4 a 2 2 0 0 0 1.519 -0.698 l 4.843 -5.651 a 1 1 0 0 0 0 -1.302 L 7.52 1.7 a 2 2 0 0 0 -1.519 -0.698 z" />
</svg>
`
static expandIcon = html`
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="ueb-node-expansion-icon" viewBox="4 4 24 24">
<svg fill="currentColor" viewBox="4 4 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="M 16.003 18.626 l 7.081 -7.081 L 25 13.46 l -8.997 8.998 -9.003 -9 1.917 -1.916 z" />
</svg>
`
static forEachLoop = html`
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 2C1.8 2 0 3.8 0 6V9C0 11.2 2 13 4 13H10V11H5C3.2 11 2 9.7 2 8V7C2 5.63882 2.76933 4.53408 4 4.14779V2ZM12 4C13.8 4 14 5.3 14 7V8C14 8.8 13.7 9.5 13.3 10L15.2 11.4C15.7 10.7 16 9.9 16 9V6C16 3.8 14.2 2 12 2V4Z" fill="white" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 16L13 12L8 8V16Z" fill="white" />
<rect x="5" y="1" width="1" height="4" fill="white" />
<rect x="7" y="1" width="1" height="4" fill="white" />
<rect x="9" y="1" width="1" height="4" fill="white" />
<rect x="11" y="2" width="1" height="2" fill="white" />
</svg>
`
static functionSymbol = html`
<svg width="16" height="16" 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">
<path
d="M9.72002 6.0699C9.88111 4.96527 10.299 3.9138 10.94 2.99991C10.94 2.99991 10.94 3.05991 10.94 3.08991C10.94 3.36573 11.0496 3.63026 11.2446 3.8253C11.4397 4.02033 11.7042 4.12991 11.98 4.12991C12.2558 4.12991 12.5204 4.02033 12.7154 3.8253C12.9105 3.63026 13.02 3.36573 13.02 3.08991C13.0204 2.90249 12.9681 2.71873 12.8691 2.5596C12.7701 2.40047 12.6283 2.27237 12.46 2.18991H12.37C11.8725 2.00961 11.3275 2.00961 10.83 2.18991C9.21002 2.63991 8.58002 4.99991 8.58002 4.99991L8.40002 5.1199H5.40002L5.15002 6.1199H8.27002L7.27002 11.4199C7.11348 12.0161 6.79062 12.5555 6.33911 12.9751C5.8876 13.3948 5.32607 13.6773 4.72002 13.7899C4.78153 13.655 4.81227 13.5081 4.81002 13.3599C4.81002 13.0735 4.69624 12.7988 4.4937 12.5962C4.29116 12.3937 4.01646 12.2799 3.73002 12.2799C3.44359 12.2799 3.16889 12.3937 2.96635 12.5962C2.76381 12.7988 2.65002 13.0735 2.65002 13.3599C2.66114 13.605 2.75692 13.8386 2.92104 14.021C3.08517 14.2033 3.30746 14.3231 3.55002 14.3599C7.91002 15.1999 8.55002 11.4499 8.55002 11.4499L9.55002 7.05991H12.55L12.8 6.05991H9.64002L9.72002 6.0699Z"
fill="currentColor"
@@ -39,14 +58,43 @@ export default class SVGIcon {
`
static genericPin = html`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" class="ueb-pin-icon">
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<circle class="ueb-pin-tofill" cx="16" cy="16" r="14" fill="none" stroke="currentColor" stroke-width="5" />
<path d="M 34 6 L 34 26 L 42 16 Z" fill="currentColor" />
</svg>
`
static loopNode = html`
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<defs>
<style>
.cls-1 {
fill: #fff;
fill-rule: evenodd;
}
.cls-2 {
fill: none;
}
</style>
</defs>
<g id="Layer_2" data-name="Layer 2">
<g id="Layer_4" data-name="Layer 4">
<path class="cls-1" d="M16,2H4A4,4,0,0,0,0,6v4a4.14,4.14,0,0,0,4,4H9v5l8-6L9,7v5H4.5A2.36,2.36,0,0,1,2,9.5v-3A2.36,2.36,0,0,1,4.5,4h11A2.36,2.36,0,0,1,18,6.5V9a3,3,0,0,1-.69,2l1.88,1.41A4,4,0,0,0,20,10V6A4,4,0,0,0,16,2Z" />
<rect class="cls-2" width="20" height="20" />
</g>
</g>
</svg>
`
static macro = html`
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8 2.92L10 12.29L14.55 2.61C14.662 2.4259 14.8189 2.27332 15.0061 2.16661C15.1933 2.05989 15.4045 2.00256 15.62 2H19L18.66 2.89C18.66 2.89 17.17 3.04 17.11 3.63C17.05 4.22 16 15.34 15.93 16.13C15.86 16.92 17.33 17.13 17.33 17.13L17.17 17.99H13.84C13.7241 17.9764 13.612 17.9399 13.5103 17.8826C13.4086 17.8253 13.3194 17.7484 13.2477 17.6562C13.176 17.5641 13.1234 17.4586 13.0929 17.346C13.0624 17.2333 13.0546 17.1157 13.07 17L14.43 5.52L10 14.57C9.8 15.03 9.07 15.72 8.63 15.71H7.75L6.05 4.86L3.54 17.39C3.51941 17.5514 3.44327 17.7005 3.32465 17.8118C3.20603 17.9232 3.05235 17.9897 2.89 18H1L1.11 17.09C1.11 17.09 2.21 17.09 2.3 16.69C2.39 16.29 5.3 3.76 5.41 3.32C5.52 2.88 4.19 2.81 4.19 2.81L4.46 2H6.62C7.09 2 7.92 2.38 8 2.92Z" fill="white"/>
</svg>
`
static referencePin = html`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" class="ueb-pin-icon">
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<polygon class="ueb-pin-tofill" points="4 16 16 4 28 16 16 28" stroke="currentColor" stroke-width="5" />
</svg>
`

View File

@@ -81,7 +81,7 @@ export default class NodeElement extends ISelectableDraggableElement {
constructor(entity, template = undefined) {
super(entity, template ?? new (NodeElement.getTypeTemplate(entity))())
this.#pins = this.template.createPinElements()
this.nodeClass = this.entity.getClass()
this.nodeClass = this.entity.getType()
this.name = this.entity.getObjectName()
this.advancedPinDisplay = this.entity.AdvancedPinDisplay?.toString()
this.enabledState = this.entity.EnabledState

View File

@@ -164,10 +164,7 @@ export default class PinElement extends IElement {
}
getColor() {
if (!this.pinType) {
return Configuration.pinColor["default"]
}
return Configuration.pinColor[this.pinType]
return Configuration.pinColor[this.pinType] ?? Configuration.pinColor["default"]
}
isInput() {

View File

@@ -3,7 +3,7 @@ import IEntity from "./IEntity"
export default class IntegerEntity extends IEntity {
static attributes = {
value: Number,
value: 0,
}
/** @param {Object | Number | String} options */

View File

@@ -61,7 +61,7 @@ export default class ObjectEntity extends IEntity {
getType() {
let classValue = this.getClass()
if (classValue === Configuration.nodeType.macro) {
return this.MacroGraphReference.GraphBlueprint.path
return this.MacroGraphReference.MacroGraph.path
}
return classValue
}
@@ -92,15 +92,25 @@ export default class ObjectEntity extends IEntity {
getDisplayName() {
let name = ""
switch (this.getClass()) {
case Configuration.nodeType.function:
switch (this.getType()) {
case Configuration.nodeType.callFunction:
name = this.FunctionReference.MemberName
break
case Configuration.nodeType.macro:
name = this.MacroGraphReference.getMacroName()
case Configuration.nodeType.ifThenElse:
name = "Branch"
break
case Configuration.nodeType.forEachLoop:
name = "For Each Loop with Break"
break
case Configuration.nodeType.reverseForEachLoop:
name = "Reverse for Each Loop"
break
default:
name = this.getNameAndCounter()[0]
if (this.getClass() === Configuration.nodeType.macro) {
name = this.MacroGraphReference.getMacroName()
} else {
name = this.getNameAndCounter()[0]
}
break
}
return Utility.formatStringName(name)

View File

@@ -22,6 +22,7 @@ export default class IKeyboardShortcut extends IInput {
constructor(target, blueprint, options = {}) {
options.activateAnyKey ??= false
options.activationKeys ??= []
options.consumeEvent ??= true
options.listenOnFocus ??= true
options.unlistenOnTextEdit ??= true // No shortcuts when inside of a text field
if (!(options.activationKeys instanceof Array)) {
@@ -62,6 +63,7 @@ export default class IKeyboardShortcut extends IInput {
)
) {
if (options.consumeEvent) {
e.preventDefault()
e.stopImmediatePropagation()
}
self.fire()

View File

@@ -1,4 +1,5 @@
import { html } from "lit"
import IntegerEntity from "../entity/IntegerEntity"
import INumericPinTemplate from "./INumericPinTemplate"
/** @typedef {import("../entity/IntegerEntity").default} IntEntity */
@@ -7,13 +8,13 @@ import INumericPinTemplate from "./INumericPinTemplate"
export default class IntPinTemplate extends INumericPinTemplate {
setDefaultValue(values = [], rawValues = values) {
this.element.setDefaultValue(values[0])
this.element.setDefaultValue(new IntegerEntity(values[0]))
}
renderInput() {
return html`
<div class="ueb-pin-input">
<ueb-input .singleLine="${true}" .innerText="${this.element.entity.DefaultValue.toString()}">
<ueb-input .singleLine="${true}" .innerText="${this.element.entity.DefaultValue?.toString() ?? "0"}">
</ueb-input>
</div>
`

View File

@@ -1,13 +1,13 @@
import { html } from "lit"
import Utility from "../Utility"
import PinTemplate from "./PinTemplate"
import Utility from "../Utility"
/** @typedef {import("./KnotNodeTemplate").default} KnotNodeTemplate */
export default class KnotPinTemplate extends PinTemplate {
render() {
return this.element.isOutput() ? this.renderIcon() : html``
return this.element.isOutput() ? html`<div class="ueb-pin-icon">${this.renderIcon()}</div>` : html``
}
getLinkLocation() {

View File

@@ -22,7 +22,8 @@ export default class LinearColorPinTemplate extends PinTemplate {
#launchColorPickerWindow =
/** @param {MouseEvent} e */
e => {
//e.preventDefault()
e.preventDefault()
this.element.blueprint.setFocused(true)
this.#window = /** @type {WindowElement} */ (
new (ElementFactory.getConstructor("ueb-window"))({
type: ColorPickerWindowTemplate,

View File

@@ -162,7 +162,7 @@ export default class LinkTemplate extends IFromToPositionedTemplate {
<use href="#${uniqueId}" pointer-events="stroke" stroke-width="20" />
</g>
</svg>
${this.element.linkMessageIcon != "" || this.element.linkMessageText != "" ? html`
${this.element.linkMessageIcon || this.element.linkMessageText ? html`
<div class="ueb-link-message">
<span class="ueb-link-message-icon">${this.element.linkMessageIcon}</span>
<span class="ueb-link-message-text">${this.element.linkMessageText}</span>

View File

@@ -1,4 +1,5 @@
import { html, nothing } from "lit"
import Configuration from "../Configuration"
import ElementFactory from "../element/ElementFactory"
import ISelectableDraggableTemplate from "./ISelectableDraggableTemplate"
import SVGIcon from "../SVGIcon"
@@ -11,6 +12,15 @@ import SVGIcon from "../SVGIcon"
/** @extends {ISelectableDraggableTemplate<NodeElement>} */
export default class NodeTemplate extends ISelectableDraggableTemplate {
static #nodeIcon = {
[Configuration.nodeType.callFunction]: SVGIcon.functionSymbol,
[Configuration.nodeType.forEachLoop]: SVGIcon.forEachLoop,
[Configuration.nodeType.forLoop]: SVGIcon.loopNode,
[Configuration.nodeType.ifThenElse]: SVGIcon.branchNode,
[Configuration.nodeType.whileLoop]: SVGIcon.loopNode,
default: SVGIcon.functionSymbol
}
toggleAdvancedDisplayHandler = () => {
this.element.toggleShowAdvancedPinDisplay()
this.element.addNextUpdatedCallbacks(() => this.element.dispatchReflowEvent(), true)
@@ -27,7 +37,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
<div class="ueb-node-wrapper">
<div class="ueb-node-top">
<div class="ueb-node-name">
<span class="ueb-node-name-symbol">${SVGIcon.functionSymbol}</span>
<span class="ueb-node-name-symbol">${this.renderNodeIcon()}</span>
<span class="ueb-node-name-text ueb-ellipsis-nowrap-text">
${this.renderNodeName()}
</span>
@@ -52,6 +62,17 @@ export default class NodeTemplate extends ISelectableDraggableTemplate {
`
}
renderNodeIcon() {
let icon = NodeTemplate.#nodeIcon[this.element.getType()]
if (icon) {
return icon
}
if (this.element.entity.getClass() === Configuration.nodeType.macro) {
return SVGIcon.macro
}
return NodeTemplate.#nodeIcon.default
}
renderNodeName() {
return this.element.getNodeDisplayName()
}

View File

@@ -38,7 +38,7 @@ export default class PinTemplate extends ITemplate {
}
render() {
const icon = this.renderIcon()
const icon = html`<div class="ueb-pin-icon">${this.renderIcon()}</div>`
const content = html`
<div class="ueb-pin-content">
${this.renderName()}