Skip to content

Commit

Permalink
Fix - wall > selected (door type) should no longer create invisible w…
Browse files Browse the repository at this point in the history
…alls when used across more than 1 line segment.
  • Loading branch information
Azmoria committed Oct 22, 2023
1 parent 518dc2a commit d65d364
Showing 1 changed file with 97 additions and 47 deletions.
144 changes: 97 additions & 47 deletions Fog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,8 @@ function drawing_mouseup(e) {
rw: width,
rh: height
};

let intersectingWalls = [];
let wallLine = [];

for(let i=0; i<walls.length; i++){

Expand Down Expand Up @@ -2424,7 +2425,15 @@ function drawing_mouseup(e) {
break;
}
}

if(!fullyInside){
intersectingWalls.push({
wallLine: wallLine[0],
left: left,
right: right,
top: top,
bottom: bottom
});
let x1;
let x2;
let y1;
Expand Down Expand Up @@ -2523,54 +2532,95 @@ function drawing_mouseup(e) {
];
window.DRAWINGS.push(data);
}
}

}
}

if(window.DRAWFUNCTION == 'wall-door-convert'){
x1 = undefined;

if(bottom != false){
x1 = bottom.x;
y1 = bottom.y;
}
if(left != false){
if(x1 == undefined){
x1 = left.x;
y1 = left.y;
}
else{
x2 = left.x;
y2 = left.y;
}
}
if(right != false){
if(x1 == undefined){
x1 = right.x;
y1 = right.y;
}
else{
x2 = right.x;
y2 = right.y;
}
}
if(top != false){
x2 = top.x;
y2 = top.y;
}

let data = ['line',
'wall',
window.DRAWCOLOR,
x1,
y1,
x2,
y2,
12,
window.CURRENT_SCENE_DATA.scale_factor*window.CURRENT_SCENE_DATA.conversion
];
window.DRAWINGS.push(data);

}
}
}


if(intersectingWalls.length>0 && window.DRAWFUNCTION == 'wall-door-convert'){
let wallLine = [intersectingWalls[0]]
let x1;
let x2;
let y1;
let y2;
let bottom = intersectingWalls[0].bottom;
let top = intersectingWalls[0].top;
let left = intersectingWalls[0].left;
let right = intersectingWalls[0].right;

for(let i = 0; i < intersectingWalls.length; i++){
wallLine[0].bottom.x = (wallLine[0].bottom.x < intersectingWalls[i].bottom.x) ? intersectingWalls[i].bottom.x : wallLine[0].bottom.x;
wallLine[0].bottom.y = (wallLine[0].bottom.y < intersectingWalls[i].bottom.y) ? intersectingWalls[i].bottom.y : wallLine[0].bottom.y;

wallLine[0].top.x = (wallLine[0].top.x > intersectingWalls[i].top.x) ? intersectingWalls[i].top.x : wallLine[0].top.x;
wallLine[0].top.y = (wallLine[0].top.y > intersectingWalls[i].top.y) ? intersectingWalls[i].top.y : wallLine[0].top.y;

wallLine[0].left.x = (wallLine[0].left.x > intersectingWalls[i].left.x) ? intersectingWalls[i].left.x : wallLine[0].left.x;
wallLine[0].left.y = (wallLine[0].left.y > intersectingWalls[i].left.y) ? intersectingWalls[i].left.y : wallLine[0].left.y;

wallLine[0].right.x = (wallLine[0].right.x < intersectingWalls[i].right.x) ? intersectingWalls[i].right.x : wallLine[0].right.x;
wallLine[0].right.y = (wallLine[0].right.y < intersectingWalls[i].right.y) ? intersectingWalls[i].right.y : wallLine[0].right.y;

bottom = (intersectingWalls[i].bottom != false) ? intersectingWalls[i].bottom : bottom;
top = (intersectingWalls[i].top != false) ? intersectingWalls[i].top : top;
left = (intersectingWalls[i].left != false) ? intersectingWalls[i].left : left;
right = (intersectingWalls[i].right != false) ? intersectingWalls[i].right : right;

}

if(bottom != false){
x1 = bottom.x;
y1 = bottom.y;
}
if(left != false){
if(x1 == undefined){
x1 = left.x;
y1 = left.y;
}
else{
x2 = left.x;
y2 = left.y;
}
}
if(right != false){
if(x1 == undefined){
x1 = right.x;
y1 = right.y;
}
else{
x2 = right.x;
y2 = right.y;
}
}
if(top != false){
if(x1 == undefined){
x1 = top.x;
y1 = top.y;
x2 = top.x;
y2 = top.y;
}
else{
x2 = top.x;
y2 = top.y;
}

}

let data = ['line',
'wall',
window.DRAWCOLOR,
x1,
y1,
x2,
y2,
12,
window.CURRENT_SCENE_DATA.scale_factor*window.CURRENT_SCENE_DATA.conversion
];
window.DRAWINGS.push(data);

}


Expand Down

0 comments on commit d65d364

Please sign in to comment.