2014-02-07 09:10:55 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
2014-09-12 21:08:11 +00:00
|
|
|
|
using System;
|
2014-02-07 09:10:55 +00:00
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
|
{
|
|
|
|
|
public class ResultVertexOverlappingVertex : ErrorResult
|
|
|
|
|
{
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2014-09-12 21:08:11 +00:00
|
|
|
|
private readonly Vertex vertex1;
|
|
|
|
|
private readonly Vertex vertex2;
|
2014-02-07 09:10:55 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
public override int Buttons { get { return 1; } }
|
|
|
|
|
public override string Button1Text { get { return "Merge Vertices"; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
|
public ResultVertexOverlappingVertex(Vertex v1, Vertex v2)
|
|
|
|
|
{
|
|
|
|
|
// Initialize
|
2014-09-12 21:08:11 +00:00
|
|
|
|
vertex1 = v1;
|
|
|
|
|
vertex2 = v2;
|
|
|
|
|
viewobjects.Add(v1);
|
|
|
|
|
viewobjects.Add(v2);
|
|
|
|
|
hidden = (v1.IgnoredErrorChecks.Contains(this.GetType()) && v2.IgnoredErrorChecks.Contains(this.GetType())); //mxd
|
|
|
|
|
description = "These vertices have the same position.";
|
2014-02-07 09:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
2014-09-12 21:08:11 +00:00
|
|
|
|
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
|
|
|
|
internal override void Hide(bool hide)
|
|
|
|
|
{
|
|
|
|
|
hidden = hide;
|
|
|
|
|
Type t = this.GetType();
|
|
|
|
|
if(hide)
|
|
|
|
|
{
|
|
|
|
|
vertex1.IgnoredErrorChecks.Add(t);
|
|
|
|
|
vertex2.IgnoredErrorChecks.Add(t);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(vertex1.IgnoredErrorChecks.Contains(t)) vertex1.IgnoredErrorChecks.Remove(t);
|
|
|
|
|
if(vertex2.IgnoredErrorChecks.Contains(t)) vertex2.IgnoredErrorChecks.Remove(t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-07 09:10:55 +00:00
|
|
|
|
// This must return the string that is displayed in the listbox
|
2014-09-12 21:08:11 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
return "Vertices " + vertex1.Index + " and " + vertex2.Index + " have the same position";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rendering
|
2014-09-12 21:08:11 +00:00
|
|
|
|
public override void PlotSelection(IRenderer2D renderer)
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
renderer.PlotVertex(vertex1, ColorCollection.SELECTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fix by splitting the line
|
2014-09-12 21:08:11 +00:00
|
|
|
|
public override bool Button1Click(bool batchMode)
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
if(!batchMode) General.Map.UndoRedo.CreateUndo("Merge vertices");
|
|
|
|
|
vertex2.Join(vertex1);
|
|
|
|
|
General.Map.Map.Update();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|