This commit is contained in:
codeimp 2008-10-23 22:01:07 +00:00
parent cc292c9c40
commit 27e05b7f1b
8 changed files with 116 additions and 49 deletions

View file

@ -76,6 +76,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnEngage();
renderer.SetPresentation(Presentation.Standard);
// Save selection as marks
General.Map.Map.ClearAllMarks(false);
General.Map.Map.MarkAllSelectedGeometry(true, false);
General.Map.Map.ClearAllSelected();
// Show toolbox window
BuilderPlug.Me.ErrorCheckForm.Show((Form)General.Interface);
}
@ -88,8 +93,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Hide object info
General.Interface.HideInfo();
// Restore selection
General.Map.Map.SelectMarkedGeometry(true, true);
General.Map.Map.ClearAllMarks(false);
// Hide toolbox window
BuilderPlug.Me.ErrorCheckForm.Hide();
BuilderPlug.Me.ErrorCheckForm.CloseWindow();
}
// This applies the curves and returns to the base mode
@ -118,7 +127,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(renderer.StartPlotter(true))
{
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
//if(selection != null) selection.PlotSelection(renderer);
if(selection != null) selection.PlotSelection(renderer);
renderer.PlotVerticesSet(General.Map.Map.Vertices);
renderer.Finish();
}
@ -127,14 +136,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(renderer.StartThings(true))
{
renderer.RenderThingSet(General.Map.Map.Things, 1.0f);
//if(selection != null) selection.RenderThingsSelection(renderer);
if(selection != null) selection.RenderThingsSelection(renderer);
renderer.Finish();
}
// Render overlay
if(renderer.StartOverlay(true))
{
//if(selection != null) selection.RenderOverlaySelection(renderer);
if(selection != null) selection.RenderOverlaySelection(renderer);
renderer.Finish();
}

View file

@ -61,32 +61,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Go for all the things
foreach(Thing t in General.Map.Map.Things)
{
// Make square coordinates from thing
Vector2D lt = new Vector2D(t.Position.x - t.Size, t.Position.y - t.Size);
Vector2D rb = new Vector2D(t.Position.x + t.Size, t.Position.y + t.Size);
// Go for all the lines to see if this thing is stucked
ThingTypeInfo info = General.Map.Config.GetThingInfo(t.Type);
bool stucked = false;
foreach(Linedef l in General.Map.Map.Linedefs)
// Check this thing for getting stucked?
if( (info.ErrorCheck == ThingTypeInfo.THING_ERROR_INSIDE_STUCKED) &&
(info.Blocking > ThingTypeInfo.THING_BLOCKING_NONE))
{
// Test only single-sided lines
if(l.Back == null)
// Make square coordinates from thing
Vector2D lt = new Vector2D(t.Position.x - t.Size, t.Position.y - t.Size);
Vector2D rb = new Vector2D(t.Position.x + t.Size, t.Position.y + t.Size);
// Go for all the lines to see if this thing is stucked
foreach(Linedef l in General.Map.Map.Linedefs)
{
// Test if line ends are inside the thing
if(PointInRect(lt, rb, l.Start.Position) ||
PointInRect(lt, rb, l.End.Position))
// Test only single-sided lines
if(l.Back == null)
{
// Thing stucked in line!
stucked = true;
}
// Test if the line intersects the square
else if(Line2D.GetIntersection(l.Start.Position, l.End.Position, lt.x, lt.y, rb.x, lt.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, rb.x, lt.y, rb.x, rb.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, rb.x, rb.y, lt.x, rb.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, lt.x, rb.y, lt.x, lt.y))
{
// Thing stucked in line!
stucked = true;
// Test if line ends are inside the thing
if(PointInRect(lt, rb, l.Start.Position) ||
PointInRect(lt, rb, l.End.Position))
{
// Thing stucked in line!
stucked = true;
}
// Test if the line intersects the square
else if(Line2D.GetIntersection(l.Start.Position, l.End.Position, lt.x, lt.y, rb.x, lt.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, rb.x, lt.y, rb.x, rb.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, rb.x, rb.y, lt.x, rb.y) ||
Line2D.GetIntersection(l.Start.Position, l.End.Position, lt.x, rb.y, lt.x, lt.y))
{
// Thing stucked in line!
stucked = true;
}
}
}
}
@ -99,23 +106,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
else
{
// Get the nearest line to see if the thing is outside the map
bool outside = false;
Linedef l = General.Map.Map.NearestLinedef(t.Position);
if(l.SideOfLine(t.Position) <= 0)
// Check this thing for being outside the map?
if(info.ErrorCheck >= ThingTypeInfo.THING_ERROR_INSIDE)
{
outside = (l.Front == null);
}
else
{
outside = (l.Back == null);
}
// Outside the map?
if(outside)
{
// Make result
SubmitResult(new ResultThingOutside(t));
// Get the nearest line to see if the thing is outside the map
bool outside = false;
Linedef l = General.Map.Map.NearestLinedef(t.Position);
if(l.SideOfLine(t.Position) <= 0)
{
outside = (l.Front == null);
}
else
{
outside = (l.Back == null);
}
// Outside the map?
if(outside)
{
// Make result
SubmitResult(new ResultThingOutside(t));
}
}
}

View file

@ -95,6 +95,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
return "Unknown result";
}
// This is called for rendering
public virtual void PlotSelection(IRenderer2D renderer)
{
}
// This is called for rendering
public virtual void RenderThingsSelection(IRenderer2D renderer)
{
}
// This is called for rendering
public virtual void RenderOverlaySelection(IRenderer2D renderer)
{
}
#endregion
}

