Sector/Linedef/Thing/Vertex Edit Form: the map will not be marked as changed anymore when canceling changes made in the forms, when the map wasn't marked as changed before

Copying map elements doesn't mark the map as changed anymore if the map wasn't marked as changed before copying
This commit is contained in:
biwa 2021-04-01 23:31:52 +02:00
parent c748209eba
commit 95f5c719b7
9 changed files with 106 additions and 9 deletions

View file

@ -238,6 +238,8 @@ namespace CodeImp.DoomBuilder.Editing
// that need to be copied.
if(General.Editing.Mode.OnCopyBegin())
{
bool oldmapischanged = General.Map.IsChanged;
General.MainWindow.DisplayStatus(StatusType.Action, desc);
// Copy the marked geometry
@ -269,6 +271,12 @@ namespace CodeImp.DoomBuilder.Editing
return false;
}
// General.Map.Map.CloneMarked will set General.Map.IsChanged to true, since it recreated the map. But since this
// creation happens in another MapSet, the currently opened map is actually not changed. Force the IsChanged property
// to false if the map wasn't changed before doing the copying
if (oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
// Done
memstream.Dispose();
General.Editing.Mode.OnCopyEnd();

View file

@ -2708,6 +2708,17 @@ namespace CodeImp.DoomBuilder
renderer2d.GridVisibilityChanged();
}
/// <summary>
/// This forces the "changed" variable to "false", which is normally not possible when setting the "IsChanged" property.
/// USE WITH CARE! This should only be used in very specific circumstances, where the "IsChanged" property is set to true
/// because of internal behavior
/// </summary>
internal void ForceMapIsChangedFalse()
{
changed = false;
General.MainWindow.UpdateMapChangedStatus();
}
#endregion
}
}

View file

@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.Windows
private List<LinedefProperties> linedefprops; //mxd
private bool preventchanges;
private bool undocreated; //mxd
private bool oldmapischanged;
private struct LinedefProperties //mxd
{
@ -151,6 +152,7 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Linedef> lines)
{
preventchanges = true;
oldmapischanged = General.Map.IsChanged;
argscontrol.Reset();
undocreated = false;
@ -464,7 +466,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the linedef, like textures will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// Be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.Windows
private readonly List<int> keynumbers; //mxd
private readonly List<PairedFieldsControl> frontUdmfControls; //mxd
private readonly List<PairedFieldsControl> backUdmfControls; //mxd
private bool oldmapischanged;
private struct LinedefProperties //mxd
{
@ -259,6 +260,7 @@ namespace CodeImp.DoomBuilder.Windows
}
preventchanges = true;
oldmapischanged = General.Map.IsChanged;
undocreated = false;
argscontrol.Reset();
tagsselector.Reset();
@ -768,7 +770,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the linedef, like textures will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// Be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -41,6 +41,7 @@ namespace CodeImp.DoomBuilder.Windows
private List<SectorProperties> sectorprops; //mxd
private bool preventchanges; //mxd
private bool undocreated; //mxd
private bool oldmapischanged;
private struct SectorProperties //mxd
{
@ -90,7 +91,8 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Sector> sectors)
{
preventchanges = true; //mxd
undocreated = false;
oldmapischanged = General.Map.IsChanged;
undocreated = false;
// Keep this list
this.sectors = sectors;
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
@ -345,7 +347,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. perform undo
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the sector, like floor/ceiling textures will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// And be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -43,6 +43,8 @@ namespace CodeImp.DoomBuilder.Windows
private Vector2D globalslopepivot;
private Dictionary<Sector, Vector2D> slopepivots;
private bool oldmapischanged;
#endregion
#region ================== Structs
@ -306,7 +308,8 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Sector> sectors)
{
preventchanges = true; //mxd
undocreated = false;
oldmapischanged = General.Map.IsChanged;
undocreated = false;
// Keep this list
this.sectors = sectors;
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
@ -942,7 +945,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the sector, like floor/ceiling textures will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// Be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -51,6 +51,7 @@ namespace CodeImp.DoomBuilder.Windows
private static bool useabsoluteheight; //mxd
private List<ThingProperties> thingprops; //mxd
private Dictionary<string, string> flagsrename; //mxd
private bool oldmapischanged;
private struct ThingProperties //mxd
{
@ -141,6 +142,7 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Thing> things)
{
preventchanges = true;
oldmapischanged = General.Map.IsChanged;
undocreated = false;
argscontrol.Reset();
@ -466,7 +468,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Perform undo?
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the thing, like its type, will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// Be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -51,6 +51,7 @@ namespace CodeImp.DoomBuilder.Windows
private List<ThingProperties> thingprops; //mxd
private readonly string[] renderstyles; //mxd
private Dictionary<string, string> flagsrename; //mxd
private bool oldmapischanged;
//mxd. Persistent settings
private bool useabsoluteheight;
@ -164,6 +165,7 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Thing> things)
{
preventchanges = true;
oldmapischanged = General.Map.IsChanged;
undocreated = false;
argscontrol.Reset();
@ -589,7 +591,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Perform undo?
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the sector, like its type, will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// Be gone
this.DialogResult = DialogResult.Cancel;

View file

@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.Windows
private bool preventchanges; //mxd
private bool undocreated; //mxd
private List<VertexProperties> vertexprops; //mxd
private bool oldmapischanged;
private struct VertexProperties //mxd
{
@ -118,6 +119,7 @@ namespace CodeImp.DoomBuilder.Windows
public void Setup(ICollection<Vertex> vertices, bool allowPositionChange)
{
preventchanges = true; //mxd
oldmapischanged = General.Map.IsChanged;
// Keep this list
this.vertices = vertices;
@ -356,7 +358,16 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Perform undo if required
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
if (undocreated)
{
General.Map.UndoRedo.WithdrawUndo();
// Changing certain properties of the vertex, like the position, will set General.Map.IsChanged to true.
// But if cancel is pressed and the changes are discarded, and the map was not changed before, we have to force
// General.Map.IsChanged back to false
if (General.Map.IsChanged && oldmapischanged == false)
General.Map.ForceMapIsChangedFalse();
}
// And close
this.DialogResult = DialogResult.Cancel;