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 System.Collections.Generic;
|
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
|
{
|
|
|
|
|
public class ResultVertexOverlappingLine : ErrorResult
|
|
|
|
|
{
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
2014-09-12 21:08:11 +00:00
|
|
|
|
private readonly Linedef line;
|
|
|
|
|
private readonly Vertex vertex;
|
2014-02-07 09:10:55 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
public override int Buttons { get { return 1; } }
|
|
|
|
|
public override string Button1Text { get { return "Split Linedef"; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ================== Constructor / Destructor
|
|
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
|
public ResultVertexOverlappingLine(Vertex v, Linedef l)
|
|
|
|
|
{
|
|
|
|
|
// Initialize
|
2014-09-12 21:08:11 +00:00
|
|
|
|
line = l;
|
|
|
|
|
vertex = v;
|
|
|
|
|
viewobjects.Add(l);
|
|
|
|
|
viewobjects.Add(v);
|
|
|
|
|
hidden = (l.IgnoredErrorChecks.Contains(this.GetType()) && v.IgnoredErrorChecks.Contains(this.GetType())); //mxd
|
|
|
|
|
description = "This vertex overlaps this linedef without splitting it.";
|
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)
|
|
|
|
|
{
|
|
|
|
|
vertex.IgnoredErrorChecks.Add(t);
|
|
|
|
|
line.IgnoredErrorChecks.Add(t);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(vertex.IgnoredErrorChecks.Contains(t)) vertex.IgnoredErrorChecks.Remove(t);
|
|
|
|
|
if(line.IgnoredErrorChecks.Contains(t)) line.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 "Vertex " + vertex.Index + " overlaps line " + line.Index + " without splitting it";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rendering
|
2014-09-12 21:08:11 +00:00
|
|
|
|
public override void PlotSelection(IRenderer2D renderer)
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
renderer.PlotLinedef(line, General.Colors.Selection);
|
|
|
|
|
renderer.PlotVertex(line.Start, ColorCollection.VERTICES);
|
|
|
|
|
renderer.PlotVertex(line.End, ColorCollection.VERTICES);
|
|
|
|
|
|
|
|
|
|
renderer.PlotVertex(vertex, 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("Split Linedef");
|
|
|
|
|
line.Split(vertex);
|
|
|
|
|
|
|
|
|
|
//check that we don't have duplicate lines
|
|
|
|
|
List<Linedef> lines = new List<Linedef>(vertex.Linedefs);
|
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
|
for(int i = 0; i < lines.Count - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
for(int c = i + 1; c < lines.Count; c++)
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
if( (lines[i].Start == lines[c].Start && lines[i].End == lines[c].End) ||
|
2014-12-03 23:15:26 +00:00
|
|
|
|
(lines[i].Start == lines[c].End && lines[i].End == lines[c].Start))
|
|
|
|
|
{
|
2014-02-07 09:10:55 +00:00
|
|
|
|
lines[c].Join(lines[i]);
|
2016-05-20 15:04:00 +00:00
|
|
|
|
|
|
|
|
|
//mxd. Textures may've become unused
|
|
|
|
|
if(lines[c].Front != null) lines[c].Front.RemoveUnneededTextures(lines[c].Back != null, false, true);
|
|
|
|
|
if(lines[c].Back != null) lines[c].Back.RemoveUnneededTextures(lines[c].Front != null, false, true);
|
2014-02-07 09:10:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
General.Map.Map.Update();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|