2008-02-19 19:04:19 +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.Interface;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using System.Drawing;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-05-14 21:48:36 +00:00
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2008-02-19 19:04:19 +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:
|
2008-05-08 16:39:14 +00:00
|
|
|
// [EditMode]
|
|
|
|
|
|
|
|
[EditMode(Volatile = true)]
|
2008-02-19 19:04:19 +00:00
|
|
|
|
2008-02-24 21:52:18 +00:00
|
|
|
public sealed class DragSectorsMode : DragGeometryMode
|
2008-02-19 19:04:19 +00:00
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
private ICollection<Linedef> selectedlines;
|
|
|
|
private ICollection<Sector> selectedsectors;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor to start dragging immediately
|
2008-04-07 14:33:41 +00:00
|
|
|
public DragSectorsMode(EditMode basemode, Vector2D dragstartmappos)
|
2008-02-19 19:04:19 +00:00
|
|
|
{
|
2008-05-01 14:10:38 +00:00
|
|
|
// Mark what we are dragging
|
|
|
|
General.Map.Map.ClearAllMarks();
|
|
|
|
General.Map.Map.MarkSelectedLinedefs(true, true);
|
|
|
|
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
|
|
|
foreach(Vertex v in verts) v.Marked = true;
|
2008-02-19 19:04:19 +00:00
|
|
|
|
|
|
|
// Get selected lines
|
|
|
|
selectedlines = General.Map.Map.GetLinedefsSelection(true);
|
|
|
|
selectedsectors = General.Map.Map.GetSectorsSelection(true);
|
|
|
|
|
|
|
|
// Initialize
|
2008-05-01 14:10:38 +00:00
|
|
|
base.StartDrag(basemode, dragstartmappos);
|
2008-02-19 19:04:19 +00:00
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public override void Dispose()
|
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Clean up
|
|
|
|
|
|
|
|
// Done
|
|
|
|
base.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// Mode engages
|
|
|
|
public override void Engage()
|
|
|
|
{
|
|
|
|
base.Engage();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disenagaging
|
|
|
|
public override void Disengage()
|
|
|
|
{
|
2008-04-19 15:04:44 +00:00
|
|
|
// Select vertices from lines selection
|
|
|
|
General.Map.Map.ClearSelectedVertices();
|
2008-05-01 14:10:38 +00:00
|
|
|
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
2008-04-19 15:04:44 +00:00
|
|
|
foreach(Vertex v in verts) v.Selected = true;
|
|
|
|
|
|
|
|
// Perform normal disengage
|
2008-02-19 19:04:19 +00:00
|
|
|
base.Disengage();
|
2008-04-19 15:04:44 +00:00
|
|
|
|
|
|
|
// Clear vertex selection
|
|
|
|
General.Map.Map.ClearSelectedVertices();
|
2008-02-19 19:04:19 +00:00
|
|
|
|
|
|
|
// When not cancelled
|
|
|
|
if(!cancelled)
|
|
|
|
{
|
|
|
|
// If only a single sector was selected, deselect it now
|
2008-02-21 06:47:43 +00:00
|
|
|
if(selectedsectors.Count == 1)
|
|
|
|
{
|
|
|
|
General.Map.Map.ClearSelectedSectors();
|
|
|
|
General.Map.Map.ClearSelectedLinedefs();
|
|
|
|
}
|
2008-02-19 19:04:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This redraws the display
|
2008-04-20 22:54:24 +00:00
|
|
|
public override void RedrawDisplay()
|
2008-02-19 19:04:19 +00:00
|
|
|
{
|
2008-02-19 21:32:40 +00:00
|
|
|
bool viewchanged = CheckViewChanged();
|
2008-02-19 19:04:19 +00:00
|
|
|
|
|
|
|
// Start rendering
|
2008-04-12 12:45:57 +00:00
|
|
|
if(renderer.StartPlotter(true))
|
2008-02-19 19:04:19 +00:00
|
|
|
{
|
|
|
|
// Render lines and vertices
|
2008-05-01 14:10:38 +00:00
|
|
|
renderer.PlotLinedefSet(snaptolines);
|
|
|
|
renderer.PlotLinedefSet(unstablelines);
|
2008-04-12 16:07:10 +00:00
|
|
|
renderer.PlotLinedefSet(selectedlines);
|
|
|
|
renderer.PlotVerticesSet(General.Map.Map.Vertices);
|
2008-02-19 19:04:19 +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
|
2008-04-12 16:07:10 +00:00
|
|
|
renderer.PlotVertex(dragitem, ColorCollection.HIGHLIGHT);
|
2008-02-19 19:04:19 +00:00
|
|
|
|
|
|
|
// Done
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
2008-04-12 12:45:57 +00:00
|
|
|
|
|
|
|
// Redraw things when view changed
|
|
|
|
if(viewchanged)
|
|
|
|
{
|
|
|
|
if(renderer.StartThings(true))
|
|
|
|
{
|
|
|
|
renderer.SetThingsRenderOrder(false);
|
|
|
|
renderer.RenderThingSet(General.Map.Map.Things);
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-13 14:24:35 +00:00
|
|
|
// Redraw overlay
|
|
|
|
if(renderer.StartOverlay(true))
|
|
|
|
{
|
2008-05-13 17:11:33 +00:00
|
|
|
foreach(LineLengthLabel l in labels)
|
2008-05-13 14:24:35 +00:00
|
|
|
{
|
2008-05-13 17:11:33 +00:00
|
|
|
renderer.RenderText(l.TextLabel);
|
2008-05-13 14:24:35 +00:00
|
|
|
}
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
|
2008-04-12 12:45:57 +00:00
|
|
|
renderer.Present();
|
2008-02-19 19:04:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|