mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-19 15:01:11 +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\VertexBuffer.cs" />
|
||||||
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
||||||
<Compile Include="VisualModes\VisualSlope.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">
|
<Compile Include="Windows\PreAndPostCommandsForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -266,6 +266,9 @@
|
||||||
<Compile Include="Rendering\VertexBuffer.cs" />
|
<Compile Include="Rendering\VertexBuffer.cs" />
|
||||||
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
<Compile Include="Rendering\VisualSlopeHandle.cs" />
|
||||||
<Compile Include="VisualModes\VisualSlope.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">
|
<Compile Include="Windows\PreAndPostCommandsForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</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
|
namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
internal partial class LinedefEditForm : DelayedForm
|
internal partial class LinedefEditForm : DelayedForm, ILinedefEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
// This sets up the form to edit the given lines
|
// 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;
|
preventchanges = true;
|
||||||
oldmapischanged = General.Map.IsChanged;
|
oldmapischanged = General.Map.IsChanged;
|
||||||
|
|
|
@ -29,7 +29,7 @@ using CodeImp.DoomBuilder.Types;
|
||||||
|
|
||||||
namespace CodeImp.DoomBuilder.Windows
|
namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
internal partial class LinedefEditFormUDMF : DelayedForm
|
internal partial class LinedefEditFormUDMF : DelayedForm, ILinedefEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
|
|
@ -4144,12 +4144,8 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
// This shows the dialog to edit lines
|
// This shows the dialog to edit lines
|
||||||
public DialogResult ShowEditLinedefs(ICollection<Linedef> lines, bool selectfront, bool selectback)
|
public DialogResult ShowEditLinedefs(ICollection<Linedef> lines, bool selectfront, bool selectback)
|
||||||
{
|
{
|
||||||
DialogResult result;
|
|
||||||
|
|
||||||
// Show line edit dialog
|
// Show line edit dialog
|
||||||
if(General.Map.UDMF) //mxd
|
ILinedefEditForm f = GetLinedefEditForm(selectfront, selectback);
|
||||||
{
|
|
||||||
LinedefEditFormUDMF f = new LinedefEditFormUDMF(selectfront, selectback);
|
|
||||||
DisableProcessing(); //mxd
|
DisableProcessing(); //mxd
|
||||||
#if NO_WIN32
|
#if NO_WIN32
|
||||||
BreakExclusiveMouseInput();
|
BreakExclusiveMouseInput();
|
||||||
|
@ -4164,44 +4160,30 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
#endif
|
#endif
|
||||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||||
editformopen = true; //mxd
|
editformopen = true; //mxd
|
||||||
result = f.ShowDialog(this);
|
DialogResult result = f.ShowDialog(this);
|
||||||
editformopen = false; //mxd
|
editformopen = false; //mxd
|
||||||
f.Dispose();
|
f.Dispose();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILinedefEditForm GetLinedefEditForm(bool selectfront, bool selectback)
|
||||||
|
{
|
||||||
|
if (General.Map.UDMF)
|
||||||
|
{
|
||||||
|
return new LinedefEditFormUDMF(selectfront, selectback);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LinedefEditForm f = new LinedefEditForm();
|
return 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 result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This shows the dialog to edit sectors
|
// This shows the dialog to edit sectors
|
||||||
public DialogResult ShowEditSectors(ICollection<Sector> sectors)
|
public DialogResult ShowEditSectors(ICollection<Sector> sectors)
|
||||||
{
|
{
|
||||||
DialogResult result;
|
|
||||||
|
|
||||||
// Show sector edit dialog
|
// Show sector edit dialog
|
||||||
if(General.Map.UDMF) //mxd
|
ISectorEditForm f = GetSectorEditForm();
|
||||||
{
|
|
||||||
SectorEditFormUDMF f = new SectorEditFormUDMF();
|
|
||||||
DisableProcessing(); //mxd
|
DisableProcessing(); //mxd
|
||||||
#if NO_WIN32
|
#if NO_WIN32
|
||||||
BreakExclusiveMouseInput();
|
BreakExclusiveMouseInput();
|
||||||
|
@ -4216,44 +4198,30 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
#endif
|
#endif
|
||||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||||
editformopen = true; //mxd
|
editformopen = true; //mxd
|
||||||
result = f.ShowDialog(this);
|
DialogResult result = f.ShowDialog(this);
|
||||||
editformopen = false; //mxd
|
editformopen = false; //mxd
|
||||||
f.Dispose();
|
f.Dispose();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ISectorEditForm GetSectorEditForm()
|
||||||
|
{
|
||||||
|
if (General.Map.UDMF)
|
||||||
|
{
|
||||||
|
return new SectorEditFormUDMF();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SectorEditForm f = new SectorEditForm();
|
return 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This shows the dialog to edit things
|
// This shows the dialog to edit things
|
||||||
public DialogResult ShowEditThings(ICollection<Thing> things)
|
public DialogResult ShowEditThings(ICollection<Thing> things)
|
||||||
{
|
{
|
||||||
DialogResult result;
|
|
||||||
|
|
||||||
// Show thing edit dialog
|
// Show thing edit dialog
|
||||||
if(General.Map.UDMF)
|
IThingEditForm f = GetThingEditForm();
|
||||||
{
|
|
||||||
ThingEditFormUDMF f = new ThingEditFormUDMF();
|
|
||||||
DisableProcessing(); //mxd
|
DisableProcessing(); //mxd
|
||||||
#if NO_WIN32
|
#if NO_WIN32
|
||||||
BreakExclusiveMouseInput();
|
BreakExclusiveMouseInput();
|
||||||
|
@ -4268,33 +4236,23 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
#endif
|
#endif
|
||||||
f.OnValuesChanged += EditForm_OnValuesChanged;
|
f.OnValuesChanged += EditForm_OnValuesChanged;
|
||||||
editformopen = true; //mxd
|
editformopen = true; //mxd
|
||||||
result = f.ShowDialog(this);
|
DialogResult result = f.ShowDialog(this);
|
||||||
editformopen = false; //mxd
|
editformopen = false; //mxd
|
||||||
f.Dispose();
|
f.Dispose();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IThingEditForm GetThingEditForm()
|
||||||
|
{
|
||||||
|
if (General.Map.UDMF)
|
||||||
|
{
|
||||||
|
return new ThingEditFormUDMF();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ThingEditForm f = new ThingEditForm();
|
return 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 result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
|
|
@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.Types;
|
||||||
|
|
||||||
namespace CodeImp.DoomBuilder.Windows
|
namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
internal partial class SectorEditForm : DelayedForm
|
internal partial class SectorEditForm : DelayedForm, ISectorEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ using CodeImp.DoomBuilder.Types;
|
||||||
|
|
||||||
namespace CodeImp.DoomBuilder.Windows
|
namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
internal partial class SectorEditFormUDMF : DelayedForm
|
internal partial class SectorEditFormUDMF : DelayedForm, ISectorEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dialog window that allows viewing and editing of Thing properties.
|
/// Dialog window that allows viewing and editing of Thing properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class ThingEditForm : DelayedForm
|
internal partial class ThingEditForm : DelayedForm, IThingEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dialog window that allows viewing and editing of Thing properties.
|
/// Dialog window that allows viewing and editing of Thing properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class ThingEditFormUDMF : DelayedForm
|
internal partial class ThingEditFormUDMF : DelayedForm, IThingEditForm
|
||||||
{
|
{
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue