WIP: Copy/paste locationing
This commit is contained in:
parent
50320ff533
commit
187664e36a
@ -365,6 +365,11 @@ function loadActiveContainer(Elements) {
|
||||
let elementConnections = new Array();
|
||||
let icelementConnections = new Array();
|
||||
let designatorMap = new Array();
|
||||
let selectedObjects = new Array();
|
||||
let lowestX = 9999999999;
|
||||
let lowestY = 9999999999;
|
||||
let highestX = 0;
|
||||
let highestY = 0;
|
||||
|
||||
for (let a = 0; a < Elements.length; a++) {
|
||||
if (Elements[a].IsIC) {
|
||||
@ -379,10 +384,17 @@ function loadActiveContainer(Elements) {
|
||||
let classRef = getElementInfo(Elements[a].Name).Class;
|
||||
|
||||
let newElement = new classRef(logicEngine.ActiveContainer,Elements[a],logicEngine,getElementInfo(Elements[a].Name).Args[0]);
|
||||
if (newElement) selectedObjects.push(newElement);
|
||||
|
||||
logicEngine.ActiveContainer.AddElement(newElement);
|
||||
newElement.X -= logicEngine.Panning.OffsetX;
|
||||
newElement.Y -= logicEngine.Panning.OffsetY;
|
||||
|
||||
if (newElement.X < lowestX) lowestX = newElement.X;
|
||||
if (newElement.X > highestX) highestX = newElement.X;
|
||||
if (newElement.Y < lowestY) lowestY = newElement.Y;
|
||||
if (newElement.Y > highestY) highestY = newElement.Y;
|
||||
|
||||
designatorMap.push({Old: Elements[a].Designator, New: newElement.Designator});
|
||||
|
||||
if (Elements[a].Outputs) {
|
||||
@ -412,6 +424,23 @@ function loadActiveContainer(Elements) {
|
||||
}
|
||||
}
|
||||
|
||||
logicEngine.ActiveContainer.Selected = selectedObjects;
|
||||
logicEngine.MovingElement = new Array(logicEngine.ActiveContainer.Selected.length);
|
||||
|
||||
for (let b = 0; b < logicEngine.ActiveContainer.Selected.length; b++) {
|
||||
//logicEngine.ActiveContainer.Selected[b].X = (logicEngine.ActiveContainer.Selected[b].X - ((highestX-lowestX)/2)) + logicEngine.Mouse.x;
|
||||
logicEngine.ActiveContainer.Selected[b].X = (logicEngine.ActiveContainer.Selected[b].X - lowestX) + logicEngine.Mouse.x - ((highestX-lowestX)/2);
|
||||
//logicEngine.ActiveContainer.Selected[b].Y = (logicEngine.ActiveContainer.Selected[b].Y - ((highestY-lowestY)/2)) + logicEngine.Mouse.y;
|
||||
logicEngine.ActiveContainer.Selected[b].Y = (logicEngine.ActiveContainer.Selected[b].Y - lowestY) + logicEngine.Mouse.y - ((highestY-lowestY)/2);
|
||||
logicEngine.MovingElement[b] = {
|
||||
StartX: logicEngine.ActiveContainer.Selected[b].X,
|
||||
StartY: logicEngine.ActiveContainer.Selected[b].Y
|
||||
};
|
||||
logicEngine.MovingElementMouseStartX = logicEngine.Mouse.x;
|
||||
logicEngine.MovingElementMouseStartY = logicEngine.Mouse.y;
|
||||
}
|
||||
logicEngine.MouseDown = true;
|
||||
|
||||
for (let a = 0; a < elementConnections.length; a++) {
|
||||
let toElement = logicEngine.ActiveContainer.HasElement(getPastedElementDesignator(designatorMap,elementConnections[a].ToElement));
|
||||
if (toElement) {
|
||||
|
Loading…
Reference in New Issue
Block a user