Make undo/redo less unstable by handling flat alignment changes differently.

This commit is contained in:
sphere 2021-10-31 14:46:00 +01:00
parent 65f1577fec
commit 676223929f
2 changed files with 52 additions and 47 deletions

View file

@ -700,15 +700,26 @@ namespace CodeImp.DoomBuilder.Editing
u = null;
levelsundone++;
}
General.Map.Map.EndAddRemove();
if((levels > 1) && showmessage)
General.Interface.DisplayStatus(StatusType.Action, "Undone " + levelsundone + " changes.");
// (Re)set hacky flat alignment
if (General.Map.SRB2)
{
foreach (Sector s in General.Map.Map.Sectors)
if (s.Marked || linedeftags.Contains(s.Tag))
{
s.UpdateFloorSurface();
s.UpdateCeilingSurface();
}
}
// Remove selection
General.Map.Map.ClearAllSelected();
// Update map
General.Map.Map.Update();
foreach(Thing t in General.Map.Map.Things) if(t.Marked) t.UpdateConfiguration();
@ -717,21 +728,6 @@ namespace CodeImp.DoomBuilder.Editing
General.MainWindow.RefreshInfo();
//General.MainWindow.RedrawDisplay();
// (Re)set hacky flat alignment
foreach (Linedef l in General.Map.Map.Linedefs)
if (l.Marked && (l.IsFlatAlignment || l.Action == 0))
{
l.Front.Sector.UpdateFloorSurface();
l.Front.Sector.UpdateCeilingSurface();
linedeftags.Add(l.Tag);
}
foreach (Sector s in General.Map.Map.Sectors)
if (linedeftags.Contains(s.Tag) || s.Marked)
{
s.UpdateFloorSurface();
s.UpdateCeilingSurface();
}
// Map changed!
General.Map.IsChanged = true;
@ -740,15 +736,15 @@ namespace CodeImp.DoomBuilder.Editing
General.Plugins.OnUndoEnd();
// Update interface
General.MainWindow.RedrawDisplay(); //mxd
General.Editing.Mode.UpdateSelectionInfo(); //mxd
General.MainWindow.RedrawDisplay(); //mxd
dobackgroundwork = true;
General.MainWindow.UpdateInterface();
}
}
}
}
Cursor.Current = oldcursor;
}
@ -859,12 +855,23 @@ namespace CodeImp.DoomBuilder.Editing
r = null;
levelsundone++;
}
General.Map.Map.EndAddRemove();
if(levels > 1)
General.Interface.DisplayStatus(StatusType.Action, "Redone " + levelsundone + " changes.");
// (Re)set hacky flat alignment
if (General.Map.SRB2)
{
foreach (Sector s in General.Map.Map.Sectors)
if (s.Marked || linedeftags.Contains(s.Tag))
{
s.UpdateFloorSurface();
s.UpdateCeilingSurface();
}
}
// Remove selection
General.Map.Map.ClearAllSelected();
@ -876,21 +883,6 @@ namespace CodeImp.DoomBuilder.Editing
General.MainWindow.RefreshInfo();
//General.MainWindow.RedrawDisplay();
// (Re)set hacky flat alignment
foreach (Linedef l in General.Map.Map.Linedefs)
if (l.Marked && (l.IsFlatAlignment || l.Action == 0))
{
l.Front.Sector.UpdateFloorSurface();
l.Front.Sector.UpdateCeilingSurface();
linedeftags.Add(l.Tag);
}
foreach (Sector s in General.Map.Map.Sectors)
if (linedeftags.Contains(s.Tag) || s.Marked)
{
s.UpdateFloorSurface();
s.UpdateCeilingSurface();
}
// Map changed!
General.Map.IsChanged = true;
@ -899,15 +891,15 @@ namespace CodeImp.DoomBuilder.Editing
General.Plugins.OnRedoEnd();
// Update interface
General.MainWindow.RedrawDisplay(); //mxd
General.Editing.Mode.UpdateSelectionInfo(); //mxd
General.MainWindow.RedrawDisplay(); //mxd
dobackgroundwork = true;
General.MainWindow.UpdateInterface();
}
}
}
}
Cursor.Current = oldcursor;
}
@ -930,7 +922,11 @@ namespace CodeImp.DoomBuilder.Editing
int index; ds.rInt(out index);
//LogRecordInfo("PLY: Removing vertex " + index);
Vertex v = General.Map.Map.GetVertexByIndex(index);
foreach(Linedef l in v.Linedefs) l.Marked = true;
foreach (Linedef l in v.Linedefs)
{
l.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
}
v.Dispose();
geometrychanged = true;
}
@ -996,6 +992,7 @@ namespace CodeImp.DoomBuilder.Editing
Linedef l = General.Map.Map.GetLinedefByIndex(index);
if(l.Front != null) l.Front.Marked = true;
if(l.Back != null) l.Back.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
l.Dispose();
geometrychanged = true;
}
@ -1024,6 +1021,7 @@ namespace CodeImp.DoomBuilder.Editing
Linedef l = General.Map.Map.CreateLinedef(index, vs, ve);
l.ReadWrite(ds);
l.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
geometrychanged = true;
}
@ -1043,7 +1041,7 @@ namespace CodeImp.DoomBuilder.Editing
{
int index; ds.rInt(out index);
Linedef l = General.Map.Map.GetLinedefByIndex(index);
linedeftags.Add(l.Tag);
if (l.Tag != 0 ) linedeftags.Add(l.Tag);
l.ReadWrite(ds);
l.Marked = true;
}
@ -1068,7 +1066,8 @@ namespace CodeImp.DoomBuilder.Editing
Vertex v = (vindex >= 0) ? General.Map.Map.GetVertexByIndex(vindex) : null;
l.SetStartVertex(v);
l.Marked = true;
if(v != null) v.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
if (v != null) v.Marked = true;
geometrychanged = true;
}
@ -1092,7 +1091,8 @@ namespace CodeImp.DoomBuilder.Editing
Vertex v = (vindex >= 0) ? General.Map.Map.GetVertexByIndex(vindex) : null;
l.SetEndVertex(v);
l.Marked = true;
if(v != null) v.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
if (v != null) v.Marked = true;
geometrychanged = true;
}
@ -1116,7 +1116,8 @@ namespace CodeImp.DoomBuilder.Editing
Sidedef sd = (sindex >= 0) ? General.Map.Map.GetSidedefByIndex(sindex) : null;
l.AttachFront(sd);
l.Marked = true;
if(sd != null) sd.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
if (sd != null) sd.Marked = true;
geometrychanged = true;
}
@ -1140,7 +1141,8 @@ namespace CodeImp.DoomBuilder.Editing
Sidedef sd = (sindex >= 0) ? General.Map.Map.GetSidedefByIndex(sindex) : null;
l.AttachBack(sd);
l.Marked = true;
if(sd != null) sd.Marked = true;
if (l.Tag != 0) linedeftags.Add(l.Tag);
if (sd != null) sd.Marked = true;
geometrychanged = true;
}

View file

@ -498,8 +498,11 @@ namespace CodeImp.DoomBuilder.Windows
s.UpdateCeilingSurface();
}
}
l.Front.Sector.UpdateFloorSurface();
l.Front.Sector.UpdateCeilingSurface();
if (l.Front.Sector != null)
{
l.Front.Sector.UpdateFloorSurface();
l.Front.Sector.UpdateCeilingSurface();
}
}
// Update the used textures