mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
more work on error checking
This commit is contained in:
parent
b82c18064f
commit
cc292c9c40
9 changed files with 313 additions and 31 deletions
|
@ -45,6 +45,7 @@
|
|||
<Compile Include="ClassicModes\FindReplaceMode.cs" />
|
||||
<Compile Include="ClassicModes\MakeSectorMode.cs" />
|
||||
<Compile Include="ErrorChecks\CheckStuckedThings.cs" />
|
||||
<Compile Include="ErrorChecks\ResultThingOutside.cs" />
|
||||
<Compile Include="ErrorChecks\ResultStuckedThing.cs" />
|
||||
<Compile Include="ErrorChecks\ErrorResult.cs" />
|
||||
<Compile Include="ErrorChecks\ErrorCheckerAttribute.cs" />
|
||||
|
|
|
@ -109,6 +109,36 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Redrawing display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
// Get the selection
|
||||
ErrorResult selection = BuilderPlug.Me.ErrorCheckForm.SelectedResult;
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
|
||||
//if(selection != null) selection.PlotSelection(renderer);
|
||||
renderer.PlotVerticesSet(General.Map.Map.Vertices);
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Render things
|
||||
if(renderer.StartThings(true))
|
||||
{
|
||||
renderer.RenderThingSet(General.Map.Map.Things, 1.0f);
|
||||
//if(selection != null) selection.RenderThingsSelection(renderer);
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Render overlay
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
//if(selection != null) selection.RenderOverlaySelection(renderer);
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -95,8 +95,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(stucked)
|
||||
{
|
||||
// Make result
|
||||
ResultStuckedThing r = new ResultStuckedThing(t);
|
||||
SubmitResult(r);
|
||||
SubmitResult(new ResultStuckedThing(t));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -116,8 +115,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(outside)
|
||||
{
|
||||
// Make result
|
||||
ResultStuckedThing r = new ResultStuckedThing(t);
|
||||
SubmitResult(r);
|
||||
SubmitResult(new ResultThingOutside(t));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,10 +42,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
#region ================== Variables
|
||||
|
||||
protected string description;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string Description { get { return description; } }
|
||||
|
||||
// Override these properties to create buttons
|
||||
public virtual int Buttons { get { return 0; } }
|
||||
public virtual string Button1Text { get { return ""; } }
|
||||
public virtual string Button2Text { get { return ""; } }
|
||||
public virtual string Button3Text { get { return ""; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
@ -60,6 +70,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
// When this result is selected
|
||||
public virtual void Selected()
|
||||
{
|
||||
}
|
||||
|
||||
// When the first button is clicked
|
||||
public virtual void Button1Click()
|
||||
{
|
||||
}
|
||||
|
||||
// When the second button is clicked
|
||||
public virtual void Button2Click()
|
||||
{
|
||||
}
|
||||
|
||||
// When the third button is clicked
|
||||
public virtual void Button3Click()
|
||||
{
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.thing = t;
|
||||
this.description = "This thing is stucked in a wall (single-sided line) and will likely not be able to move around.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
78
Source/BuilderModes/ErrorChecks/ResultThingOutside.cs
Normal file
78
Source/BuilderModes/ErrorChecks/ResultThingOutside.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
|
||||
#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 System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultThingOutside : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private Thing thing;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 1; } }
|
||||
public override string Button1Text { get { return "Delete Thing"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public ResultThingOutside(Thing t)
|
||||
{
|
||||
// Initialize
|
||||
this.thing = t;
|
||||
this.description = "This thing is completely outside the map.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -77,6 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.results.Name = "results";
|
||||
this.results.Size = new System.Drawing.Size(360, 164);
|
||||
this.results.TabIndex = 2;
|
||||
this.results.SelectedIndexChanged += new System.EventHandler(this.results_SelectedIndexChanged);
|
||||
//
|
||||
// resultspanel
|
||||
//
|
||||
|
@ -101,6 +102,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.fix3.Text = "Fix 3";
|
||||
this.fix3.UseVisualStyleBackColor = true;
|
||||
this.fix3.Visible = false;
|
||||
this.fix3.Click += new System.EventHandler(this.fix3_Click);
|
||||
//
|
||||
// fix2
|
||||
//
|
||||
|
@ -112,16 +114,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.fix2.Text = "Fix 2";
|
||||
this.fix2.UseVisualStyleBackColor = true;
|
||||
this.fix2.Visible = false;
|
||||
this.fix2.Click += new System.EventHandler(this.fix2_Click);
|
||||
//
|
||||
// resultinfo
|
||||
//
|
||||
this.resultinfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.resultinfo.Location = new System.Drawing.Point(12, 208);
|
||||
this.resultinfo.Enabled = false;
|
||||
this.resultinfo.Location = new System.Drawing.Point(12, 206);
|
||||
this.resultinfo.Name = "resultinfo";
|
||||
this.resultinfo.Size = new System.Drawing.Size(358, 47);
|
||||
this.resultinfo.Size = new System.Drawing.Size(358, 57);
|
||||
this.resultinfo.TabIndex = 5;
|
||||
this.resultinfo.Text = "label1";
|
||||
this.resultinfo.Text = "Select a result from the list to see more information.\r\n";
|
||||
//
|
||||
// fix1
|
||||
//
|
||||
|
@ -133,6 +137,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.fix1.Text = "Fix 1";
|
||||
this.fix1.UseVisualStyleBackColor = true;
|
||||
this.fix1.Visible = false;
|
||||
this.fix1.Click += new System.EventHandler(this.fix1_Click);
|
||||
//
|
||||
// progress
|
||||
//
|
||||
|
|
|
@ -61,6 +61,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public ErrorResult SelectedResult { get { return results.SelectedItem as ErrorResult; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Show
|
||||
|
||||
// Constructor
|
||||
|
@ -105,40 +111,43 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Cross-Thread Calls
|
||||
#region ================== Thread Calls
|
||||
|
||||
public void SubmitResult(ErrorResult result)
|
||||
{
|
||||
if(results.InvokeRequired)
|
||||
{
|
||||
CallResultMethodDelegate d = new CallResultMethodDelegate(SubmitResult);
|
||||
try { progress.Invoke(d, result); } catch(ThreadInterruptedException) { }
|
||||
try { progress.Invoke(d, result); }
|
||||
catch(ThreadInterruptedException) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
results.Items.Add(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetProgressMaximum(int maximum)
|
||||
{
|
||||
if(progress.InvokeRequired)
|
||||
{
|
||||
CallIntMethodDelegate d = new CallIntMethodDelegate(SetProgressMaximum);
|
||||
try { progress.Invoke(d, maximum); } catch(ThreadInterruptedException) { }
|
||||
try { progress.Invoke(d, maximum); }
|
||||
catch(ThreadInterruptedException) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
progress.Maximum = maximum;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void AddProgressValue(int value)
|
||||
{
|
||||
if(progress.InvokeRequired)
|
||||
{
|
||||
CallIntMethodDelegate d = new CallIntMethodDelegate(AddProgressValue);
|
||||
try { progress.Invoke(d, value); } catch(ThreadInterruptedException) { }
|
||||
try { progress.Invoke(d, value); }
|
||||
catch(ThreadInterruptedException) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -146,6 +155,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// This stops checking (only called from the checking management thread)
|
||||
private void StopChecking()
|
||||
{
|
||||
if(this.InvokeRequired)
|
||||
|
@ -163,10 +173,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// This starts checking
|
||||
private void StartChecking()
|
||||
{
|
||||
if(running) return;
|
||||
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
// Open the results panel
|
||||
this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top + resultspanel.Height);
|
||||
progress.Value = 0;
|
||||
results.Items.Clear();
|
||||
ClearSelectedResult();
|
||||
resultspanel.Visible = true;
|
||||
buttoncheck.Text = "Abort Analysis";
|
||||
|
||||
// Start checking
|
||||
running = true;
|
||||
checksthread = new Thread(new ThreadStart(RunChecks));
|
||||
checksthread.Name = "Checking Management";
|
||||
checksthread.Priority = ThreadPriority.Normal;
|
||||
checksthread.Start();
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
// This clears the selected result
|
||||
private void ClearSelectedResult()
|
||||
{
|
||||
results.SelectedIndex = -1;
|
||||
resultinfo.Text = "Select a result from the list to see more information.";
|
||||
resultinfo.Enabled = false;
|
||||
fix1.Visible = false;
|
||||
fix2.Visible = false;
|
||||
fix3.Visible = false;
|
||||
}
|
||||
|
||||
// This runs in a seperate thread to manage the checking threads
|
||||
private void RunChecks()
|
||||
{
|
||||
|
@ -281,23 +327,86 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
else
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
// Open the results panel
|
||||
this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top + resultspanel.Height);
|
||||
progress.Value = 0;
|
||||
results.Items.Clear();
|
||||
resultspanel.Visible = true;
|
||||
buttoncheck.Text = "Abort Analysis";
|
||||
|
||||
// Start checking
|
||||
running = true;
|
||||
checksthread = new Thread(new ThreadStart(RunChecks));
|
||||
checksthread.Name = "Checking Management";
|
||||
checksthread.Priority = ThreadPriority.Normal;
|
||||
checksthread.Start();
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
StartChecking();
|
||||
}
|
||||
}
|
||||
|
||||
// Results selection changed
|
||||
private void results_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Anything selected?
|
||||
if(results.SelectedIndex >= 0)
|
||||
{
|
||||
ErrorResult r = (results.SelectedItem as ErrorResult);
|
||||
resultinfo.Text = r.Description;
|
||||
resultinfo.Enabled = true;
|
||||
fix1.Text = r.Button1Text;
|
||||
fix2.Text = r.Button2Text;
|
||||
fix3.Text = r.Button3Text;
|
||||
fix1.Visible = (r.Buttons >= 1);
|
||||
fix2.Visible = (r.Buttons >= 2);
|
||||
fix3.Visible = (r.Buttons >= 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearSelectedResult();
|
||||
}
|
||||
}
|
||||
|
||||
// First button
|
||||
private void fix1_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Anything selected?
|
||||
if(results.SelectedIndex >= 0)
|
||||
{
|
||||
if(running)
|
||||
{
|
||||
General.ShowWarningMessage("You must stop the analysis before you can make changes to your map!", MessageBoxButtons.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorResult r = (results.SelectedItem as ErrorResult);
|
||||
r.Button1Click();
|
||||
StartChecking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Second button
|
||||
private void fix2_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Anything selected?
|
||||
if(results.SelectedIndex >= 0)
|
||||
{
|
||||
if(running)
|
||||
{
|
||||
General.ShowWarningMessage("You must stop the analysis before you can make changes to your map!", MessageBoxButtons.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorResult r = (results.SelectedItem as ErrorResult);
|
||||
r.Button2Click();
|
||||
StartChecking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Third button
|
||||
private void fix3_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Anything selected?
|
||||
if(results.SelectedIndex >= 0)
|
||||
{
|
||||
if(running)
|
||||
{
|
||||
General.ShowWarningMessage("You must stop the analysis before you can make changes to your map!", MessageBoxButtons.OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorResult r = (results.SelectedItem as ErrorResult);
|
||||
r.Button3Click();
|
||||
StartChecking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,4 +117,34 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="checks.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="buttoncheck.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="results.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="resultspanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="fix3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="fix2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="resultinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="fix1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="progress.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in a new issue