From 28172b94bb99f95db560e38004837cfdfd68aa22 Mon Sep 17 00:00:00 2001 From: codeimp Date: Thu, 23 Oct 2008 05:53:34 +0000 Subject: [PATCH] working on map analysis mode --- Source/BuilderModes/BuilderModes.csproj | 11 ++ .../ClassicModes/ErrorCheckMode.cs | 116 +++++++++++++++++ Source/BuilderModes/General/BuilderPlug.cs | 7 + .../Interface/ErrorCheckForm.Designer.cs | 54 ++++++++ .../BuilderModes/Interface/ErrorCheckForm.cs | 89 +++++++++++++ .../Interface/ErrorCheckForm.resx | 120 ++++++++++++++++++ Source/BuilderModes/Resources/Actions.cfg | 10 ++ 7 files changed, 407 insertions(+) create mode 100644 Source/BuilderModes/ClassicModes/ErrorCheckMode.cs create mode 100644 Source/BuilderModes/Interface/ErrorCheckForm.Designer.cs create mode 100644 Source/BuilderModes/Interface/ErrorCheckForm.cs create mode 100644 Source/BuilderModes/Interface/ErrorCheckForm.resx diff --git a/Source/BuilderModes/BuilderModes.csproj b/Source/BuilderModes/BuilderModes.csproj index bfd8d39e..eafbd085 100644 --- a/Source/BuilderModes/BuilderModes.csproj +++ b/Source/BuilderModes/BuilderModes.csproj @@ -35,6 +35,7 @@ + @@ -56,6 +57,12 @@ CurveLinedefsForm.cs + + Form + + + ErrorCheckForm.cs + Form @@ -147,6 +154,10 @@ + + Designer + ErrorCheckForm.cs + FindReplaceForm.cs Designer diff --git a/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs b/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs new file mode 100644 index 00000000..f1f2e389 --- /dev/null +++ b/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs @@ -0,0 +1,116 @@ + +#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 System.Drawing; +using CodeImp.DoomBuilder.Editing; + +#endregion + +namespace CodeImp.DoomBuilder.BuilderModes +{ + [EditMode(DisplayName = "Map Analysis", + SwitchAction = "errorcheckmode", + Volatile = false)] + + public sealed class ErrorCheckMode : BaseClassicMode + { + #region ================== Constants + + #endregion + + #region ================== Variables + + #endregion + + #region ================== Properties + + #endregion + + #region ================== Constructor / Disposer + + #endregion + + #region ================== Events + + // Cancelled + public override void OnCancel() + { + // Cancel base class + base.OnCancel(); + + // Return to base mode + General.Map.ChangeMode(General.Map.PreviousStableMode.Name); + } + + // Mode engages + public override void OnEngage() + { + base.OnEngage(); + renderer.SetPresentation(Presentation.Standard); + + // Show toolbox window + BuilderPlug.Me.ErrorCheckForm.Show((Form)General.Interface); + } + + // Disenagaging + public override void OnDisengage() + { + base.OnDisengage(); + + // Hide object info + General.Interface.HideInfo(); + + // Hide toolbox window + BuilderPlug.Me.ErrorCheckForm.Hide(); + } + + // This applies the curves and returns to the base mode + public override void OnAccept() + { + // Snap to map format accuracy + General.Map.Map.SnapAllToAccuracy(); + + // Update caches + General.Map.Map.Update(); + General.Map.IsChanged = true; + + // Return to base mode + General.Map.ChangeMode(General.Map.PreviousStableMode.Name); + } + + // Redrawing display + public override void OnRedrawDisplay() + { + } + + #endregion + } +} diff --git a/Source/BuilderModes/General/BuilderPlug.cs b/Source/BuilderModes/General/BuilderPlug.cs index 0a4bb62f..27438f13 100644 --- a/Source/BuilderModes/General/BuilderPlug.cs +++ b/Source/BuilderModes/General/BuilderPlug.cs @@ -55,6 +55,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private MenusForm menusform; private CurveLinedefsForm curvelinedefsform; private FindReplaceForm findreplaceform; + private ErrorCheckForm errorcheckform; #endregion @@ -65,6 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public MenusForm MenusForm { get { return menusform; } } public CurveLinedefsForm CurveLinedefsForm { get { return curvelinedefsform; } } public FindReplaceForm FindReplaceForm { get { return findreplaceform; } } + public ErrorCheckForm ErrorCheckForm { get { return errorcheckform; } } #endregion @@ -85,6 +87,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Load find/replace form findreplaceform = new FindReplaceForm(); + + // Load error checking form + errorcheckform = new ErrorCheckForm(); } // Disposer @@ -101,6 +106,8 @@ namespace CodeImp.DoomBuilder.BuilderModes curvelinedefsform = null; findreplaceform.Dispose(); findreplaceform = null; + errorcheckform.Dispose(); + errorcheckform = null; // Done me = null; diff --git a/Source/BuilderModes/Interface/ErrorCheckForm.Designer.cs b/Source/BuilderModes/Interface/ErrorCheckForm.Designer.cs new file mode 100644 index 00000000..c8539028 --- /dev/null +++ b/Source/BuilderModes/Interface/ErrorCheckForm.Designer.cs @@ -0,0 +1,54 @@ +namespace CodeImp.DoomBuilder.BuilderModes +{ + partial class ErrorCheckForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if(disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // ErrorCheckForm + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(406, 319); + this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ErrorCheckForm"; + this.Opacity = 0; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "Map Analysis"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ErrorCheckForm_FormClosing); + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/Source/BuilderModes/Interface/ErrorCheckForm.cs b/Source/BuilderModes/Interface/ErrorCheckForm.cs new file mode 100644 index 00000000..74417608 --- /dev/null +++ b/Source/BuilderModes/Interface/ErrorCheckForm.cs @@ -0,0 +1,89 @@ + +#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.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Microsoft.Win32; +using System.Diagnostics; +using CodeImp.DoomBuilder.Actions; +using CodeImp.DoomBuilder.Data; +using CodeImp.DoomBuilder.Config; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Controls; +using CodeImp.DoomBuilder.Windows; +using System.Reflection; +using System.Globalization; + +#endregion + +namespace CodeImp.DoomBuilder.BuilderModes +{ + public partial class ErrorCheckForm : DelayedForm + { + #region ================== Constructor / Show + + // Constructor + public ErrorCheckForm() + { + InitializeComponent(); + } + + // This shows the window + public void Show(Form owner) + { + // First time showing? + //if((this.Location.X == 0) && (this.Location.Y == 0)) + { + // Position at left-top of owner + this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90); + } + + // Close results part + //resultspanel.Visible = false; + //this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top); + + // Show window + base.Show(owner); + } + + #endregion + + #region ================== Events + + // Window closing + private void ErrorCheckForm_FormClosing(object sender, FormClosingEventArgs e) + { + // If the user closes the form, then just cancel the mode + if(e.CloseReason == CloseReason.UserClosing) + { + e.Cancel = true; + General.Map.CancelMode(); + } + } + + #endregion + + #region ================== Methods + + #endregion + } +} \ No newline at end of file diff --git a/Source/BuilderModes/Interface/ErrorCheckForm.resx b/Source/BuilderModes/Interface/ErrorCheckForm.resx new file mode 100644 index 00000000..ff31a6db --- /dev/null +++ b/Source/BuilderModes/Interface/ErrorCheckForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index 7d834fe2..ce316356 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -257,3 +257,13 @@ makedoor allowmouse = true; allowscroll = true; } + +errorcheckmode +{ + title = "Map Analysis Mode"; + category = "modes"; + description = "Checks your map for errors and mistakes and reports the results."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +}