Changed, Edit Sector/Linedef/Thing/Vertex forms: undo is now created either when user changes a value using a real-time control or when applying changes, not when opening a form.

This commit is contained in:
MaxED 2015-01-26 08:53:05 +00:00
parent 9a5709cf69
commit 0374a0bf90
7 changed files with 408 additions and 238 deletions

View file

@ -46,8 +46,9 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Variables
private ICollection<Linedef> lines;
private List<LinedefProperties> linedefProps; //mxd
private List<LinedefProperties> linedefprops; //mxd
private bool preventchanges;
private bool undocreated; //mxd
//mxd. Window setup stuff
private static Point location = Point.Empty;
@ -180,12 +181,7 @@ namespace CodeImp.DoomBuilder.Windows
// Keep this list
this.lines = lines;
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
linedefProps = new List<LinedefProperties>();
//mxd. Make undo
string undodesc = "linedef";
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
linedefprops = new List<LinedefProperties>();
////////////////////////////////////////////////////////////////////////
// Set all options to the first linedef properties
@ -354,7 +350,7 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd
linedefProps.Add(new LinedefProperties(l));
linedefprops.Add(new LinedefProperties(l));
}
// Refresh controls so that they show their image
@ -412,6 +408,16 @@ namespace CodeImp.DoomBuilder.Windows
}
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (lines.Count > 1 ? lines.Count + " linedefs" : "linedef"));
}
//mxd
private void UpdateScriptControls()
{
@ -446,6 +452,8 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
MakeUndo(); //mxd
//mxd
bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1;
@ -557,7 +565,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
General.Map.UndoRedo.WithdrawUndo();
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// Be gone
this.DialogResult = DialogResult.Cancel;
@ -612,6 +620,8 @@ namespace CodeImp.DoomBuilder.Windows
if(!preventchanges)
{
MakeUndo(); //mxd
// mxd. Apply action's default arguments
if(showaction != 0)
{
@ -662,6 +672,7 @@ namespace CodeImp.DoomBuilder.Windows
private void flags_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
@ -673,8 +684,8 @@ namespace CodeImp.DoomBuilder.Windows
l.SetFlag(c.Tag.ToString(), true);
else if(c.CheckState == CheckState.Unchecked)
l.SetFlag(c.Tag.ToString(), false);
else if(linedefProps[i].Flags.ContainsKey(c.Tag.ToString()))
l.SetFlag(c.Tag.ToString(), linedefProps[i].Flags[c.Tag.ToString()]);
else if(linedefprops[i].Flags.ContainsKey(c.Tag.ToString()))
l.SetFlag(c.Tag.ToString(), linedefprops[i].Flags[c.Tag.ToString()]);
else //linedefs created in the editor have empty Flags by default
l.SetFlag(c.Tag.ToString(), false);
}
@ -693,6 +704,7 @@ namespace CodeImp.DoomBuilder.Windows
private void fronthigh_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(fronthigh.TextureName))
@ -701,7 +713,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureHigh(linedefProps[i].Front != null ? linedefProps[i].Front.TextureTop : "-");
if(l.Front != null) l.Front.SetTextureHigh(linedefprops[i].Front != null ? linedefprops[i].Front.TextureTop : "-");
i++;
}
@ -722,6 +734,7 @@ namespace CodeImp.DoomBuilder.Windows
private void frontmid_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(frontmid.TextureName))
@ -730,7 +743,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureMid(linedefProps[i].Front != null ? linedefProps[i].Front.TextureMid : "-");
if(l.Front != null) l.Front.SetTextureMid(linedefprops[i].Front != null ? linedefprops[i].Front.TextureMid : "-");
i++;
}
@ -751,6 +764,7 @@ namespace CodeImp.DoomBuilder.Windows
private void frontlow_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(frontlow.TextureName))
@ -759,7 +773,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureLow(linedefProps[i].Front != null ? linedefProps[i].Front.TextureLow : "-");
if(l.Front != null) l.Front.SetTextureLow(linedefprops[i].Front != null ? linedefprops[i].Front.TextureLow : "-");
i++;
}
@ -780,6 +794,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backhigh_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backhigh.TextureName))
@ -788,7 +803,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureHigh(linedefProps[i].Back != null ? linedefProps[i].Back.TextureTop : "-");
if(l.Back != null) l.Back.SetTextureHigh(linedefprops[i].Back != null ? linedefprops[i].Back.TextureTop : "-");
i++;
}
@ -809,6 +824,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backmid_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backmid.TextureName))
@ -817,7 +833,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureMid(linedefProps[i].Back != null ? linedefProps[i].Back.TextureMid : "-");
if(l.Back != null) l.Back.SetTextureMid(linedefprops[i].Back != null ? linedefprops[i].Back.TextureMid : "-");
i++;
}
@ -838,6 +854,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backlow_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backlow.TextureName))
@ -846,7 +863,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureLow(linedefProps[i].Back != null ? linedefProps[i].Back.TextureLow : "-");
if(l.Back != null) l.Back.SetTextureLow(linedefprops[i].Back != null ? linedefprops[i].Back.TextureLow : "-");
i++;
}
@ -867,17 +884,17 @@ namespace CodeImp.DoomBuilder.Windows
private void frontTextureOffset_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
if(linedefProps[i].Front != null)
if(linedefprops[i].Front != null)
{
l.Front.OffsetX = frontTextureOffset.GetValue1(linedefProps[i].Front.OffsetX);
l.Front.OffsetY = frontTextureOffset.GetValue2(linedefProps[i].Front.OffsetY);
l.Front.OffsetX = frontTextureOffset.GetValue1(linedefprops[i].Front.OffsetX);
l.Front.OffsetY = frontTextureOffset.GetValue2(linedefprops[i].Front.OffsetY);
}
else
{
@ -897,17 +914,17 @@ namespace CodeImp.DoomBuilder.Windows
private void backTextureOffset_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
if(linedefProps[i].Back != null)
if(linedefprops[i].Back != null)
{
l.Back.OffsetX = backTextureOffset.GetValue1(linedefProps[i].Back.OffsetX);
l.Back.OffsetY = backTextureOffset.GetValue2(linedefProps[i].Back.OffsetY);
l.Back.OffsetX = backTextureOffset.GetValue1(linedefprops[i].Back.OffsetX);
l.Back.OffsetY = backTextureOffset.GetValue2(linedefprops[i].Back.OffsetY);
}
else
{

View file

@ -48,8 +48,9 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Variables
private ICollection<Linedef> lines;
private List<LinedefProperties> linedefProps; //mxd
private List<LinedefProperties> linedefprops; //mxd
private bool preventchanges;
private bool undocreated; //mxd
private string arg0str; //mxd
private bool haveArg0Str; //mxd
private readonly string[] renderstyles; //mxd
@ -265,12 +266,7 @@ namespace CodeImp.DoomBuilder.Windows
// Keep this list
this.lines = lines;
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
linedefProps = new List<LinedefProperties>();
//mxd. Make undo
string undodesc = "linedef";
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
linedefprops = new List<LinedefProperties>();
////////////////////////////////////////////////////////////////////////
// Set all options to the first linedef properties
@ -437,7 +433,6 @@ namespace CodeImp.DoomBuilder.Windows
}
// Custom fields
l.Fields.BeforeFieldsChange();
fieldslist.SetValues(l.Fields, false);
// Action/tags
@ -516,7 +511,6 @@ namespace CodeImp.DoomBuilder.Windows
cbLightAbsoluteFront.CheckState = CheckState.Indeterminate;
}
l.Front.Fields.BeforeFieldsChange(); //mxd
frontTextureOffset.SetValues(l.Front.OffsetX, l.Front.OffsetY, false); //mxd
}
@ -572,12 +566,11 @@ namespace CodeImp.DoomBuilder.Windows
cbLightAbsoluteBack.CheckState = CheckState.Indeterminate;
}
l.Back.Fields.BeforeFieldsChange(); //mxd
backTextureOffset.SetValues(l.Back.OffsetX, l.Back.OffsetY, false); //mxd
}
//mxd
linedefProps.Add(new LinedefProperties(l));
linedefprops.Add(new LinedefProperties(l));
}
// Refresh controls so that they show their image
@ -662,6 +655,26 @@ namespace CodeImp.DoomBuilder.Windows
}
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (lines.Count > 1 ? lines.Count + " linedefs" : "linedef"));
if(General.Map.FormatInterface.HasCustomFields)
{
foreach (Linedef l in lines)
{
l.Fields.BeforeFieldsChange();
if(l.Front != null) l.Front.Fields.BeforeFieldsChange();
if(l.Back != null) l.Back.Fields.BeforeFieldsChange();
}
}
}
//mxd
private void UpdateScriptControls()
{
@ -738,6 +751,8 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
MakeUndo();
//mxd
bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1;
int locknumber = 0;
@ -892,7 +907,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
General.Map.UndoRedo.WithdrawUndo();
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// Be gone
this.DialogResult = DialogResult.Cancel;
@ -949,6 +964,8 @@ namespace CodeImp.DoomBuilder.Windows
if(!preventchanges)
{
MakeUndo(); //mxd
// mxd. Apply action's default arguments
if(showaction != 0)
{
@ -1016,6 +1033,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cbRenderStyle_SelectedIndexChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//update values
foreach(Linedef l in lines)
@ -1028,13 +1046,14 @@ namespace CodeImp.DoomBuilder.Windows
private void alpha_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if(string.IsNullOrEmpty(alpha.Text))
{
foreach(Linedef l in lines)
UDMFTools.SetFloat(l.Fields, "alpha", linedefProps[i++].Alpha, 1.0f);
UDMFTools.SetFloat(l.Fields, "alpha", linedefprops[i++].Alpha, 1.0f);
}
else //update values
{
@ -1052,6 +1071,7 @@ namespace CodeImp.DoomBuilder.Windows
private void flags_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
@ -1063,8 +1083,8 @@ namespace CodeImp.DoomBuilder.Windows
l.SetFlag(c.Tag.ToString(), true);
else if(c.CheckState == CheckState.Unchecked)
l.SetFlag(c.Tag.ToString(), false);
else if(linedefProps[i].Flags.ContainsKey(c.Tag.ToString()))
l.SetFlag(c.Tag.ToString(), linedefProps[i].Flags[c.Tag.ToString()]);
else if(linedefprops[i].Flags.ContainsKey(c.Tag.ToString()))
l.SetFlag(c.Tag.ToString(), linedefprops[i].Flags[c.Tag.ToString()]);
else //linedefs created in the editor have empty Flags by default
l.SetFlag(c.Tag.ToString(), false);
}
@ -1218,6 +1238,7 @@ namespace CodeImp.DoomBuilder.Windows
private void fronthigh_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(fronthigh.TextureName))
@ -1226,7 +1247,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureHigh(linedefProps[i].Front != null ? linedefProps[i].Front.TextureTop : "-");
if(l.Front != null) l.Front.SetTextureHigh(linedefprops[i].Front != null ? linedefprops[i].Front.TextureTop : "-");
i++;
}
}
@ -1246,6 +1267,7 @@ namespace CodeImp.DoomBuilder.Windows
private void frontmid_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(frontmid.TextureName))
@ -1254,7 +1276,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureMid(linedefProps[i].Front != null ? linedefProps[i].Front.TextureMid : "-");
if(l.Front != null) l.Front.SetTextureMid(linedefprops[i].Front != null ? linedefprops[i].Front.TextureMid : "-");
i++;
}
}
@ -1274,6 +1296,7 @@ namespace CodeImp.DoomBuilder.Windows
private void frontlow_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(frontlow.TextureName))
@ -1282,7 +1305,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null) l.Front.SetTextureLow(linedefProps[i].Front != null ? linedefProps[i].Front.TextureLow : "-");
if(l.Front != null) l.Front.SetTextureLow(linedefprops[i].Front != null ? linedefprops[i].Front.TextureLow : "-");
i++;
}
}
@ -1302,6 +1325,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backhigh_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backhigh.TextureName))
@ -1310,7 +1334,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureHigh(linedefProps[i].Back != null ? linedefProps[i].Back.TextureTop : "-");
if(l.Back != null) l.Back.SetTextureHigh(linedefprops[i].Back != null ? linedefprops[i].Back.TextureTop : "-");
i++;
}
}
@ -1330,6 +1354,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backmid_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backmid.TextureName))
@ -1338,7 +1363,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureMid(linedefProps[i].Back != null ? linedefProps[i].Back.TextureMid : "-");
if(l.Back != null) l.Back.SetTextureMid(linedefprops[i].Back != null ? linedefprops[i].Back.TextureMid : "-");
i++;
}
}
@ -1358,6 +1383,7 @@ namespace CodeImp.DoomBuilder.Windows
private void backlow_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(backlow.TextureName))
@ -1366,7 +1392,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null) l.Back.SetTextureLow(linedefProps[i].Back != null ? linedefProps[i].Back.TextureLow : "-");
if(l.Back != null) l.Back.SetTextureLow(linedefprops[i].Back != null ? linedefprops[i].Back.TextureLow : "-");
i++;
}
}
@ -1390,6 +1416,7 @@ namespace CodeImp.DoomBuilder.Windows
private void lightFront_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
@ -1398,7 +1425,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Front != null)
UDMFTools.SetInteger(l.Front.Fields, "light", (linedefProps[i].Front != null ? linedefProps[i].Front.Brightness : 0), 0);
UDMFTools.SetInteger(l.Front.Fields, "light", (linedefprops[i].Front != null ? linedefprops[i].Front.Brightness : 0), 0);
i++;
}
}
@ -1418,7 +1445,7 @@ namespace CodeImp.DoomBuilder.Windows
absolute = true;
}
int value = General.Clamp(lightFront.GetResult((linedefProps[i].Front != null ? linedefProps[i].Front.Brightness : 0)), (absolute ? 0 : -255), 255);
int value = General.Clamp(lightFront.GetResult((linedefprops[i].Front != null ? linedefprops[i].Front.Brightness : 0)), (absolute ? 0 : -255), 255);
UDMFTools.SetInteger(l.Front.Fields, "light", value, 0);
}
i++;
@ -1432,6 +1459,7 @@ namespace CodeImp.DoomBuilder.Windows
private void lightBack_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
@ -1440,7 +1468,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Linedef l in lines)
{
if(l.Back != null)
UDMFTools.SetInteger(l.Back.Fields, "light", (linedefProps[i].Back != null ? linedefProps[i].Back.Brightness : 0), 0);
UDMFTools.SetInteger(l.Back.Fields, "light", (linedefprops[i].Back != null ? linedefprops[i].Back.Brightness : 0), 0);
i++;
}
}
@ -1460,7 +1488,7 @@ namespace CodeImp.DoomBuilder.Windows
absolute = true;
}
int value = General.Clamp(lightBack.GetResult((linedefProps[i].Back != null ? linedefProps[i].Back.Brightness : 0)), (absolute ? 0 : -255), 255);
int value = General.Clamp(lightBack.GetResult((linedefprops[i].Back != null ? linedefprops[i].Back.Brightness : 0)), (absolute ? 0 : -255), 255);
UDMFTools.SetInteger(l.Back.Fields, "light", value, 0);
}
i++;
@ -1474,6 +1502,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cbLightAbsoluteFront_CheckedChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
if(cbLightAbsoluteFront.Checked)
{
@ -1491,7 +1520,7 @@ namespace CodeImp.DoomBuilder.Windows
{
if(l.Front != null)
{
if(linedefProps[i].Front != null && linedefProps[i].Front.AbsoluteBrightness)
if(linedefprops[i].Front != null && linedefprops[i].Front.AbsoluteBrightness)
{
l.Front.Fields["lightabsolute"] = new UniValue(UniversalType.Boolean, true);
}
@ -1519,6 +1548,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cbLightAbsoluteBack_CheckedChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
if(cbLightAbsoluteBack.Checked)
{
@ -1536,7 +1566,7 @@ namespace CodeImp.DoomBuilder.Windows
{
if(l.Back != null)
{
if(linedefProps[i].Back != null && linedefProps[i].Back.AbsoluteBrightness)
if(linedefprops[i].Back != null && linedefprops[i].Back.AbsoluteBrightness)
{
l.Back.Fields["lightabsolute"] = new UniValue(UniversalType.Boolean, true);
}
@ -1568,17 +1598,17 @@ namespace CodeImp.DoomBuilder.Windows
private void frontTextureOffset_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
if(linedefProps[i].Front != null)
if(linedefprops[i].Front != null)
{
l.Front.OffsetX = frontTextureOffset.GetValue1(linedefProps[i].Front.OffsetX);
l.Front.OffsetY = frontTextureOffset.GetValue2(linedefProps[i].Front.OffsetY);
l.Front.OffsetX = frontTextureOffset.GetValue1(linedefprops[i].Front.OffsetX);
l.Front.OffsetY = frontTextureOffset.GetValue2(linedefprops[i].Front.OffsetY);
}
else
{
@ -1598,17 +1628,17 @@ namespace CodeImp.DoomBuilder.Windows
private void backTextureOffset_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
if(linedefProps[i].Back != null)
if(linedefprops[i].Back != null)
{
l.Back.OffsetX = backTextureOffset.GetValue1(linedefProps[i].Back.OffsetX);
l.Back.OffsetY = backTextureOffset.GetValue2(linedefProps[i].Back.OffsetY);
l.Back.OffsetX = backTextureOffset.GetValue1(linedefprops[i].Back.OffsetX);
l.Back.OffsetY = backTextureOffset.GetValue2(linedefprops[i].Back.OffsetY);
}
else
{
@ -1632,14 +1662,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontOffsetTop_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetTopX : 0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetTopY : 0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetTopX : 0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetTopY : 0f;
pfcFrontOffsetTop.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
i++;
@ -1653,14 +1684,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontOffsetMid_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetMidX : 0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetMidY : 0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetMidX : 0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetMidY : 0f;
pfcFrontOffsetMid.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1675,14 +1707,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontOffsetBottom_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetBottomX : 0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.OffsetBottomY : 0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetBottomX : 0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.OffsetBottomY : 0f;
pfcFrontOffsetBottom.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1697,14 +1730,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackOffsetTop_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetTopX : 0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetTopY : 0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetTopX : 0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetTopY : 0f;
pfcBackOffsetTop.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1719,14 +1753,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackOffsetMid_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetMidX : 0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetMidY : 0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetMidX : 0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetMidY : 0f;
pfcBackOffsetMid.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1741,14 +1776,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackOffsetBottom_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetBottomX : 0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.OffsetBottomY : 0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetBottomX : 0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.OffsetBottomY : 0f;
pfcBackOffsetBottom.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1767,14 +1803,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontScaleTop_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleTopX : 1.0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleTopY : 1.0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleTopX : 1.0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleTopY : 1.0f;
pfcFrontScaleTop.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1789,14 +1826,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontScaleMid_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleMidX : 1.0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleMidY : 1.0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleMidX : 1.0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleMidY : 1.0f;
pfcFrontScaleMid.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1811,14 +1849,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcFrontScaleBottom_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Front != null)
{
float oldX = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleBottomX : 1.0f;
float oldY = linedefProps[i].Front != null ? linedefProps[i].Front.ScaleBottomY : 1.0f;
float oldX = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleBottomX : 1.0f;
float oldY = linedefprops[i].Front != null ? linedefprops[i].Front.ScaleBottomY : 1.0f;
pfcFrontScaleBottom.ApplyTo(l.Front.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1833,14 +1872,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackScaleTop_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleTopX : 1.0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleTopY : 1.0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleTopX : 1.0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleTopY : 1.0f;
pfcBackScaleTop.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1855,14 +1895,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackScaleMid_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleMidX : 1.0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleMidY : 1.0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleMidX : 1.0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleMidY : 1.0f;
pfcBackScaleMid.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1877,14 +1918,15 @@ namespace CodeImp.DoomBuilder.Windows
private void pfcBackScaleBottom_OnValuesChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
{
if(l.Back != null)
{
float oldX = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleBottomX : 1.0f;
float oldY = linedefProps[i].Back != null ? linedefProps[i].Back.ScaleBottomY : 1.0f;
float oldX = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleBottomX : 1.0f;
float oldY = linedefprops[i].Back != null ? linedefprops[i].Back.ScaleBottomY : 1.0f;
pfcBackScaleBottom.ApplyTo(l.Back.Fields, General.Map.FormatInterface.MinTextureOffset, General.Map.FormatInterface.MaxTextureOffset, oldX, oldY);
}
@ -1903,6 +1945,7 @@ namespace CodeImp.DoomBuilder.Windows
private void flagsFront_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
@ -1916,8 +1959,8 @@ namespace CodeImp.DoomBuilder.Windows
l.Front.SetFlag(c.Tag.ToString(), true);
else if(c.CheckState == CheckState.Unchecked)
l.Front.SetFlag(c.Tag.ToString(), false);
else if(linedefProps[i].Front.Flags.ContainsKey(c.Tag.ToString()))
l.Front.SetFlag(c.Tag.ToString(), linedefProps[i].Front.Flags[c.Tag.ToString()]);
else if(linedefprops[i].Front.Flags.ContainsKey(c.Tag.ToString()))
l.Front.SetFlag(c.Tag.ToString(), linedefprops[i].Front.Flags[c.Tag.ToString()]);
else //linedefs created in the editor have empty Flags by default
l.Front.SetFlag(c.Tag.ToString(), false);
}
@ -1932,6 +1975,7 @@ namespace CodeImp.DoomBuilder.Windows
private void flagsBack_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach(Linedef l in lines)
@ -1945,8 +1989,8 @@ namespace CodeImp.DoomBuilder.Windows
l.Back.SetFlag(c.Tag.ToString(), true);
else if(c.CheckState == CheckState.Unchecked)
l.Back.SetFlag(c.Tag.ToString(), false);
else if(linedefProps[i].Back.Flags.ContainsKey(c.Tag.ToString()))
l.Back.SetFlag(c.Tag.ToString(), linedefProps[i].Back.Flags[c.Tag.ToString()]);
else if(linedefprops[i].Back.Flags.ContainsKey(c.Tag.ToString()))
l.Back.SetFlag(c.Tag.ToString(), linedefprops[i].Back.Flags[c.Tag.ToString()]);
else //linedefs created in the editor have empty Flags by default
l.Back.SetFlag(c.Tag.ToString(), false);
}

View file

@ -38,8 +38,9 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Variables
private ICollection<Sector> sectors;
private List<SectorProperties> sectorProps; //mxd
private bool blockUpdate; //mxd
private List<SectorProperties> sectorprops; //mxd
private bool preventchanges; //mxd
private bool undocreated; //mxd
//mxd. Window setup stuff
private static Point location = Point.Empty;
@ -98,17 +99,12 @@ namespace CodeImp.DoomBuilder.Windows
// This sets up the form to edit the given sectors
public void Setup(ICollection<Sector> sectors)
{
blockUpdate = true; //mxd
preventchanges = true; //mxd
// Keep this list
this.sectors = sectors;
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
sectorProps = new List<SectorProperties>(); //mxd
//mxd. Make undo
string undodesc = "sector";
if(sectors.Count > 1) undodesc = sectors.Count + " sectors";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
sectorprops = new List<SectorProperties>(); //mxd
//mxd. Set default height offset
heightoffset.Text = "0";
@ -163,13 +159,23 @@ namespace CodeImp.DoomBuilder.Windows
if(s.Tag != sc.Tag) tagSelector.ClearTag(); //mxd
//mxd. Store initial properties
sectorProps.Add(new SectorProperties(s));
sectorprops.Add(new SectorProperties(s));
}
// Show sector height
UpdateSectorHeight();
blockUpdate = false; //mxd
preventchanges = false; //mxd
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (sectors.Count > 1 ? sectors.Count + " sectors" : "sector"));
}
// This updates the sector height field
@ -201,8 +207,8 @@ namespace CodeImp.DoomBuilder.Windows
if(index > -1)
{
int fh = floorheight.GetResult(sectorProps[index].FloorHeight); //mxd
int ch = ceilingheight.GetResult(sectorProps[index].CeilHeight); //mxd
int fh = floorheight.GetResult(sectorprops[index].FloorHeight); //mxd
int ch = ceilingheight.GetResult(sectorprops[index].CeilHeight); //mxd
int height = ch - fh;
sectorheight.Text = height.ToString();
sectorheight.Visible = true;
@ -225,13 +231,13 @@ namespace CodeImp.DoomBuilder.Windows
if(string.IsNullOrEmpty(ceilingheight.Text))
{
foreach(Sector s in sectors)
s.CeilHeight = sectorProps[i++].CeilHeight + offset;
s.CeilHeight = sectorprops[i++].CeilHeight + offset;
}
else //update values
{
foreach(Sector s in sectors)
s.CeilHeight = ceilingheight.GetResult(sectorProps[i++].CeilHeight) + offset;
s.CeilHeight = ceilingheight.GetResult(sectorprops[i++].CeilHeight) + offset;
}
}
@ -245,13 +251,13 @@ namespace CodeImp.DoomBuilder.Windows
if(string.IsNullOrEmpty(floorheight.Text))
{
foreach(Sector s in sectors)
s.FloorHeight = sectorProps[i++].FloorHeight + offset;
s.FloorHeight = sectorprops[i++].FloorHeight + offset;
}
else //update values
{
foreach(Sector s in sectors)
s.FloorHeight = floorheight.GetResult(sectorProps[i++].FloorHeight) + offset;
s.FloorHeight = floorheight.GetResult(sectorprops[i++].FloorHeight) + offset;
}
}
@ -278,6 +284,8 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
MakeUndo(); //mxd
// Go for all sectors
int tagoffset = 0; //mxd
foreach(Sector s in sectors)
@ -300,7 +308,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. perform undo
General.Map.UndoRedo.WithdrawUndo();
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// And be gone
this.DialogResult = DialogResult.Cancel;
@ -334,7 +342,8 @@ namespace CodeImp.DoomBuilder.Windows
// Ceiling height changes
private void ceilingheight_TextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateCeilingHeight();
UpdateSectorHeight();
@ -346,7 +355,8 @@ namespace CodeImp.DoomBuilder.Windows
// Floor height changes
private void floorheight_TextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateFloorHeight();
UpdateSectorHeight();
@ -358,7 +368,8 @@ namespace CodeImp.DoomBuilder.Windows
// Height offset changes
private void heightoffset_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateFloorHeight();
UpdateCeilingHeight();
@ -370,13 +381,14 @@ namespace CodeImp.DoomBuilder.Windows
private void floortex_OnValueChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(floortex.TextureName))
{
int i = 0;
foreach(Sector s in sectors) s.SetFloorTexture(sectorProps[i++].FloorTexture);
foreach(Sector s in sectors) s.SetFloorTexture(sectorprops[i++].FloorTexture);
}
else //update values
@ -393,13 +405,14 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilingtex_OnValueChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(ceilingtex.TextureName))
{
int i = 0;
foreach(Sector s in sectors) s.SetCeilTexture(sectorProps[i++].CeilTexture);
foreach(Sector s in sectors) s.SetCeilTexture(sectorprops[i++].CeilTexture);
}
else //update values
@ -416,19 +429,20 @@ namespace CodeImp.DoomBuilder.Windows
private void brightness_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if(string.IsNullOrEmpty(brightness.Text))
{
foreach(Sector s in sectors) s.Brightness = sectorProps[i++].Brightness;
foreach(Sector s in sectors) s.Brightness = sectorprops[i++].Brightness;
}
else //update values
{
foreach(Sector s in sectors)
s.Brightness = General.Clamp(brightness.GetResult(sectorProps[i++].Brightness), General.Map.FormatInterface.MinBrightness, General.Map.FormatInterface.MaxBrightness);
s.Brightness = General.Clamp(brightness.GetResult(sectorprops[i++].Brightness), General.Map.FormatInterface.MinBrightness, General.Map.FormatInterface.MaxBrightness);
}
General.Map.IsChanged = true;

View file

@ -26,7 +26,8 @@ namespace CodeImp.DoomBuilder.Windows
private ICollection<Sector> sectors;
private Dictionary<Sector, SectorProperties> sectorprops; //mxd
private bool blockupdate; //mxd
private bool preventchanges; //mxd
private bool undocreated; //mxd
private StepsList anglesteps; //mxd
private readonly string[] renderstyles; //mxd
@ -232,18 +233,13 @@ namespace CodeImp.DoomBuilder.Windows
// This sets up the form to edit the given sectors
public void Setup(ICollection<Sector> sectors)
{
blockupdate = true; //mxd
preventchanges = true; //mxd
// Keep this list
this.sectors = sectors;
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
sectorprops = new Dictionary<Sector, SectorProperties>(sectors.Count); //mxd
//mxd. Make undo
string undodesc = "sector";
if(sectors.Count > 1) undodesc = sectors.Count + " sectors";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
//mxd. Set default height offset
heightoffset.Text = "0";
@ -424,7 +420,6 @@ namespace CodeImp.DoomBuilder.Windows
if(s.Tag != sc.Tag) tagSelector.ClearTag(); //mxd
// Custom fields
s.Fields.BeforeFieldsChange(); //mxd
fieldslist.SetValues(s.Fields, false);
//mxd. Angle steps
@ -460,7 +455,18 @@ namespace CodeImp.DoomBuilder.Windows
if(useCeilSlopeLineAngles) ceilingslopecontrol.StepValues = anglesteps;
if(useFloorSlopeLineAngles) floorslopecontrol.StepValues = anglesteps;
blockupdate = false; //mxd
preventchanges = false; //mxd
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (sectors.Count > 1 ? sectors.Count + " sectors" : "sector"));
foreach(Sector s in sectors) s.Fields.BeforeFieldsChange();
}
// mxd
@ -611,6 +617,8 @@ namespace CodeImp.DoomBuilder.Windows
General.Map.Config.SectorRenderStyles.Keys.CopyTo(rskeys, 0);
}
MakeUndo(); //mxd
// Go for all sectors
int tagoffset = 0; //mxd
foreach(Sector s in sectors)
@ -705,7 +713,7 @@ namespace CodeImp.DoomBuilder.Windows
private void cancel_Click(object sender, EventArgs e)
{
//mxd. Let's pretend nothing of this really happened...
General.Map.UndoRedo.WithdrawUndo();
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// Be gone
this.DialogResult = DialogResult.Cancel;
@ -763,7 +771,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilingheight_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateCeilingHeight();
UpdateSectorHeight();
@ -774,7 +783,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorheight_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateFloorHeight();
UpdateSectorHeight();
@ -785,7 +795,8 @@ namespace CodeImp.DoomBuilder.Windows
private void heightoffset_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
UpdateFloorHeight();
UpdateCeilingHeight();
@ -797,7 +808,8 @@ namespace CodeImp.DoomBuilder.Windows
private void brightness_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(brightness.Text))
@ -818,7 +830,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilingtex_OnValueChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(ceilingtex.TextureName))
@ -842,7 +855,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floortex_OnValueChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(floortex.TextureName))
@ -866,7 +880,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorRotation_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(floorRotation.Text))
@ -896,7 +911,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilRotation_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(ceilRotation.Text))
@ -926,7 +942,8 @@ namespace CodeImp.DoomBuilder.Windows
private void lightColor_OnValueChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -940,7 +957,8 @@ namespace CodeImp.DoomBuilder.Windows
private void fadeColor_OnValueChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -958,7 +976,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilOffsets_OnValuesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -973,7 +992,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorOffsets_OnValuesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -988,7 +1008,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilScale_OnValuesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -1003,7 +1024,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorScale_OnValuesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
foreach(Sector s in sectors)
{
@ -1018,7 +1040,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilBrightness_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(ceilBrightness.Text))
@ -1055,7 +1078,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorBrightness_WhenTextChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
//restore values
if(string.IsNullOrEmpty(floorBrightness.Text))
@ -1092,7 +1116,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilLightAbsolute_CheckedChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
if(ceilLightAbsolute.Checked)
{
@ -1136,7 +1161,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorLightAbsolute_CheckedChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
if(floorLightAbsolute.Checked)
{
@ -1287,7 +1313,8 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilingslopecontrol_OnAnglesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
float anglexy, anglez;
//Set or restore values
@ -1312,7 +1339,8 @@ namespace CodeImp.DoomBuilder.Windows
private void floorslopecontrol_OnAnglesChanged(object sender, EventArgs e)
{
if(blockupdate) return;
if(preventchanges) return;
MakeUndo(); //mxd
float anglexy, anglez;
//Set or restore values
@ -1338,6 +1366,7 @@ namespace CodeImp.DoomBuilder.Windows
// Update displayed ceiling offset value
private void ceilingslopecontrol_OnPivotModeChanged(object sender, EventArgs e)
{
MakeUndo(); //mxd
bool first = true;
foreach (Sector s in sectors)
{
@ -1349,6 +1378,7 @@ namespace CodeImp.DoomBuilder.Windows
// Update displayed floor offset value
private void floorslopecontrol_OnPivotModeChanged(object sender, EventArgs e)
{
MakeUndo(); //mxd
bool first = true;
foreach (Sector s in sectors)
{
@ -1359,6 +1389,7 @@ namespace CodeImp.DoomBuilder.Windows
private void ceilingslopecontrol_OnResetClicked(object sender, EventArgs e)
{
MakeUndo(); //mxd
ceilingslopecontrol.SetOffset(General.GetByIndex(sectors, 0).CeilHeight, true);
foreach(Sector s in sectors)
@ -1378,6 +1409,7 @@ namespace CodeImp.DoomBuilder.Windows
private void floorslopecontrol_OnResetClicked(object sender, EventArgs e)
{
MakeUndo(); //mxd
floorslopecontrol.SetOffset(General.GetByIndex(sectors, 0).FloorHeight, true);
foreach(Sector s in sectors)

View file

@ -47,9 +47,10 @@ namespace CodeImp.DoomBuilder.Windows
private ICollection<Thing> things;
private ThingTypeInfo thinginfo;
private bool preventchanges;
//mxd
private static bool useAbsoluteHeight;
private List<ThingProperties> thingProps; //mxd
private bool preventmapchange; //mxd
private bool undocreated; //mxd
private static bool useAbsoluteHeight; //mxd
private List<ThingProperties> thingprops; //mxd
//mxd. Window setup stuff
private static Point location = Point.Empty;
@ -149,11 +150,6 @@ namespace CodeImp.DoomBuilder.Windows
hint.Visible = things.Count > 1; //mxd
hintlabel.Visible = things.Count > 1; //mxd
thingtype.UseMultiSelection = things.Count > 1; //mxd
//mxd. Make undo
string undodesc = "thing";
if(things.Count > 1) undodesc = things.Count + " things";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
////////////////////////////////////////////////////////////////////////
// Set all options to the first thing properties
@ -200,7 +196,7 @@ namespace CodeImp.DoomBuilder.Windows
// Now go for all lines and change the options when a setting is different
////////////////////////////////////////////////////////////////////////
thingProps = new List<ThingProperties>();
thingprops = new List<ThingProperties>();
// Go for all things
foreach(Thing t in things)
@ -250,14 +246,16 @@ namespace CodeImp.DoomBuilder.Windows
if(t.Args[4] != arg4.GetResult(-1)) arg4.ClearValue();
//mxd. Store initial properties
thingProps.Add(new ThingProperties(t));
thingprops.Add(new ThingProperties(t));
}
preventchanges = false;
//mxd. Trigger updates manually...
preventmapchange = true;
angle_WhenTextChanged(angle, EventArgs.Empty);
flags_OnValueChanged(flags, EventArgs.Empty);
preventmapchange = false;
UpdateScriptControls(); //mxd
actionhelp.UpdateAction(action.GetValue()); //mxd
@ -294,6 +292,16 @@ namespace CodeImp.DoomBuilder.Windows
}
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (things.Count > 1 ? things.Count + " things" : "thing"));
}
//mxd
private void UpdateScriptControls()
{
@ -345,6 +353,8 @@ namespace CodeImp.DoomBuilder.Windows
if(!preventchanges)
{
MakeUndo();
// mxd. Apply action's or thing's default arguments
if (showaction != 0 || thinginfo != null)
{
@ -382,7 +392,7 @@ namespace CodeImp.DoomBuilder.Windows
preventchanges = true;
anglecontrol.Angle = angle.GetResult(GZBuilder.Controls.AngleControl.NO_ANGLE);
preventchanges = false;
UpdateAngle(); //mxd
if(!preventmapchange) ApplyAngleChange(); //mxd
}
//mxd. Angle control clicked
@ -390,12 +400,14 @@ namespace CodeImp.DoomBuilder.Windows
{
if(preventchanges) return;
angle.Text = anglecontrol.Angle.ToString();
UpdateAngle();
if(!preventmapchange) ApplyAngleChange();
}
// Apply clicked
private void apply_Click(object sender, EventArgs e)
{
MakeUndo();
List<string> defaultflags = new List<string>();
// Verify the tag
@ -500,8 +512,8 @@ namespace CodeImp.DoomBuilder.Windows
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
//mxd. perform undo
General.Map.UndoRedo.WithdrawUndo();
//mxd. Perform undo?
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// Be gone
this.DialogResult = DialogResult.Cancel;
@ -512,6 +524,8 @@ namespace CodeImp.DoomBuilder.Windows
private void cbAbsoluteHeight_CheckedChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
useAbsoluteHeight = cbAbsoluteHeight.Checked;
zlabel.Text = (useAbsoluteHeight ? "Abs. Z:" : "Z:");
@ -565,11 +579,12 @@ namespace CodeImp.DoomBuilder.Windows
private void posX_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
// Update values
foreach(Thing t in things)
t.Move(new Vector2D(posX.GetResultFloat(thingProps[i++].X), t.Position.y));
t.Move(new Vector2D(posX.GetResultFloat(thingprops[i++].X), t.Position.y));
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
@ -578,11 +593,12 @@ namespace CodeImp.DoomBuilder.Windows
private void posY_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
// Update values
foreach(Thing t in things)
t.Move(new Vector2D(t.Position.x, posY.GetResultFloat(thingProps[i++].Y)));
t.Move(new Vector2D(t.Position.x, posY.GetResultFloat(thingprops[i++].Y)));
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
@ -591,20 +607,21 @@ namespace CodeImp.DoomBuilder.Windows
private void posZ_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
if(string.IsNullOrEmpty(posZ.Text))
{
// Restore values
foreach(Thing t in things)
t.Move(new Vector3D(t.Position.x, t.Position.y, thingProps[i++].Z));
t.Move(new Vector3D(t.Position.x, t.Position.y, thingprops[i++].Z));
}
else
{
// Update values
foreach(Thing t in things)
{
float z = posZ.GetResultFloat(thingProps[i++].Z);
float z = posZ.GetResultFloat(thingprops[i++].Z);
if(useAbsoluteHeight && !posZ.CheckIsRelative() && t.Sector != null)
z -= t.Sector.FloorHeight;
t.Move(new Vector3D(t.Position.x, t.Position.y, z));
@ -625,6 +642,8 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Update things
if(preventchanges) return;
MakeUndo(); //mxd
if(((thingtype.GetResult(0) < General.Map.FormatInterface.MinThingType) || (thingtype.GetResult(0) > General.Map.FormatInterface.MaxThingType)))
return;
@ -642,9 +661,10 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd
private void UpdateAngle()
private void ApplyAngleChange()
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
@ -652,13 +672,13 @@ namespace CodeImp.DoomBuilder.Windows
{
// Apply rotation
foreach(Thing t in things)
t.Rotate(thingProps[i++].AngleDoom);
}
else
{ //update values
t.Rotate(thingprops[i++].AngleDoom);
}
else //update values
{
// Apply rotation
foreach(Thing t in things)
t.Rotate(angle.GetResult(thingProps[i++].AngleDoom));
t.Rotate(angle.GetResult(thingprops[i++].AngleDoom));
}
General.Map.IsChanged = true;

View file

@ -48,10 +48,12 @@ namespace CodeImp.DoomBuilder.Windows
private ICollection<Thing> things;
private ThingTypeInfo thinginfo;
private bool preventchanges;
private bool preventmapchange; //mxd
private bool undocreated; //mxd
private static bool useAbsoluteHeight;
private string arg0str;
private bool haveArg0Str;
private List<ThingProperties> thingProps; //mxd
private List<ThingProperties> thingprops; //mxd
private readonly string[] renderstyles; //mxd
//mxd. Window setup stuff
@ -173,11 +175,6 @@ namespace CodeImp.DoomBuilder.Windows
hintlabel.Visible = things.Count > 1; //mxd
thingtype.UseMultiSelection = things.Count > 1; //mxd
//mxd. Make undo
string undodesc = "thing";
if(things.Count > 1) undodesc = things.Count + " things";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
////////////////////////////////////////////////////////////////////////
// Set all options to the first thing properties
////////////////////////////////////////////////////////////////////////
@ -237,7 +234,7 @@ namespace CodeImp.DoomBuilder.Windows
// Now go for all lines and change the options when a setting is different
////////////////////////////////////////////////////////////////////////
thingProps = new List<ThingProperties>();
thingprops = new List<ThingProperties>();
// Go for all things
foreach(Thing t in things)
@ -285,7 +282,6 @@ namespace CodeImp.DoomBuilder.Windows
if(t.Args[4] != arg4.GetResult(-1)) arg4.ClearValue();
//mxd. Custom fields
t.Fields.BeforeFieldsChange(); //mxd
fieldslist.SetValues(t.Fields, false);
if (t.Fields.GetValue("conversation", 0).ToString() != conversationID.Text) conversationID.Text = "";
if (t.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = "";
@ -310,7 +306,7 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd. Store initial properties
thingProps.Add(new ThingProperties(t));
thingprops.Add(new ThingProperties(t));
//mxd. add user vars
/*if(info != null && info.Actor != null && info.Actor.UserVars.Count > 0)
@ -326,10 +322,12 @@ namespace CodeImp.DoomBuilder.Windows
preventchanges = false;
//mxd. Trigger updates manually...
preventmapchange = true;
angle_WhenTextChanged(angle, EventArgs.Empty);
pitch_WhenTextChanged(pitch, EventArgs.Empty);
roll_WhenTextChanged(roll, EventArgs.Empty);
flags_OnValueChanged(flags, EventArgs.Empty);
preventmapchange = false;
UpdateScriptControls(); //mxd
actionhelp.UpdateAction(action.GetValue()); //mxd
@ -375,6 +373,17 @@ namespace CodeImp.DoomBuilder.Windows
}
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (things.Count > 1 ? things.Count + " things" : "thing"));
foreach(Thing t in things) t.Fields.BeforeFieldsChange();
}
//mxd
private void UpdateScriptControls()
{
@ -440,6 +449,8 @@ namespace CodeImp.DoomBuilder.Windows
if(!preventchanges)
{
MakeUndo(); //mxd
// mxd. Apply action's or thing's default arguments
if(showaction != 0 || thinginfo != null)
{
@ -477,7 +488,7 @@ namespace CodeImp.DoomBuilder.Windows
preventchanges = true;
anglecontrol.Angle = angle.GetResult(GZBuilder.Controls.AngleControl.NO_ANGLE);
preventchanges = false;
UpdateAngle(); //mxd
if(!preventmapchange) ApplyAngleChange(); //mxd
}
//mxd. Angle control clicked
@ -485,7 +496,7 @@ namespace CodeImp.DoomBuilder.Windows
{
if(preventchanges) return;
angle.Text = anglecontrol.Angle.ToString();
UpdateAngle();
if(!preventmapchange) ApplyAngleChange();
}
private void pitch_WhenTextChanged(object sender, EventArgs e)
@ -495,14 +506,14 @@ namespace CodeImp.DoomBuilder.Windows
preventchanges = true;
pitchControl.Angle = (p == GZBuilder.Controls.AngleControl.NO_ANGLE ? p : p + 90);
preventchanges = false;
UpdatePitch();
if(!preventmapchange) ApplyPitchChange();
}
private void pitchControl_AngleChanged(object sender, EventArgs e)
{
if(preventchanges) return;
pitch.Text = (General.ClampAngle(pitchControl.Angle - 90)).ToString();
UpdatePitch();
if(!preventmapchange) ApplyPitchChange();
}
private void roll_WhenTextChanged(object sender, EventArgs e)
@ -512,19 +523,22 @@ namespace CodeImp.DoomBuilder.Windows
preventchanges = true;
rollControl.Angle = (r == GZBuilder.Controls.AngleControl.NO_ANGLE ? r : r + 90);
preventchanges = false;
UpdateRoll();
if(!preventmapchange) ApplyRollChange();
}
private void rollControl_AngleChanged(object sender, EventArgs e)
{
if(preventchanges) return;
roll.Text = (General.ClampAngle(rollControl.Angle - 90)).ToString();
UpdateRoll();
if(!preventmapchange) ApplyRollChange();
}
// Apply clicked
private void apply_Click(object sender, EventArgs e)
{
// Make Undo
MakeUndo(); //mxd
List<string> defaultflags = new List<string>();
// Verify the tag
@ -664,8 +678,8 @@ namespace CodeImp.DoomBuilder.Windows
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
//mxd. perform undo
General.Map.UndoRedo.WithdrawUndo();
//mxd. Perform undo?
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// Be gone
this.DialogResult = DialogResult.Cancel;
@ -685,6 +699,8 @@ namespace CodeImp.DoomBuilder.Windows
private void cbAbsoluteHeight_CheckedChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
useAbsoluteHeight = cbAbsoluteHeight.Checked;
zlabel.Text = useAbsoluteHeight ? "Abs. Z:" : "Z:";
@ -737,11 +753,12 @@ namespace CodeImp.DoomBuilder.Windows
private void posX_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
// Update values
foreach(Thing t in things)
t.Move(new Vector2D(posX.GetResultFloat(thingProps[i++].X), t.Position.y));
t.Move(new Vector2D(posX.GetResultFloat(thingprops[i++].X), t.Position.y));
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
@ -750,11 +767,12 @@ namespace CodeImp.DoomBuilder.Windows
private void posY_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
// Update values
foreach(Thing t in things)
t.Move(new Vector2D(t.Position.x, posY.GetResultFloat(thingProps[i++].Y)));
t.Move(new Vector2D(t.Position.x, posY.GetResultFloat(thingprops[i++].Y)));
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
@ -763,20 +781,21 @@ namespace CodeImp.DoomBuilder.Windows
private void posZ_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
if(string.IsNullOrEmpty(posZ.Text))
{
// Restore values
foreach(Thing t in things)
t.Move(new Vector3D(t.Position.x, t.Position.y, thingProps[i++].Z));
t.Move(new Vector3D(t.Position.x, t.Position.y, thingprops[i++].Z));
}
else
{
// Update values
foreach(Thing t in things)
{
float z = posZ.GetResultFloat(thingProps[i++].Z);
float z = posZ.GetResultFloat(thingprops[i++].Z);
if(useAbsoluteHeight && !posZ.CheckIsRelative() && t.Sector != null)
z -= t.Sector.FloorHeight;
t.Move(new Vector3D(t.Position.x, t.Position.y, z));
@ -789,13 +808,14 @@ namespace CodeImp.DoomBuilder.Windows
private void scale_OnValuesChanged(object sender, EventArgs e)
{
if (preventchanges) return;
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
foreach (Thing t in things)
{
float sx = scale.GetValue1(thingProps[i].ScaleX);
float sy = scale.GetValue2(thingProps[i].ScaleY);
float sx = scale.GetValue1(thingprops[i].ScaleX);
float sy = scale.GetValue2(thingprops[i].ScaleY);
t.SetScale((sx == 0 ? 1.0f : sx), (sy == 0 ? 1.0f : sy));
i++;
}
@ -819,6 +839,8 @@ namespace CodeImp.DoomBuilder.Windows
|| (thingtype.GetResult(0) > General.Map.FormatInterface.MaxThingType))
return;
MakeUndo(); //mxd
foreach(Thing t in things)
{
//Set type
@ -833,61 +855,64 @@ namespace CodeImp.DoomBuilder.Windows
}
//mxd
private void UpdateAngle()
private void ApplyAngleChange()
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if(string.IsNullOrEmpty(angle.Text))
{
foreach(Thing t in things) t.Rotate(thingProps[i++].AngleDoom);
foreach(Thing t in things) t.Rotate(thingprops[i++].AngleDoom);
}
else //update values
{
foreach(Thing t in things)
t.Rotate(angle.GetResult(thingProps[i++].AngleDoom));
t.Rotate(angle.GetResult(thingprops[i++].AngleDoom));
}
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void UpdatePitch()
private void ApplyPitchChange()
{
if (preventchanges) return;
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if (string.IsNullOrEmpty(pitch.Text))
{
foreach (Thing t in things) t.SetPitch(thingProps[i++].Pitch);
foreach (Thing t in things) t.SetPitch(thingprops[i++].Pitch);
}
else //update values
{
foreach (Thing t in things)
t.SetPitch(pitch.GetResult(thingProps[i++].Pitch));
t.SetPitch(pitch.GetResult(thingprops[i++].Pitch));
}
General.Map.IsChanged = true;
if (OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
//mxd
private void UpdateRoll()
private void ApplyRollChange()
{
if (preventchanges) return;
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if (string.IsNullOrEmpty(roll.Text))
{
foreach (Thing t in things) t.SetRoll(thingProps[i++].Roll);
foreach (Thing t in things) t.SetRoll(thingprops[i++].Roll);
}
else //update values
{
foreach (Thing t in things)
t.SetRoll(roll.GetResult(thingProps[i++].Roll));
t.SetRoll(roll.GetResult(thingprops[i++].Roll));
}
General.Map.IsChanged = true;

View file

@ -44,8 +44,9 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Variables
private ICollection<Vertex> vertices;
private bool blockUpdate; //mxd
private List<VertexProperties> vertexProps; //mxd
private bool preventchanges; //mxd
private bool undocreated; //mxd
private List<VertexProperties> vertexprops; //mxd
//mxd. Window setup stuff
private static Point location = Point.Empty;
@ -53,10 +54,10 @@ namespace CodeImp.DoomBuilder.Windows
private struct VertexProperties //mxd
{
public float X;
public float Y;
public float ZCeiling;
public float ZFloor;
public readonly float X;
public readonly float Y;
public readonly float ZCeiling;
public readonly float ZFloor;
public VertexProperties(Vertex v)
{
@ -124,17 +125,12 @@ namespace CodeImp.DoomBuilder.Windows
// This sets up the form to edit the given vertices
public void Setup(ICollection<Vertex> vertices, bool allowPositionChange)
{
blockUpdate = true; //mxd
preventchanges = true; //mxd
// Keep this list
this.vertices = vertices;
if(vertices.Count > 1) this.Text = "Edit Vertices (" + vertices.Count + ")";
vertexProps = new List<VertexProperties>(); //mxd
//mxd. Make undo
string undodesc = "vertex";
if(vertices.Count > 1) undodesc = vertices.Count + " vertices";
General.Map.UndoRedo.CreateUndo("Edit " + undodesc);
vertexprops = new List<VertexProperties>(); //mxd
////////////////////////////////////////////////////////////////////////
// Set all options to the first vertex properties
@ -167,13 +163,13 @@ namespace CodeImp.DoomBuilder.Windows
if(positiony.Text != v.Position.y.ToString()) positiony.Text = "";
// Custom fields
if(General.Map.FormatInterface.HasCustomFields) { //mxd
v.Fields.BeforeFieldsChange();//mxd
if(General.Map.FormatInterface.HasCustomFields)
{
fieldslist.SetValues(v.Fields, false);
}
//mxd. Store initial properties
vertexProps.Add(new VertexProperties(v));
vertexprops.Add(new VertexProperties(v));
}
//mxd. Height offsets
@ -192,7 +188,22 @@ namespace CodeImp.DoomBuilder.Windows
}
}
blockUpdate = false; //mxd
preventchanges = false; //mxd
}
//mxd
private void MakeUndo()
{
if(undocreated) return;
undocreated = true;
//mxd. Make undo
General.Map.UndoRedo.CreateUndo("Edit " + (vertices.Count > 1 ? vertices.Count + " vertices" : "vertex"));
if(General.Map.FormatInterface.HasCustomFields)
{
foreach(Vertex v in vertices) v.Fields.BeforeFieldsChange();
}
}
#endregion
@ -201,19 +212,20 @@ namespace CodeImp.DoomBuilder.Windows
private void positionx_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo();
int i = 0;
//restore values
if(string.IsNullOrEmpty(positionx.Text))
{
// Apply position
foreach(Vertex v in vertices) v.Move(new Vector2D(vertexProps[i++].X, v.Position.y));
foreach(Vertex v in vertices) v.Move(new Vector2D(vertexprops[i++].X, v.Position.y));
}
else //update values
{
// Verify the coordinates
float px = positionx.GetResultFloat(vertexProps[i].X);
float px = positionx.GetResultFloat(vertexprops[i].X);
if(px < General.Map.FormatInterface.MinCoordinate)
{
positionx.Text = General.Map.FormatInterface.MinCoordinate.ToString();
@ -236,19 +248,20 @@ namespace CodeImp.DoomBuilder.Windows
private void positiony_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo();
int i = 0;
//restore values
if(string.IsNullOrEmpty(positiony.Text))
{
// Apply position
foreach(Vertex v in vertices) v.Move(new Vector2D(v.Position.x, vertexProps[i++].Y));
foreach(Vertex v in vertices) v.Move(new Vector2D(v.Position.x, vertexprops[i++].Y));
}
else //update values
{
// Verify the coordinates
float py = positiony.GetResultFloat(vertexProps[i].Y);
float py = positiony.GetResultFloat(vertexprops[i].Y);
if(py < General.Map.FormatInterface.MinCoordinate)
{
positiony.Text = General.Map.FormatInterface.MinCoordinate.ToString();
@ -271,13 +284,14 @@ namespace CodeImp.DoomBuilder.Windows
private void zceiling_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo();
int i = 0;
//restore values
if(string.IsNullOrEmpty(zceiling.Text))
{
foreach(Vertex v in vertices) v.ZCeiling = vertexProps[i++].ZCeiling;
foreach(Vertex v in vertices) v.ZCeiling = vertexprops[i++].ZCeiling;
}
else if(zceiling.Text == CLEAR_VALUE) //clear values
@ -288,7 +302,7 @@ namespace CodeImp.DoomBuilder.Windows
else //update values
{
foreach(Vertex v in vertices)
v.ZCeiling = zceiling.GetResultFloat(vertexProps[i++].ZCeiling);
v.ZCeiling = zceiling.GetResultFloat(vertexprops[i++].ZCeiling);
}
General.Map.IsChanged = true;
@ -297,14 +311,15 @@ namespace CodeImp.DoomBuilder.Windows
private void zfloor_WhenTextChanged(object sender, EventArgs e)
{
if(blockUpdate) return;
if(preventchanges) return;
MakeUndo();
int i = 0;
//restore values
if(string.IsNullOrEmpty(zfloor.Text))
{
foreach(Vertex v in vertices)
v.ZFloor = vertexProps[i++].ZFloor;
v.ZFloor = vertexprops[i++].ZFloor;
}
else if(zfloor.Text == CLEAR_VALUE) //clear values
@ -314,7 +329,7 @@ namespace CodeImp.DoomBuilder.Windows
else //update values
{
foreach(Vertex v in vertices)
v.ZFloor = zfloor.GetResultFloat(vertexProps[i++].ZFloor);
v.ZFloor = zfloor.GetResultFloat(vertexprops[i++].ZFloor);
}
General.Map.IsChanged = true;
@ -340,7 +355,10 @@ namespace CodeImp.DoomBuilder.Windows
// OK clicked
private void apply_Click(object sender, EventArgs e)
{
//apply custom fields
//mxd. Make undo if required
MakeUndo();
// Apply custom fields
if(General.Map.FormatInterface.HasCustomFields)
{
foreach(Vertex v in vertices) fieldslist.Apply(v.Fields); //mxd
@ -357,8 +375,8 @@ namespace CodeImp.DoomBuilder.Windows
// Cancel clicked
private void cancel_Click(object sender, EventArgs e)
{
//mxd. perform undo
General.Map.UndoRedo.WithdrawUndo();
//mxd. Perform undo if required
if(undocreated) General.Map.UndoRedo.WithdrawUndo();
// And close
this.DialogResult = DialogResult.Cancel;