Added unknown things check to Error Checker

This commit is contained in:
MaxED 2012-08-29 10:09:02 +00:00
parent a45b1dd3b9
commit 879cbacd93
3 changed files with 86 additions and 0 deletions

View file

@ -39,6 +39,7 @@
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
@ -244,11 +245,13 @@
<Compile Include="ErrorChecks\CheckMissingTextures.cs" /> <Compile Include="ErrorChecks\CheckMissingTextures.cs" />
<Compile Include="ErrorChecks\CheckUnknownFlats.cs" /> <Compile Include="ErrorChecks\CheckUnknownFlats.cs" />
<Compile Include="ErrorChecks\CheckUnknownTextures.cs" /> <Compile Include="ErrorChecks\CheckUnknownTextures.cs" />
<Compile Include="ErrorChecks\CheckUnknownThings.cs" />
<Compile Include="ErrorChecks\ResultNoErrors.cs" /> <Compile Include="ErrorChecks\ResultNoErrors.cs" />
<Compile Include="ErrorChecks\ResultStuckThingInThing.cs" /> <Compile Include="ErrorChecks\ResultStuckThingInThing.cs" />
<Compile Include="ErrorChecks\ResultTextureMissing.cs" /> <Compile Include="ErrorChecks\ResultTextureMissing.cs" />
<Compile Include="ErrorChecks\ResultUnknownFlat.cs" /> <Compile Include="ErrorChecks\ResultUnknownFlat.cs" />
<Compile Include="ErrorChecks\ResultUnknownTexture.cs" /> <Compile Include="ErrorChecks\ResultUnknownTexture.cs" />
<Compile Include="ErrorChecks\ResultUnknownThing.cs" />
<Compile Include="FindReplace\FindLinedefFlags.cs" /> <Compile Include="FindReplace\FindLinedefFlags.cs" />
<Compile Include="FindReplace\FindThingAngle.cs" /> <Compile Include="FindReplace\FindThingAngle.cs" />
<Compile Include="FindReplace\FindAnyTextureFlat.cs" /> <Compile Include="FindReplace\FindAnyTextureFlat.cs" />

View file

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Config;
namespace CodeImp.DoomBuilder.BuilderModes.ErrorChecks {
[ErrorChecker("Check unknown things", true, 50)]
public class CheckUnknownThings : ErrorChecker {
private int PROGRESS_STEP = 1000;
// Constructor
public CheckUnknownThings() {
// Total progress is done when all things are checked
SetTotalProgress(General.Map.Map.Things.Count / PROGRESS_STEP);
}
// This runs the check
public override void Run() {
int progress = 0;
int stepprogress = 0;
// Go for all things
foreach (Thing t in General.Map.Map.Things) {
if (General.Map.Data.GetThingInfoEx(t.Type) == null)
SubmitResult(new ResultUnknownThing(t));
// 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);
}
}
}
}
}

View file

@ -0,0 +1,41 @@
using System;
//using System.Collections.Generic;
//using System.Text;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.BuilderModes.ErrorChecks {
public class ResultUnknownThing : ErrorResult {
public override int Buttons { get { return 1; } }
public override string Button1Text { get { return "Delete Thing"; } }
private Thing thing;
// Constructor
public ResultUnknownThing(Thing t) {
// Initialize
this.thing = t;
this.viewobjects.Add(t);
this.description = "This thing has unknown type (eg. it's not defined in DECORATE or current game configuration).";
}
// This must return the string that is displayed in the listbox
public override string ToString() {
return "Thing " + General.Map.Data.GetThingInfo(thing.Type).Index + " at " + thing.Position.x + ", " + thing.Position.y + " has unknown type.";
}
// Rendering
public override void RenderOverlaySelection(IRenderer2D renderer) {
renderer.RenderThing(thing, renderer.DetermineThingColor(thing), 1.0f);
}
// This removes the thing
public override bool Button1Click() {
General.Map.UndoRedo.CreateUndo("Delete thing");
thing.Dispose();
General.Map.IsChanged = true;
General.Map.ThingsFilter.Update();
return true;
}
}
}