From 5c76efb8c07feba69479f6e7068a8ffd741c8b23 Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sat, 26 Aug 2023 13:49:00 +0200 Subject: [PATCH] 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 --- .../BuilderModes/ClassicModes/LinedefsMode.cs | 18 ++++++++--------- .../BuilderModes/ClassicModes/SectorsMode.cs | 18 ++++++++--------- .../BuilderModes/ClassicModes/ThingsMode.cs | 17 ++++++++-------- .../BuilderModes/ClassicModes/VerticesMode.cs | 20 +++++++++---------- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 09e5e875b..4bd62bd5e 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -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; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 227ae03a9..7deb7b6dd 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -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; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 5fb00a5fd..7724f7611 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -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; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 2accf6b91..b25ae893f 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -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; } -- GitLab