Fixed a problem where not selected geometry and things could not be dragged when the "don't move selection if any part of it is outside of map boundary" option was enabled

This commit is contained in:
biwa 2023-08-26 13:49:00 +02:00
parent 1fca52ef08
commit 5c76efb8c0
4 changed files with 37 additions and 36 deletions

View file

@ -1078,19 +1078,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(draglines)) //mxd
General.Editing.ChangeMode(new DragLinedefsMode(mousedownmappos, draglines));
}
}
}
//mxd. Check if any selected linedef is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Linedef> draglines)
{
ICollection<Linedef> selectedlines = General.Map.Map.GetSelectedLinedefs(true);
int unaffectedCount = 0;
foreach(Linedef l in selectedlines)
foreach(Linedef l in draglines)
{
// Make sure the linedef is inside the map boundary
if(l.Start.Position.x < General.Map.Config.LeftBoundary || l.Start.Position.x > General.Map.Config.RightBoundary
@ -1098,21 +1097,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|| l.End.Position.x < General.Map.Config.LeftBoundary || l.End.Position.x > General.Map.Config.RightBoundary
|| l.End.Position.y > General.Map.Config.TopBoundary || l.End.Position.y < General.Map.Config.BottomBoundary)
{
l.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedlines.Count)
if (unaffectedCount == draglines.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedlines.Count == 1 ? "selected linedef is" : "all of selected linedefs are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (draglines.Count == 1 ? "selected linedef is" : "all of selected linedefs are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if(unaffectedCount > 0)
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected linedefs " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}

View file

@ -1333,19 +1333,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragsectors)) //mxd
General.Editing.ChangeMode(new DragSectorsMode(mousedownmappos, dragsectors));
}
}
}
//mxd. Check if any selected sector is outside of map boundary
private bool CanDrag()
private bool CanDrag(ICollection<Sector> dragsectors)
{
ICollection<Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);
int unaffectedCount = 0;
foreach(Sector s in selectedsectors)
foreach(Sector s in dragsectors)
{
// Make sure the sector is inside the map boundary
foreach(Sidedef sd in s.Sidedefs)
@ -1355,24 +1354,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
|| sd.Line.End.Position.x < General.Map.Config.LeftBoundary || sd.Line.End.Position.x > General.Map.Config.RightBoundary
|| sd.Line.End.Position.y > General.Map.Config.TopBoundary || sd.Line.End.Position.y < General.Map.Config.BottomBoundary)
{
SelectSector(s, false, false);
unaffectedCount++;
break;
}
}
}
if(unaffectedCount == selectedsectors.Count)
if (unaffectedCount == dragsectors.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedsectors.Count == 1 ? "selected sector is" : "all of selected sectors are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragsectors.Count == 1 ? "selected sector is" : "all of selected sectors are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if(unaffectedCount > 0)
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected sectors " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
UpdateSelectedLabels(); //mxd
return true;
}

View file

@ -758,7 +758,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragthings)) //mxd
{
// Shift pressed? Clone things!
bool thingscloned = false;
@ -819,31 +819,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd. Check if any selected thing is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Thing> dragthings)
{
ICollection<Thing> selectedthings = General.Map.Map.GetSelectedThings(true);
int unaffectedCount = 0;
foreach(Thing t in selectedthings)
foreach(Thing t in dragthings)
{
// Make sure the vertex is inside the map boundary
if(t.Position.x < General.Map.Config.LeftBoundary || t.Position.x > General.Map.Config.RightBoundary
|| t.Position.y > General.Map.Config.TopBoundary || t.Position.y < General.Map.Config.BottomBoundary)
{
t.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedthings.Count)
if (unaffectedCount == dragthings.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedthings.Count == 1 ? "selected thing is" : "all of selected things are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragthings.Count == 1 ? "selected thing is" : "all of selected things are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if(unaffectedCount > 0)
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected vertices " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}

View file

@ -653,39 +653,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragvertices)) //mxd
General.Editing.ChangeMode(new DragVerticesMode(mousedownmappos, dragvertices));
}
}
}
//mxd. Check if any selected vertex is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Vertex> dragvertices)
{
ICollection<Vertex> selectedverts = General.Map.Map.GetSelectedVertices(true);
int unaffectedCount = 0;
foreach(Vertex v in selectedverts)
foreach(Vertex v in dragvertices)
{
// Make sure the vertex is inside the map boundary
if(v.Position.x < General.Map.Config.LeftBoundary || v.Position.x > General.Map.Config.RightBoundary
|| v.Position.y > General.Map.Config.TopBoundary || v.Position.y < General.Map.Config.BottomBoundary)
{
v.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedverts.Count)
if (unaffectedCount == dragvertices.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedverts.Count == 1 ? "selected vertex is" : "all of selected vertices are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragvertices.Count == 1 ? "selected vertex is" : "all of selected vertices are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if(unaffectedCount > 0)
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected vertices " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}