Fixed a regression where editing map elements did not preserve the selection order, but used the index order instead. Fixes #791

This commit is contained in:
biwa 2022-09-20 23:52:41 +02:00
parent e7ccffa498
commit fa5c741b76
8 changed files with 51 additions and 52 deletions

View file

@ -57,7 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Disposer
// Constructor to start dragging immediately
public DragLinedefsMode(Vector2D dragstartmappos, List<Linedef> lines)
public DragLinedefsMode(Vector2D dragstartmappos, ICollection<Linedef> lines)
{
// Mark what we are dragging
General.Map.Map.ClearAllMarks(false);

View file

@ -57,7 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Disposer
// Constructor to start dragging immediately
public DragSectorsMode(Vector2D dragstartmappos, List<Sector> sectors)
public DragSectorsMode(Vector2D dragstartmappos, ICollection<Sector> sectors)
{
// Mark what we are dragging
General.Map.Map.ClearAllMarks(false);

View file

@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Disposer
// Constructor to start dragging immediately
public DragThingsMode(EditMode basemode, Vector2D dragstartmappos, List<Thing> things, bool makeundo)
public DragThingsMode(EditMode basemode, Vector2D dragstartmappos, ICollection<Thing> things, bool makeundo)
{
// Initialize
this.dragstartmappos = dragstartmappos;

View file

@ -59,7 +59,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Disposer
// Constructor to start dragging immediately
public DragVerticesMode(Vector2D dragstartmappos, List<Vertex> vertices)
public DragVerticesMode(Vector2D dragstartmappos, ICollection<Vertex> vertices)
{
// Mark what we are dragging
General.Map.Map.ClearAllMarks(false);

View file

@ -71,6 +71,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Stores sizes of the text for text labels so that they only have to be computed once
private Dictionary<string, float> textlabelsizecache;
// Linedefs that will be edited
ICollection<Linedef> editlines;
#endregion
#region ================== Properties
@ -777,21 +780,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode
editpressed = true;
// We use the marks to determine what to edit/drag, so clear it first
General.Map.Map.ClearMarkedLinedefs(false);
// Highlighted item not selected?
if(!highlighted.Selected)
{
// Make this the only selection
General.Map.Map.ClearSelectedLinedefs();
highlighted.Marked = true;
editlines = new List<Linedef> { highlighted };
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
}
else
{
General.Map.Map.MarkSelectedLinedefs(true, true);
editlines = General.Map.Map.GetSelectedLinedefs(true);
}
// Update display
@ -828,10 +830,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode?
if(editpressed)
{
// Anything selected?
ICollection<Linedef> editlines = General.Map.Map.GetMarkedLinedefs(true);
if(editlines.Count > 0)
if(editlines?.Count > 0)
{
if(General.Interface.IsActiveWindow)
{
@ -1063,19 +1062,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Anything highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
List<Linedef> draglines = new List<Linedef>();
ICollection<Linedef> draglines;
// Highlighted item not selected?
if(!highlighted.Selected)
{
// Select only this linedef for dragging
General.Map.Map.ClearSelectedLinedefs();
draglines.Add(highlighted);
draglines = new List<Linedef> { highlighted };
}
else
{
// Add all selected linedefs to the linedefs we want to drag
draglines.AddRange(General.Map.Map.GetSelectedLinedefs(true));
draglines = General.Map.Map.GetSelectedLinedefs(true);
}
// Start dragging the selection

View file

@ -83,6 +83,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
private ConcurrentDictionary<Thing, bool> determinedsectorthings;
// Sectors that will be edited
private ICollection<Sector> editsectors;
#endregion
#region ================== Properties
@ -1056,24 +1059,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode
editpressed = true;
// We use the marks to determine what to edit/drag, so clear it first
General.Map.Map.ClearMarkedSectors(false);
// Highlighted item not selected?
if (!highlighted.Selected)
{
// Make this the only selection
General.Map.Map.ClearSelectedSectors();
General.Map.Map.ClearSelectedLinedefs();
highlighted.Marked = true;
editsectors = new List<Sector> { highlighted };
UpdateSelectedLabels(); //mxd
UpdateOverlaySurfaces(); //mxd
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
}
else
else // Highlight is selected, so take all selected sectors
{
General.Map.Map.MarkSelectedSectors(true, true);
editsectors = General.Map.Map.GetSelectedSectors(true);
}
// Update display
@ -1108,10 +1110,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode?
if(editpressed)
{
// Anything selected?
ICollection<Sector> editsectors = General.Map.Map.GetMarkedSectors(true);
if(editsectors.Count > 0)
if(editsectors?.Count > 0)
{
if(General.Interface.IsActiveWindow)
{
@ -1315,19 +1314,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Anything highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
List<Sector> dragsectors = new List<Sector>();
ICollection<Sector> dragsectors;
// Highlighted item not selected?
if (!highlighted.Selected)
{
// Select only this sector for dragging
General.Map.Map.ClearSelectedSectors();
dragsectors.Add(highlighted);
dragsectors = new List<Sector> { highlighted };
UpdateOverlaySurfaces(); //mxd
}
else
{
dragsectors.AddRange(General.Map.Map.GetSelectedSectors(true));
dragsectors = General.Map.Map.GetSelectedSectors(true);
}
// Start dragging the selection

View file

@ -76,6 +76,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Stores sizes of the text for text labels so that they only have to be computed once
private Dictionary<string, float> textlabelsizecache;
// Things that will be edited
private ICollection<Thing> editthings;
#endregion
#region ================== Properties
@ -484,21 +487,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode
editpressed = true;
// We use the marks to determine what do edit/drag, so clear it first
General.Map.Map.ClearMarkedThings(false);
// Highlighted item not selected?
if(!highlighted.Selected)
{
// Make this the only selection
General.Map.Map.ClearSelectedThings();
highlighted.Marked = true;
editthings = new List<Thing> { highlighted };
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
}
else
{
General.Map.Map.MarkSelectedThings(true, true);
editthings = General.Map.Map.GetSelectedThings(true);
}
// Update display
@ -528,7 +530,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
General.Map.Map.ClearSelectedThings();
General.Map.Map.ClearMarkedThings(false);
t.Marked = true;
editthings = new List<Thing> { t };
Highlight(t);
General.Interface.RedrawDisplay();
}
@ -543,10 +545,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode?
if(editpressed)
{
// Anything selected?
ICollection<Thing> editthings = General.Map.Map.GetMarkedThings(true);
if(editthings.Count > 0)
if(editthings?.Count > 0)
{
if(General.Interface.IsActiveWindow)
{
@ -743,19 +742,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Anything highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
List<Thing> dragthings = new List<Thing>();
ICollection<Thing> dragthings;
// Highlighted item not selected?
if(!highlighted.Selected)
{
// Select only this thing for dragging
General.Map.Map.ClearSelectedThings();
dragthings.Add(highlighted);
dragthings = new List<Thing> { highlighted };
}
else
{
// Add all selected things to the things we want to drag
dragthings.AddRange(General.Map.Map.GetSelectedThings(true));
dragthings = General.Map.Map.GetSelectedThings(true);
}
// Start dragging the selection
@ -765,7 +764,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
bool thingscloned = false;
if(General.Interface.ShiftState)
{
List<Thing> clonedthings = new List<Thing>(dragthings.Count);
ICollection<Thing> clonedthings = new List<Thing>(dragthings.Count);
if(dragthings.Count > 0)
{
// Make undo

View file

@ -59,6 +59,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The blockmap makes is used to make finding lines faster
BlockMap<BlockEntry> blockmap;
// Vertices that will be edited
ICollection<Vertex> editvertices;
#endregion
#region ================== Properties
@ -294,13 +297,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Make this the only selection
General.Map.Map.ClearSelectedVertices();
highlighted.Marked = true;
editvertices = new List<Vertex> { highlighted };
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
}
else
{
General.Map.Map.MarkSelectedVertices(true, true);
editvertices = General.Map.Map.GetSelectedVertices(true);
}
// Update display
@ -400,10 +405,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit pressed in this mode?
if(editpressed)
{
// Anything selected?
ICollection<Vertex> editvertices = General.Map.Map.GetMarkedVertices(true);
if(editvertices.Count > 0)
if(editvertices?.Count > 0)
{
if(General.Interface.IsActiveWindow)
{
@ -635,19 +637,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Anything highlighted?
if((highlighted != null) && !highlighted.IsDisposed)
{
List<Vertex> dragvertices = new List<Vertex>();
ICollection<Vertex> dragvertices;
// Highlighted item not selected?
if(!highlighted.Selected)
{
// Select only this vertex for dragging
General.Map.Map.ClearSelectedVertices();
dragvertices.Add(highlighted);
dragvertices = new List<Vertex> { highlighted };
}
else
{
// Add all selected vertices to the vertices we want to drag
dragvertices.AddRange(General.Map.Map.GetSelectedVertices(true));
dragvertices = General.Map.Map.GetSelectedVertices(true);
}
// Start dragging the selection