2009-04-19 18:07:22 +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.Generic;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
|
|
|
// 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 = "Linedefs",
|
2011-12-03 14:49:53 +00:00
|
|
|
AllowCopyPaste = false,
|
2009-04-19 18:07:22 +00:00
|
|
|
Volatile = true)]
|
|
|
|
|
|
|
|
public sealed class DragLinedefsMode : DragGeometryMode
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
2022-09-18 14:54:09 +00:00
|
|
|
private ICollection<Linedef> draglines;
|
|
|
|
private ICollection<Linedef> unmovinglines;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor to start dragging immediately
|
2022-09-20 21:52:41 +00:00
|
|
|
public DragLinedefsMode(Vector2D dragstartmappos, ICollection<Linedef> lines)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Mark what we are dragging
|
|
|
|
General.Map.Map.ClearAllMarks(false);
|
2022-09-18 14:54:09 +00:00
|
|
|
|
|
|
|
draglines = new List<Linedef>(lines.Count);
|
|
|
|
foreach(Linedef ld in lines)
|
|
|
|
{
|
|
|
|
ld.Marked = true;
|
|
|
|
draglines.Add(ld);
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
2022-09-18 14:54:09 +00:00
|
|
|
foreach (Vertex v in verts) v.Marked = true;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Get line collections
|
2022-09-18 14:54:09 +00:00
|
|
|
unmovinglines = General.Map.Map.GetSelectedLinedefs(false);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Initialize
|
|
|
|
base.StartDrag(dragstartmappos);
|
2022-09-18 14:54:09 +00:00
|
|
|
undodescription = (draglines.Count == 1 ? "Drag linedef" : "Drag " + draglines.Count + " linedefs"); //mxd
|
2009-04-19 18:07:22 +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
|
|
|
|
|
|
|
|
// This redraws the display
|
|
|
|
public override void OnRedrawDisplay()
|
|
|
|
{
|
|
|
|
renderer.RedrawSurface();
|
|
|
|
|
2009-06-11 21:21:20 +00:00
|
|
|
UpdateRedraw();
|
|
|
|
|
2013-12-23 12:02:58 +00:00
|
|
|
if(CheckViewChanged())
|
2009-06-11 21:21:20 +00:00
|
|
|
{
|
|
|
|
// Start rendering things
|
|
|
|
if(renderer.StartThings(true))
|
|
|
|
{
|
2016-04-01 10:49:19 +00:00
|
|
|
renderer.RenderThingSet(General.Map.Map.Things, General.Settings.ActiveThingsAlpha);
|
2009-06-11 21:21:20 +00:00
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.Present();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This redraws only the required things
|
|
|
|
protected override void UpdateRedraw()
|
|
|
|
{
|
2009-04-19 18:07:22 +00:00
|
|
|
// Start rendering structure
|
|
|
|
if(renderer.StartPlotter(true))
|
|
|
|
{
|
|
|
|
// Render lines and vertices
|
2022-09-18 14:54:09 +00:00
|
|
|
renderer.PlotLinedefSet(unmovinglines);
|
|
|
|
|
|
|
|
foreach (Linedef ld in draglines)
|
|
|
|
{
|
|
|
|
if (ld.Selected)
|
|
|
|
renderer.PlotLinedef(ld, General.Colors.Selection);
|
|
|
|
else
|
|
|
|
renderer.PlotLinedef(ld, General.Colors.Highlight);
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.PlotVerticesSet(General.Map.Map.Vertices);
|
|
|
|
|
|
|
|
// 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);
|
2009-06-11 21:21:20 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Done
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
|
2014-01-13 08:06:56 +00:00
|
|
|
//mxd. Render things
|
2014-12-03 23:15:26 +00:00
|
|
|
if(renderer.StartThings(true))
|
|
|
|
{
|
2016-03-30 11:29:39 +00:00
|
|
|
renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, General.Settings.HiddenThingsAlpha);
|
2016-04-01 10:49:19 +00:00
|
|
|
renderer.RenderThingSet(unselectedthings, General.Settings.ActiveThingsAlpha);
|
|
|
|
renderer.RenderThingSet(selectedthings, General.Settings.ActiveThingsAlpha);
|
2014-01-13 08:06:56 +00:00
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Redraw overlay
|
|
|
|
if(renderer.StartOverlay(true))
|
|
|
|
{
|
2016-04-25 14:48:39 +00:00
|
|
|
renderer.RenderText(labels);
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|