diff --git a/js/baseclasses.js b/js/baseclasses.js index 83679d7..0a0a910 100644 --- a/js/baseclasses.js +++ b/js/baseclasses.js @@ -77,9 +77,11 @@ class elementContainer { this.Selected = false; this.Inputs = new Array(); this.Outputs = new Array(); + this.StaticImages = {}; this.ICOutputs = 0; } + isSelected(element) { if (this.Selected) { for (let a = 0; a < this.Selected.length; a++) { diff --git a/js/elements.js b/js/elements.js index 60d0066..5e9644c 100644 --- a/js/elements.js +++ b/js/elements.js @@ -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+5,y+5,50,50,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()) { 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"); @@ -1390,7 +1395,6 @@ class InputSwitch extends inputElement { 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+(this.Height-14),this.Width-(this.outputCircleRadius*2),12,this.Designator,"12px Console","#000"); this.drawOutputs(ctx,x,y); } } diff --git a/js/globalfunctions.js b/js/globalfunctions.js index 426e5e7..77bdc7e 100644 --- a/js/globalfunctions.js +++ b/js/globalfunctions.js @@ -12,7 +12,9 @@ function addElement(RestoreData = null,refClass,props) { let height = newElement.Height; let noclearspot = true; - while (noclearspot) { + let findattempt = 0; + while (noclearspot && findattempt < 100) { + findattempt++; if (!logicEngine.ActiveContainer.checkOverlayBounds(x, y, width, height)) { noclearspot = false; } else { @@ -24,7 +26,6 @@ function addElement(RestoreData = null,refClass,props) { if (y + height > logicEngine.Canvas.height) y = logicEngine.Canvas.height - height; x = logicEngine.Settings.GridSize * Math.round(x/logicEngine.Settings.GridSize); y = logicEngine.Settings.GridSize * Math.round(y/logicEngine.Settings.GridSize); - } } newElement.X = x;