View file

@ -67,7 +67,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This must return the string that is displayed in the listbox
public override string ToString()
{
return "Stucked thing '" + General.Map.Config.GetThingInfo(thing.Type).Title + "' at " + thing.Position.x + ", " + thing.Position.y;
return General.Map.Config.GetThingInfo(thing.Type).Title + " is stucked in a wall at " + thing.Position.x + ", " + thing.Position.y;
}
// Rendering
public override void RenderOverlaySelection(IRenderer2D renderer)
{
renderer.RenderThing(thing, renderer.DetermineThingColor(thing), 1.0f);
}
#endregion

View file

@ -70,9 +70,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This must return the string that is displayed in the listbox
public override string ToString()
{
return "Thing '" + General.Map.Config.GetThingInfo(thing.Type).Title + "' is outside the map at " + thing.Position.x + ", " + thing.Position.y;
return General.Map.Config.GetThingInfo(thing.Type).Title + " is outside the map at " + thing.Position.x + ", " + thing.Position.y;
}
// Rendering
public override void RenderOverlaySelection(IRenderer2D renderer)
{
renderer.RenderThing(thing, renderer.DetermineThingColor(thing), 1.0f);
}
#endregion
}
}

View file

@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private bool running = false;
private volatile bool running = false;
private Thread checksthread;
#endregion
@ -166,10 +166,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
else
{
checksthread = null;
running = false;
progress.Value = 0;
buttoncheck.Text = "Start Analysis";
Cursor.Current = Cursors.Default;
running = false;
}
}
@ -187,6 +187,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
ClearSelectedResult();
resultspanel.Visible = true;
buttoncheck.Text = "Abort Analysis";
General.Interface.RedrawDisplay();
// Start checking
running = true;
@ -202,6 +203,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This stops the checking
public void CloseWindow()
{
// Currently running?
if(running)
{
Cursor.Current = Cursors.WaitCursor;
checksthread.Interrupt();
}
ClearSelectedResult();
this.Hide();
}
// This clears the selected result
private void ClearSelectedResult()
{
@ -351,6 +366,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
ClearSelectedResult();
}
General.Interface.RedrawDisplay();
}
// First button

View file

@ -103,7 +103,7 @@ namespace CodeImp.DoomBuilder.Config
this.height = cfg.ReadSetting("thingtypes." + name + ".height", 16);
this.hangs = cfg.ReadSetting("thingtypes." + name + ".hangs", 0);
this.blocking = cfg.ReadSetting("thingtypes." + name + ".blocking", 0);
this.errorcheck = cfg.ReadSetting("thingtypes." + name + ".errorcheck", 0);
this.errorcheck = cfg.ReadSetting("thingtypes." + name + ".error", 1);
// Safety
if(this.width < 8f) this.width = 8f;

View file

@ -38,7 +38,10 @@ namespace CodeImp.DoomBuilder.Config
public const int THING_BLOCKING_NONE = 0;
public const int THING_BLOCKING_FULL = 1;
public const int THING_BLOCKING_HEIGHT = 2;
public const int THING_ERROR_NONE = 0;
public const int THING_ERROR_INSIDE = 1;
public const int THING_ERROR_INSIDE_STUCKED = 2;
#endregion
#region ================== Variables
@ -119,7 +122,7 @@ namespace CodeImp.DoomBuilder.Config
this.height = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height);
this.hangs = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".hangs", cat.Hangs) != 0);
this.blocking = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".blocking", cat.Blocking);
this.errorcheck = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".errorcheck", cat.ErrorCheck);
this.errorcheck = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".error", cat.ErrorCheck);
// Safety
if(this.width < 8f) this.width = 8f;