mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-19 06:51:09 +00:00
Refactor the code that open edit forms, to make it easier to add different forms in the future
This commit is contained in:
parent
5ed59088fc
commit
51d56016f3
12 changed files with 169 additions and 136 deletions
|
@ -274,6 +274,9 @@
|
|||
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
||||
<Compile Include="VisualModes\VisualSlope.cs" />
|
||||
<Compile Include="Windows\ILinedefEditForm.cs" />
|
||||
<Compile Include="Windows\ISectorEditForm.cs" />
|
||||
<Compile Include="Windows\IThingEditForm.cs" />
|
||||
<Compile Include="Windows\PreAndPostCommandsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -266,6 +266,9 @@
|
|||
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
||||
<Compile Include="VisualModes\VisualSlope.cs" />
|
||||
<Compile Include="Windows\ILinedefEditForm.cs" />
|
||||
<Compile Include="Windows\ISectorEditForm.cs" />
|
||||
<Compile Include="Windows\IThingEditForm.cs" />
|
||||
<Compile Include="Windows\PreAndPostCommandsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
23
Source/Core/Windows/ILinedefEditForm.cs
Normal file
23
Source/Core/Windows/ILinedefEditForm.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public interface ILinedefEditForm
|
||||
{
|
||||
//Events
|
||||
event EventHandler OnValuesChanged;
|
||||
event EventHandler Closed;
|
||||
|
||||
// Methods
|
||||
void Setup(ICollection<Linedef> lines, bool selectfront, bool selectback);
|
||||
DialogResult ShowDialog(IWin32Window owner);
|
||||
void Dispose();
|
||||
}
|
||||
}
|
23
Source/Core/Windows/ISectorEditForm.cs
Normal file
23
Source/Core/Windows/ISectorEditForm.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public interface ISectorEditForm
|
||||
{
|
||||
//Events
|
||||
event EventHandler OnValuesChanged;
|
||||
event EventHandler Closed;
|
||||
|
||||
// Methods
|
||||
void Setup(ICollection<Sector> sectors);
|
||||
DialogResult ShowDialog(IWin32Window owner);
|
||||
void Dispose();
|
||||
}
|
||||
}
|
23
Source/Core/Windows/IThingEditForm.cs
Normal file
23
Source/Core/Windows/IThingEditForm.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public interface IThingEditForm
|
||||
{
|
||||
//Events
|
||||
event EventHandler OnValuesChanged;
|
||||
event EventHandler Closed;
|
||||
|
||||
// Methods
|
||||
void Setup(ICollection<Thing> things);
|
||||
DialogResult ShowDialog(IWin32Window owner);
|
||||
void Dispose();
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ using CodeImp.DoomBuilder.Types;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
internal partial class LinedefEditForm : DelayedForm
|
||||
internal partial class LinedefEditForm : DelayedForm, ILinedefEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
#region ================== Methods
|
||||
|
||||
// This sets up the form to edit the given lines
|
||||
public void Setup(ICollection<Linedef> lines)
|
||||
public void Setup(ICollection<Linedef> lines, bool selectfront, bool selectback)
|
||||
{
|
||||
preventchanges = true;
|
||||
oldmapischanged = General.Map.IsChanged;
|
||||
|
|
|
@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Types;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
internal partial class LinedefEditFormUDMF : DelayedForm
|
||||
internal partial class LinedefEditFormUDMF : DelayedForm, ILinedefEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
|
|
@ -4144,159 +4144,117 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// This shows the dialog to edit lines
|
||||
public DialogResult ShowEditLinedefs(ICollection<Linedef> lines, bool selectfront, bool selectback)
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
// Show line edit dialog
|
||||
if(General.Map.UDMF) //mxd
|
||||
ILinedefEditForm f = GetLinedefEditForm(selectfront, selectback);
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(lines, selectfront, selectback);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing();
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
DialogResult result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private ILinedefEditForm GetLinedefEditForm(bool selectfront, bool selectback)
|
||||
{
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
LinedefEditFormUDMF f = new LinedefEditFormUDMF(selectfront, selectback);
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(lines, selectfront, selectback);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing();
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
return new LinedefEditFormUDMF(selectfront, selectback);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinedefEditForm f = new LinedefEditForm();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(lines);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing();
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
return new LinedefEditForm();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// This shows the dialog to edit sectors
|
||||
public DialogResult ShowEditSectors(ICollection<Sector> sectors)
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
// Show sector edit dialog
|
||||
if(General.Map.UDMF) //mxd
|
||||
{
|
||||
SectorEditFormUDMF f = new SectorEditFormUDMF();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(sectors);
|
||||
#if !NO_WIN32
|
||||
ISectorEditForm f = GetSectorEditForm();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
SectorEditForm f = new SectorEditForm();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(sectors);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
f.Setup(sectors);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
DialogResult result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// This shows the dialog to edit things
|
||||
public DialogResult ShowEditThings(ICollection<Thing> things)
|
||||
private ISectorEditForm GetSectorEditForm()
|
||||
{
|
||||
DialogResult result;
|
||||
|
||||
// Show thing edit dialog
|
||||
if(General.Map.UDMF)
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
ThingEditFormUDMF f = new ThingEditFormUDMF();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(things);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ThingEditForm f = new ThingEditForm();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(things);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
return new SectorEditFormUDMF();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SectorEditForm();
|
||||
}
|
||||
}
|
||||
|
||||
// This shows the dialog to edit things
|
||||
public DialogResult ShowEditThings(ICollection<Thing> things)
|
||||
{
|
||||
// Show thing edit dialog
|
||||
IThingEditForm f = GetThingEditForm();
|
||||
DisableProcessing(); //mxd
|
||||
#if NO_WIN32
|
||||
BreakExclusiveMouseInput();
|
||||
f.Closed += (object sender, EventArgs e) => {
|
||||
ResumeExclusiveMouseInput();
|
||||
EnableProcessing(); //mxd
|
||||
};
|
||||
#endif
|
||||
f.Setup(things);
|
||||
#if !NO_WIN32
|
||||
EnableProcessing(); //mxd
|
||||
#endif
|
||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||
editformopen = true; //mxd
|
||||
DialogResult result = f.ShowDialog(this);
|
||||
editformopen = false; //mxd
|
||||
f.Dispose();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private IThingEditForm GetThingEditForm()
|
||||
{
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
return new ThingEditFormUDMF();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ThingEditForm();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void EditForm_OnValuesChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.Types;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
internal partial class SectorEditForm : DelayedForm
|
||||
internal partial class SectorEditForm : DelayedForm, ISectorEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ using CodeImp.DoomBuilder.Types;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
internal partial class SectorEditFormUDMF : DelayedForm
|
||||
internal partial class SectorEditFormUDMF : DelayedForm, ISectorEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
/// <summary>
|
||||
/// Dialog window that allows viewing and editing of Thing properties.
|
||||
/// </summary>
|
||||
internal partial class ThingEditForm : DelayedForm
|
||||
internal partial class ThingEditForm : DelayedForm, IThingEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
/// <summary>
|
||||
/// Dialog window that allows viewing and editing of Thing properties.
|
||||
/// </summary>
|
||||
internal partial class ThingEditFormUDMF : DelayedForm
|
||||
internal partial class ThingEditFormUDMF : DelayedForm, IThingEditForm
|
||||
{
|
||||
#region ================== Events
|
||||
|
||||
|
|
Loading…
Reference in a new issue