From bc315e2d3788f1486a6fd6b010551ece8ed59973 Mon Sep 17 00:00:00 2001 From: MatCat Date: Mon, 8 Mar 2021 20:04:38 -0800 Subject: [PATCH] WIP:0.4-ms Multiselect seems to be working well now --- js/logicengine.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/logicengine.js b/js/logicengine.js index 363f2f9..dad6f2b 100644 --- a/js/logicengine.js +++ b/js/logicengine.js @@ -63,9 +63,10 @@ class LogicEngine { } PropertyChange(property) { - if (!this.ActiveContainer.Selected.getProperty(property)) return false; + if (this.ActiveContainer.Selected.length > 1) return false; + if (!this.ActiveContainer.Selected[0].getProperty(property)) return false; let propElement = document.getElementById("prop_" + property); - this.ActiveContainer.Selected.getProperty(property).Call(propElement.value); + this.ActiveContainer.Selected[0].getProperty(property).Call(propElement.value); } Mouse_Down(evt) { @@ -75,7 +76,12 @@ class LogicEngine { let element = this.ActiveContainer.checkMouseBounds(mousePos); if (element) { this.MouseDown = true; - if (this.ActiveContainer.Selected.length <= 1) this.ActiveContainer.Select(element); + + if (this.ActiveContainer.isSelected(element)) { + + } else { + this.ActiveContainer.Select(element); + } this.MovingElement = new Array(this.ActiveContainer.Selected.length); for (let a = 0; a < this.ActiveContainer.Selected.length; a++) { @@ -106,7 +112,7 @@ class LogicEngine { PropertiesBox.style.display = "none"; } } - if (this.ActiveContainer.Selected) { + if (this.ActiveContainer.Selected?.length > 0) { disableSelectedRCMs(false); } else { disableSelectedRCMs(true); @@ -145,7 +151,7 @@ class LogicEngine { this.ActiveContainer.SelectWithin(cmStartPos.x,cmStartPos.y,cmEndPos.x,cmEndPos.y); } - if (this.ActiveContainer.Selected) { + if (this.ActiveContainer.Selected?.length > 0) { disableSelectedRCMs(false); } else { disableSelectedRCMs(true); @@ -217,7 +223,7 @@ class LogicEngine { } } if (evt.key == "Delete") { - if (this.ActiveContainer.Selected) { + if (this.ActiveContainer.Selected?.length > 0) { this.ActiveContainer.DeleteElement(this.ActiveContainer.Selected); this.ActiveContainer.Selected = false; let PropertiesBox = document.getElementById("PropertiesBox"); @@ -262,7 +268,7 @@ class LogicEngine { Link(input = 0) { if (this.ActiveLink) { - if (this.ActiveContainer.Selected && (this.ActiveContainer.Selected != this.ActiveLink)) { + if ((this.ActiveContainer.Selected?.length == 1) && (this.ActiveContainer.Selected?.[0] != this.ActiveLink)) { this.ActiveLink.addConnection(this.ActiveContainer,this.ActiveContainer.Selected[0],input,this.ActiveLink.OutputLink.Output); this.ActiveLink = false; } else { @@ -356,6 +362,6 @@ class LogicEngine { StartEngine() { this.Resize(""); - this.DrawLoop(); + this.DrawLoop(); // Get the animation loop going } }