Fixed hang bug when visible work area got full of elements and a new one was attempted to be placed
This commit is contained in:
parent
bdd630e8d5
commit
1ccb5968e0
@ -77,9 +77,11 @@ class elementContainer {
|
|||||||
this.Selected = false;
|
this.Selected = false;
|
||||||
this.Inputs = new Array();
|
this.Inputs = new Array();
|
||||||
this.Outputs = new Array();
|
this.Outputs = new Array();
|
||||||
|
this.StaticImages = {};
|
||||||
this.ICOutputs = 0;
|
this.ICOutputs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
isSelected(element) {
|
isSelected(element) {
|
||||||
if (this.Selected) {
|
if (this.Selected) {
|
||||||
for (let a = 0; a < this.Selected.length; a++) {
|
for (let a = 0; a < this.Selected.length; a++) {
|
||||||
|
|||||||
@ -1379,10 +1379,15 @@ class InputSwitch extends inputElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drawElement(x, y, ctx) {
|
drawStatic(x, y, ctx) {
|
||||||
this.drawBorderBox(ctx, x,y,this.Width-20,this.Height,1,"#000","#f7e979",this.LogicEngine.Settings.ShadowColor);
|
this.drawBorderBox(ctx, x,y,this.Width-20,this.Height,1,"#000","#f7e979",this.LogicEngine.Settings.ShadowColor);
|
||||||
//this.drawBorderBox(ctx,x+5,y+5,50,50,1,"#ccc","#777");
|
//this.drawBorderBox(ctx,x+5,y+5,50,50,1,"#ccc","#777");
|
||||||
this.drawBorderBox(ctx,x+5,y+25,50,10,1,"#ccc","#777");
|
this.drawBorderBox(ctx,x+5,y+25,50,10,1,"#ccc","#777");
|
||||||
|
this.drawTextCentered(ctx,x,y+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000");
|
||||||
|
}
|
||||||
|
|
||||||
|
drawElement(x, y, ctx) {
|
||||||
|
this.drawStatic(x, y, ctx);
|
||||||
if (this.getOutput()) {
|
if (this.getOutput()) {
|
||||||
this.drawBorderBox(ctx,x+15,y+5,30,25,1,"#ccc","#777");
|
this.drawBorderBox(ctx,x+15,y+5,30,25,1,"#ccc","#777");
|
||||||
this.drawTextCentered(ctx,x,y+this.Height - 30,this.Width-(this.outputCircleRadius*2)-20,12,"OFF","12px Console","#000");
|
this.drawTextCentered(ctx,x,y+this.Height - 30,this.Width-(this.outputCircleRadius*2)-20,12,"OFF","12px Console","#000");
|
||||||
@ -1390,7 +1395,6 @@ class InputSwitch extends inputElement {
|
|||||||
this.drawBorderBox(ctx,x+15,y+30,30,25,1,"#ccc","#777");
|
this.drawBorderBox(ctx,x+15,y+30,30,25,1,"#ccc","#777");
|
||||||
this.drawTextCentered(ctx,x,y+7,this.Width-(this.outputCircleRadius*2)-20,12,"ON","12px Console","#000");
|
this.drawTextCentered(ctx,x,y+7,this.Width-(this.outputCircleRadius*2)-20,12,"ON","12px Console","#000");
|
||||||
}
|
}
|
||||||
this.drawTextCentered(ctx,x,y+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000");
|
|
||||||
this.drawOutputs(ctx,x,y);
|
this.drawOutputs(ctx,x,y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,9 @@ function addElement(RestoreData = null,refClass,props) {
|
|||||||
let height = newElement.Height;
|
let height = newElement.Height;
|
||||||
|
|
||||||
let noclearspot = true;
|
let noclearspot = true;
|
||||||
while (noclearspot) {
|
let findattempt = 0;
|
||||||
|
while (noclearspot && findattempt < 100) {
|
||||||
|
findattempt++;
|
||||||
if (!logicEngine.ActiveContainer.checkOverlayBounds(x, y, width, height)) {
|
if (!logicEngine.ActiveContainer.checkOverlayBounds(x, y, width, height)) {
|
||||||
noclearspot = false;
|
noclearspot = false;
|
||||||
} else {
|
} else {
|
||||||
@ -24,7 +26,6 @@ function addElement(RestoreData = null,refClass,props) {
|
|||||||
if (y + height > logicEngine.Canvas.height) y = logicEngine.Canvas.height - height;
|
if (y + height > logicEngine.Canvas.height) y = logicEngine.Canvas.height - height;
|
||||||
x = logicEngine.Settings.GridSize * Math.round(x/logicEngine.Settings.GridSize);
|
x = logicEngine.Settings.GridSize * Math.round(x/logicEngine.Settings.GridSize);
|
||||||
y = logicEngine.Settings.GridSize * Math.round(y/logicEngine.Settings.GridSize);
|
y = logicEngine.Settings.GridSize * Math.round(y/logicEngine.Settings.GridSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newElement.X = x;
|
newElement.X = x;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user