UltimateZoneBuilder/Source/BuilderModes/ClassicModes/DragVerticesMode.cs

162 lines
3.7 KiB
C#
Raw Normal View History

2007-11-07 21:14:27 +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;
2007-11-07 21:14:27 +00:00
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
2007-12-05 19:39:09 +00:00
using System.Drawing;
2008-01-02 21:49:43 +00:00
using CodeImp.DoomBuilder.Editing;
2007-11-07 21:14:27 +00:00
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
2007-11-07 21:14:27 +00:00
{
2008-01-04 00:16:58 +00:00
// No action or button for this mode, it is automatic.
// The EditMode attribute does not have to be specified unless the
// mode must be activated by class name rather than direct instance.
// In that case, just specifying the attribute like this is enough:
// [EditMode]
[EditMode(DisplayName = "Vertices",
Volatile = true)]
2008-01-04 00:16:58 +00:00
2008-02-24 21:52:18 +00:00
public sealed class DragVerticesMode : DragGeometryMode
2007-11-07 21:14:27 +00:00
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
2008-01-02 21:49:43 +00:00
2007-11-07 21:14:27 +00:00
#endregion
#region ================== Constructor / Disposer
// Constructor to start dragging immediately
2008-05-26 10:36:41 +00:00
public DragVerticesMode(Vertex dragitem, Vector2D dragstartmappos)
2007-11-07 21:14:27 +00:00
{
// Mark what we are dragging
General.Map.Map.ClearAllMarks(false);
General.Map.Map.MarkSelectedVertices(true, true);
// Initialize
2008-05-26 10:36:41 +00:00
base.StartDrag(dragstartmappos);
2007-11-07 21:14:27 +00:00
// We have no destructor
GC.SuppressFinalize(this);
}
2008-01-02 21:49:43 +00:00
// Disposer
2007-11-07 21:14:27 +00:00
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
// Done
base.Dispose();
2007-11-07 21:14:27 +00:00
}
}
#endregion
#region ================== Methods
2007-11-10 01:58:08 +00:00
2007-11-10 19:24:52 +00:00
// Mode engages
public override void OnEngage()
2007-11-10 19:24:52 +00:00
{
base.OnEngage();
2007-11-10 19:24:52 +00:00
}
2007-11-10 01:58:08 +00:00
// Disenagaging
public override void OnDisengage()
2007-11-10 01:58:08 +00:00
{
base.OnDisengage();
2007-11-10 19:24:52 +00:00
2007-11-10 01:58:08 +00:00
// When not cancelled
if(!cancelled)
{
2007-12-01 01:32:56 +00:00
// If only a single vertex was selected, deselect it now
2007-12-01 18:29:58 +00:00
if(selectedverts.Count == 1) General.Map.Map.ClearSelectedVertices();
2007-11-10 01:58:08 +00:00
}
}
2007-11-10 19:24:52 +00:00
// This redraws the display
public override void OnRedrawDisplay()
2007-11-10 01:58:08 +00:00
{
bool viewchanged = CheckViewChanged();
2007-11-21 12:50:56 +00:00
// Start rendering
if(renderer.StartPlotter(true))
2007-11-10 19:24:52 +00:00
{
// Render lines and vertices
renderer.PlotLinedefSet(General.Map.Map.Linedefs);
renderer.PlotVerticesSet(unselectedverts);
renderer.PlotVerticesSet(selectedverts);
2007-11-10 19:24:52 +00:00
2007-11-15 23:38:09 +00:00
// Draw the dragged item highlighted
// This is important to know, because this item is used
// for snapping to the grid and snapping to nearest items
renderer.PlotVertex(dragitem, ColorCollection.HIGHLIGHT);
2007-11-15 23:38:09 +00:00
2007-11-10 19:24:52 +00:00
// Done
2007-11-21 12:50:56 +00:00
renderer.Finish();
2007-11-10 19:24:52 +00:00
}
// Redraw things when view changed
if(viewchanged)
{
if(renderer.StartThings(true))
{
renderer.RenderThingSet(General.Map.Map.Things, 1.0f);
renderer.Finish();
}
}
// Redraw overlay
2008-04-17 05:36:48 +00:00
if(renderer.StartOverlay(true))
{
foreach(LineLengthLabel l in labels)
2008-04-17 05:36:48 +00:00
{
renderer.RenderText(l.TextLabel);
2008-04-17 05:36:48 +00:00
}
renderer.Finish();
}
renderer.Present();
2007-11-10 01:58:08 +00:00
}
2007-11-07 21:14:27 +00:00
#endregion
}
}