UltimateZoneBuilder/Source/BuilderModes/ClassicModes/ErrorCheckMode.cs

160 lines
3.8 KiB
C#
Raw Normal View History

2008-10-23 05:53:34 +00:00
#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
{
2008-11-27 19:25:13 +00:00
[EditMode(DisplayName = "Map Analysis Mode",
2008-10-23 05:53:34 +00:00
SwitchAction = "errorcheckmode",
ButtonImage = "MapAnalysisMode.png",
ButtonOrder = 200,
ButtonGroup = "002_tools",
2008-11-27 19:25:13 +00:00
Volatile = true,
UseByDefault = true)]
2008-10-23 05:53:34 +00:00
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.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
2008-10-23 05:53:34 +00:00
}
// Mode engages
public override void OnEngage()
{
base.OnEngage();
renderer.SetPresentation(Presentation.Standard);
2008-10-23 22:01:07 +00:00
// Save selection as marks
General.Map.Map.ClearAllMarks(false);
General.Map.Map.MarkAllSelectedGeometry(true, false);
General.Map.Map.ClearAllSelected();
2008-10-23 05:53:34 +00:00
// Show toolbox window
BuilderPlug.Me.ErrorCheckForm.Show((Form)General.Interface);
}
// Disenagaging
public override void OnDisengage()
{
base.OnDisengage();
// Hide object info
General.Interface.HideInfo();
2008-10-23 22:01:07 +00:00
// Restore selection
General.Map.Map.SelectMarkedGeometry(true, true);
General.Map.Map.ClearAllMarks(false);
2008-10-23 05:53:34 +00:00
// Hide toolbox window
2008-10-23 22:01:07 +00:00
BuilderPlug.Me.ErrorCheckForm.CloseWindow();
2008-10-23 05:53:34 +00:00
}
// 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.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
2008-10-23 05:53:34 +00:00
}
// Redrawing display
public override void OnRedrawDisplay()
{
2008-10-23 19:08:55 +00:00
// Get the selection
ErrorResult selection = BuilderPlug.Me.ErrorCheckForm.SelectedResult;
renderer.RedrawSurface();
// Render lines
if(renderer.StartPlotter(true))
{
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
renderer.PlotVerticesSet(General.Map.Map.Vertices);
if(selection != null) selection.PlotSelection(renderer);
2008-10-23 19:08:55 +00:00
renderer.Finish();
}
// Render things
if(renderer.StartThings(true))
{
renderer.RenderThingSet(General.Map.Map.Things, 1.0f);
2008-10-23 22:01:07 +00:00
if(selection != null) selection.RenderThingsSelection(renderer);
2008-10-23 19:08:55 +00:00
renderer.Finish();
}
// Render overlay
if(renderer.StartOverlay(true))
{
2008-10-23 22:01:07 +00:00
if(selection != null) selection.RenderOverlaySelection(renderer);
2008-10-23 19:08:55 +00:00
renderer.Finish();
}
renderer.Present();
2008-10-23 05:53:34 +00:00
}
#endregion
}
}