mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Missing Activation map check (PR#260 by davidxn)
* Adding check for missing activations on lines that have an activation-requiring action * Adding skip check if the map isn't UDMF * Oops, typo in name of check
This commit is contained in:
parent
227a0402f4
commit
838d04e9c7
3 changed files with 177 additions and 0 deletions
|
@ -124,6 +124,7 @@
|
|||
<Compile Include="ClassicModes\FindReplaceMode.cs" />
|
||||
<Compile Include="ClassicModes\MakeSectorMode.cs" />
|
||||
<Compile Include="ErrorChecks\CheckClosedSectors.cs" />
|
||||
<Compile Include="ErrorChecks\CheckMissingActivations.cs" />
|
||||
<Compile Include="ErrorChecks\CheckOffGridVertices.cs" />
|
||||
<Compile Include="ErrorChecks\CheckStuckThings.cs" />
|
||||
<Compile Include="ErrorChecks\CheckLineReferences.cs" />
|
||||
|
@ -133,6 +134,7 @@
|
|||
<Compile Include="ErrorChecks\ResultLineNotDoubleSided.cs" />
|
||||
<Compile Include="ErrorChecks\ResultLineMissingFront.cs" />
|
||||
<Compile Include="ErrorChecks\ResultLineMissingSides.cs" />
|
||||
<Compile Include="ErrorChecks\ResultMissingActivation.cs" />
|
||||
<Compile Include="ErrorChecks\ResultOffGridVertex.cs" />
|
||||
<Compile Include="ErrorChecks\ResultSectorUnclosed.cs" />
|
||||
<Compile Include="ErrorChecks\ResultStuckThingInLine.cs" />
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[ErrorChecker("Check missing activations", true, 50)]
|
||||
public class CheckMissingActivations : ErrorChecker
|
||||
{
|
||||
private const int PROGRESS_STEP = 1000;
|
||||
|
||||
// Constructor
|
||||
public CheckMissingActivations()
|
||||
{
|
||||
// Total progress is done when all linedefs are checked
|
||||
SetTotalProgress(General.Map.Map.Linedefs.Count / PROGRESS_STEP);
|
||||
}
|
||||
|
||||
public override bool SkipCheck { get { return !General.Map.UDMF; } }
|
||||
|
||||
// This runs the check
|
||||
public override void Run()
|
||||
{
|
||||
int progress = 0;
|
||||
int stepprogress = 0;
|
||||
|
||||
//If this map isn't a UDMF then we can't reach a situation where activations are missing
|
||||
if (!General.Map.UDMF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Go for all vertices
|
||||
foreach (Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
int action = l.Action;
|
||||
Dictionary<string, bool> flags = l.GetFlags();
|
||||
bool hasActivation = false;
|
||||
if (action != 0
|
||||
&& General.Map.Config.LinedefActions.ContainsKey(action)
|
||||
&& General.Map.Config.LinedefActions[action].RequiresActivation)
|
||||
{
|
||||
foreach (LinedefActivateInfo ai in General.Map.Config.LinedefActivates)
|
||||
{
|
||||
if (flags.ContainsKey(ai.Key) && flags[ai.Key] == true)
|
||||
{
|
||||
hasActivation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasActivation)
|
||||
{
|
||||
SubmitResult(new ResultMissingActivation(l));
|
||||
}
|
||||
}
|
||||
|
||||
// Handle thread interruption
|
||||
try { Thread.Sleep(0); } catch (ThreadInterruptedException) { return; }
|
||||
|
||||
// We are making progress!
|
||||
if ((++progress / PROGRESS_STEP) > stepprogress)
|
||||
{
|
||||
stepprogress = (progress / PROGRESS_STEP);
|
||||
AddProgress(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultMissingActivation : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly Linedef line;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 1; } }
|
||||
public override string Button1Text { get { return "Edit Linedef"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public ResultMissingActivation(Linedef l)
|
||||
{
|
||||
// Initialize
|
||||
this.line = l;
|
||||
this.viewobjects.Add(l);
|
||||
this.hidden = l.IgnoredErrorChecks.Contains(this.GetType());
|
||||
this.description = "This linedef has an assigned action, but no way to activate it has been set.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
||||
internal override void Hide(bool hide)
|
||||
{
|
||||
hidden = hide;
|
||||
Type t = this.GetType();
|
||||
if (hide)
|
||||
{
|
||||
line.IgnoredErrorChecks.Add(t);
|
||||
}
|
||||
else if (line.IgnoredErrorChecks.Contains(t))
|
||||
{
|
||||
line.IgnoredErrorChecks.Remove(t);
|
||||
}
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
return "Linedef " + line.Index + " has an action with no activation";
|
||||
}
|
||||
|
||||
// Rendering
|
||||
public override void PlotSelection(IRenderer2D renderer)
|
||||
{
|
||||
renderer.PlotLinedef(line, General.Colors.Selection);
|
||||
renderer.PlotVertex(line.Start, ColorCollection.VERTICES);
|
||||
renderer.PlotVertex(line.End, ColorCollection.VERTICES);
|
||||
}
|
||||
|
||||
// Fix by prompting to edit the linedef
|
||||
public override bool Button1Click(bool batchMode)
|
||||
{
|
||||
if (!batchMode) General.Map.UndoRedo.CreateUndo("Edit linedef");
|
||||
|
||||
if (General.Interface.ShowEditLinedefs(new List<Linedef> { line }) == DialogResult.OK)
|
||||
{
|
||||
General.Map.Map.Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue