0.3.9: Grid alignment positioning and bug fix on label loading
This commit is contained in:
parent
999e0b0c1f
commit
f8e08bd2ca
@ -12,6 +12,11 @@ To be decided, but at this moment this code is open source and free to use for n
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.3.9
|
||||
|
||||
* Added grid alignment, hold CTRL key while moving to get pixel level positioning.
|
||||
* Fixed property restoration issue with labels on loading a save
|
||||
|
||||
### 0.3.8
|
||||
|
||||
* Added labels! You can specify the text, size, and color
|
||||
|
@ -415,8 +415,11 @@ class LabelElement extends Element {
|
||||
|
||||
if (RestoreData) {
|
||||
this.Label = RestoreData.Properties[0].CurrentValue;
|
||||
this.Properties[0].CurrentValue = this.Label;
|
||||
this.Font = RestoreData.Properties[1].CurrentValue + "px Console";
|
||||
this.Properties[1].CurrentValue = RestoreData.Properties[1].CurrentValue;
|
||||
this.FontStyle = RestoreData.Properties[2].CurrentValue;
|
||||
this.Properties[2].CurrentValue = this.FontStyle;
|
||||
}
|
||||
|
||||
let textWidth = this.textSize(logicengine.Ctx,this.Label,this.Font);
|
||||
|
@ -4,6 +4,8 @@ function addElement(RestoreData = null,refClass,props) {
|
||||
if (!RestoreData) {
|
||||
let x = Math.round(logicEngine.Canvas.width / 2);
|
||||
let y = Math.round(logicEngine.Canvas.height / 2);
|
||||
x = 20 * Math.round(x/20);
|
||||
y = 20 * Math.round(y/20);
|
||||
let width = newElement.Width;
|
||||
let height = newElement.Height;
|
||||
|
||||
@ -18,6 +20,9 @@ function addElement(RestoreData = null,refClass,props) {
|
||||
if (y < 0) y = 0;
|
||||
if (x + width > logicEngine.Canvas.width) x = logicEngine.Canvas.width - width;
|
||||
if (y + height > logicEngine.Canvas.height) y = logicEngine.Canvas.height - height;
|
||||
x = 20 * Math.round(x/20);
|
||||
y = 20 * Math.round(y/20);
|
||||
|
||||
}
|
||||
}
|
||||
newElement.X = x;
|
||||
|
@ -95,8 +95,12 @@ class LogicEngine {
|
||||
let yOffset = mousePos.y - this.MovingElementMouseStartY;
|
||||
let diffxOffset = this.MovingElementMouseStartX - this.MovingElementStartX;
|
||||
let diffyOffset = this.MovingElementMouseStartY - this.MovingElementStartY;
|
||||
this.MovingElement.X = (this.MovingElementMouseStartX + xOffset) - diffxOffset;
|
||||
this.MovingElement.Y = (this.MovingElementMouseStartY + yOffset) - diffyOffset;
|
||||
let actualPosX = (this.MovingElementMouseStartX + xOffset) - diffxOffset;
|
||||
let actualPosY = (this.MovingElementMouseStartY + yOffset) - diffyOffset;
|
||||
if (!this.ControlPressed) actualPosX = Math.round(actualPosX/20)*20;
|
||||
if (!this.ControlPressed) actualPosY = Math.round(actualPosY/20)*20;
|
||||
this.MovingElement.X = actualPosX;
|
||||
this.MovingElement.Y = actualPosY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -104,7 +108,18 @@ class LogicEngine {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Key_Up(evt) {
|
||||
if (!evt.ctrlKey) {
|
||||
this.ControlPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
Key_Press(evt) {
|
||||
if (evt.ctrlKey) {
|
||||
this.ControlPressed = true;
|
||||
}
|
||||
|
||||
if (evt.key == "Escape") {
|
||||
if (this.MovingElement && this.MouseDown) {
|
||||
this.MovingElement.X = this.MovingElementStartX;
|
||||
@ -145,6 +160,7 @@ class LogicEngine {
|
||||
this.RecursionCount = 0;
|
||||
this.RecursionError = false;
|
||||
this.Canvas.setAttribute('tabindex','0');
|
||||
this.ControlPressed = false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
MatCat BrowserLogic Simulator
|
||||
*/
|
||||
|
||||
let Version = "0.3.8";
|
||||
let Version = "0.3.9";
|
||||
let spanVersion = document.getElementById("version");
|
||||
spanVersion.innerText = Version;
|
||||
// get the canvas and get the engine object going
|
||||
@ -21,6 +21,11 @@ window.addEventListener('keydown', function(evt) {
|
||||
logicEngine.Key_Press(evt);
|
||||
}, false);
|
||||
|
||||
window.addEventListener('keyup', function(evt) {
|
||||
logicEngine.Key_Up(evt);
|
||||
}, false);
|
||||
|
||||
|
||||
lCanvasElement.addEventListener('mousedown', function(evt) {
|
||||
logicEngine.Mouse_Down(evt);
|
||||
}, false);
|
||||
|
Loading…
Reference in New Issue
Block a user