Fix incompatible nodes types

This commit is contained in:
barsdeveloper
2023-05-20 19:51:44 +02:00
parent 9add38e914
commit 32cc4d7c66
6 changed files with 49 additions and 15 deletions

29
dist/ueblueprint.js vendored
View File

@@ -965,7 +965,7 @@ class Utility {
static formatStringName(value = "") { static formatStringName(value = "") {
return value return value
// Remove leading b (for boolean values) or newlines // Remove leading b (for boolean values) or newlines
.replace(/^\s*b/, "") .replace(/^\s*b(?=[A-Z])/, "")
// Insert a space where needed, possibly removing unnecessary elading characters // Insert a space where needed, possibly removing unnecessary elading characters
.replaceAll(Configuration.nameRegexSpaceReplacement, " ") .replaceAll(Configuration.nameRegexSpaceReplacement, " ")
.trim() .trim()
@@ -2595,6 +2595,15 @@ class SVGIcon {
</svg> </svg>
` `
static convert = x`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path fill="#3e7fbc" d="M 4 0 H 16 V 32 H 4 L 0 28 V 4 Z" />
<path fill="#bdd6ef" d="M 2 8 H 14 V 30 H 4 L 2 28 Z" />
<path fill="#bc3e4a" d="M 16 0 H 28 L 32 4 V 28 L 28 32 H 16 Z" />
<path fill="#efbdc1" d="M 18 8 H 30 V 27 L 27 30 H 18 Z" />
</svg>
`
static correct = x` static correct = x`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"> <svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path fill="#2da800" d="M 2 16 L 14 30 L 30 2 L 13 22 Z" /> <path fill="#2da800" d="M 2 16 L 14 30 L 30 2 L 13 22 Z" />
@@ -7045,8 +7054,8 @@ class LinkElement extends IFromToPositionedElement {
} }
setMessageConvertType() { setMessageConvertType() {
this.linkMessageIcon = "ueb-icon-conver-type"; this.linkMessageIcon = SVGIcon.convert;
this.linkMessageText = `Convert ${this.source.pinType} to ${this.destination.pinType}.`; this.linkMessageText = x`Convert ${this.source.pinType} to ${this.destination.pinType}.`;
} }
setMessageCorrect() { setMessageCorrect() {
@@ -7065,7 +7074,7 @@ class LinkElement extends IFromToPositionedElement {
} }
setMessagePlaceNode() { setMessagePlaceNode() {
this.linkMessageIcon = "ueb-icon-place-node"; this.linkMessageIcon = A;
this.linkMessageText = x`Place a new node.`; this.linkMessageText = x`Place a new node.`;
} }
@@ -7084,9 +7093,14 @@ class LinkElement extends IFromToPositionedElement {
this.linkMessageText = x`Both are on the same node.`; this.linkMessageText = x`Both are on the same node.`;
} }
setMEssagetypesIncompatible() { /**
* @param {PinElement} a
* @param {PinElement} b
*/
setMessageTypesIncompatible(a, b) {
this.linkMessageIcon = SVGIcon.reject; this.linkMessageIcon = SVGIcon.reject;
this.linkMessageText = x`${this.source.pinType} is not compatible with ${this.destination.pinType}.`; this.linkMessageText =
x`${Utility.capitalFirstLetter(a.pinType)} is not compatible with ${Utility.capitalFirstLetter(b.pinType)}.`;
} }
} }
@@ -7872,6 +7886,9 @@ class MouseCreateLink extends IMouseClickDrag {
} else if (outputPin.entity.getType() === "exec" && outputPin.isLinked) { } else if (outputPin.entity.getType() === "exec" && outputPin.isLinked) {
this.link.setMessageReplaceOutputLink(); this.link.setMessageReplaceOutputLink();
this.linkValid = true; this.linkValid = true;
} else if (a.pinType != b.pinType) {
this.link.setMessageTypesIncompatible(a, b);
this.linkValid = false;
} else { } else {
this.link.setMessageCorrect(); this.link.setMessageCorrect();
this.linkValid = true; this.linkValid = true;

File diff suppressed because one or more lines are too long

View File

@@ -51,6 +51,15 @@ export default class SVGIcon {
</svg> </svg>
` `
static convert = html`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path fill="#3e7fbc" d="M 4 0 H 16 V 32 H 4 L 0 28 V 4 Z" />
<path fill="#bdd6ef" d="M 2 8 H 14 V 30 H 4 L 2 28 Z" />
<path fill="#bc3e4a" d="M 16 0 H 28 L 32 4 V 28 L 28 32 H 16 Z" />
<path fill="#efbdc1" d="M 18 8 H 30 V 27 L 27 30 H 18 Z" />
</svg>
`
static correct = html` static correct = html`
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"> <svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path fill="#2da800" d="M 2 16 L 14 30 L 30 2 L 13 22 Z" /> <path fill="#2da800" d="M 2 16 L 14 30 L 30 2 L 13 22 Z" />

View File

@@ -379,7 +379,7 @@ export default class Utility {
static formatStringName(value = "") { static formatStringName(value = "") {
return value return value
// Remove leading b (for boolean values) or newlines // Remove leading b (for boolean values) or newlines
.replace(/^\s*b/, "") .replace(/^\s*b(?=[A-Z])/, "")
// Insert a space where needed, possibly removing unnecessary elading characters // Insert a space where needed, possibly removing unnecessary elading characters
.replaceAll(Configuration.nameRegexSpaceReplacement, " ") .replaceAll(Configuration.nameRegexSpaceReplacement, " ")
.trim() .trim()

View File

@@ -255,8 +255,8 @@ export default class LinkElement extends IFromToPositionedElement {
} }
setMessageConvertType() { setMessageConvertType() {
this.linkMessageIcon = "ueb-icon-conver-type" this.linkMessageIcon = SVGIcon.convert
this.linkMessageText = `Convert ${this.source.pinType} to ${this.destination.pinType}.` this.linkMessageText = html`Convert ${this.source.pinType} to ${this.destination.pinType}.`
} }
setMessageCorrect() { setMessageCorrect() {
@@ -275,7 +275,7 @@ export default class LinkElement extends IFromToPositionedElement {
} }
setMessagePlaceNode() { setMessagePlaceNode() {
this.linkMessageIcon = "ueb-icon-place-node" this.linkMessageIcon = nothing
this.linkMessageText = html`Place a new node.` this.linkMessageText = html`Place a new node.`
} }
@@ -294,8 +294,13 @@ export default class LinkElement extends IFromToPositionedElement {
this.linkMessageText = html`Both are on the same node.` this.linkMessageText = html`Both are on the same node.`
} }
setMEssagetypesIncompatible() { /**
* @param {PinElement} a
* @param {PinElement} b
*/
setMessageTypesIncompatible(a, b) {
this.linkMessageIcon = SVGIcon.reject this.linkMessageIcon = SVGIcon.reject
this.linkMessageText = html`${this.source.pinType} is not compatible with ${this.destination.pinType}.` this.linkMessageText =
html`${Utility.capitalFirstLetter(a.pinType)} is not compatible with ${Utility.capitalFirstLetter(b.pinType)}.`
} }
} }

View File

@@ -44,6 +44,9 @@ export default class MouseCreateLink extends IMouseClickDrag {
} else if (outputPin.entity.getType() === "exec" && outputPin.isLinked) { } else if (outputPin.entity.getType() === "exec" && outputPin.isLinked) {
this.link.setMessageReplaceOutputLink() this.link.setMessageReplaceOutputLink()
this.linkValid = true this.linkValid = true
} else if (a.pinType != b.pinType) {
this.link.setMessageTypesIncompatible(a, b)
this.linkValid = false
} else { } else {
this.link.setMessageCorrect() this.link.setMessageCorrect()
this.linkValid = true this.linkValid = true