mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
selecting by drawing a rectangle!
This commit is contained in:
parent
535ecc54a2
commit
a3fab2f666
6 changed files with 290 additions and 31 deletions
|
@ -144,6 +144,17 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Selecting?
|
||||
if(selecting)
|
||||
{
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
|
@ -184,6 +195,41 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This is called wheh selection ends
|
||||
protected override void EndSelection()
|
||||
{
|
||||
// Go for all lines
|
||||
foreach(Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
l.Selected = ((l.Start.Position.x >= selectionrect.Left) &&
|
||||
(l.Start.Position.y >= selectionrect.Top) &&
|
||||
(l.Start.Position.x <= selectionrect.Right) &&
|
||||
(l.Start.Position.y <= selectionrect.Bottom) &&
|
||||
(l.End.Position.x >= selectionrect.Left) &&
|
||||
(l.End.Position.y >= selectionrect.Top) &&
|
||||
(l.End.Position.x <= selectionrect.Right) &&
|
||||
(l.End.Position.y <= selectionrect.Bottom));
|
||||
}
|
||||
|
||||
base.EndSelection();
|
||||
if(renderer.StartOverlay(true)) renderer.Finish();
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This is called when the selection is updated
|
||||
protected override void UpdateSelection()
|
||||
{
|
||||
base.UpdateSelection();
|
||||
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
|
@ -234,6 +280,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start making a selection
|
||||
StartSelection();
|
||||
}
|
||||
}
|
||||
// Edit button?
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
|
@ -310,13 +361,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
{
|
||||
base.DragStart(e);
|
||||
|
||||
// Which button is used?
|
||||
if(e.Button == EditMode.SELECT_BUTTON)
|
||||
{
|
||||
// Make selection
|
||||
|
||||
}
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
// Edit button used?
|
||||
if(e.Button == EditMode.EDIT_BUTTON)
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -159,6 +159,17 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Selecting?
|
||||
if(selecting)
|
||||
{
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
|
@ -204,6 +215,63 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
else
|
||||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This is called wheh selection ends
|
||||
protected override void EndSelection()
|
||||
{
|
||||
// Go for all lines
|
||||
foreach(Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
l.Selected = ((l.Start.Position.x >= selectionrect.Left) &&
|
||||
(l.Start.Position.y >= selectionrect.Top) &&
|
||||
(l.Start.Position.x <= selectionrect.Right) &&
|
||||
(l.Start.Position.y <= selectionrect.Bottom) &&
|
||||
(l.End.Position.x >= selectionrect.Left) &&
|
||||
(l.End.Position.y >= selectionrect.Top) &&
|
||||
(l.End.Position.x <= selectionrect.Right) &&
|
||||
(l.End.Position.y <= selectionrect.Bottom));
|
||||
}
|
||||
|
||||
// Go for all sectors
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
// Go for all sidedefs
|
||||
bool allselected = true;
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
{
|
||||
if(!sd.Line.Selected)
|
||||
{
|
||||
allselected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Sector completely selected?
|
||||
s.Selected = allselected;
|
||||
}
|
||||
|
||||
// Make sure all linedefs reflect selected sectors
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
SelectSector(s, s.Selected);
|
||||
|
||||
base.EndSelection();
|
||||
if(renderer.StartOverlay(true)) renderer.Finish();
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This is called when the selection is updated
|
||||
protected override void UpdateSelection()
|
||||
{
|
||||
base.UpdateSelection();
|
||||
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
|
@ -271,7 +339,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
{
|
||||
// Flip selection
|
||||
SelectSector(highlighted, !highlighted.Selected);
|
||||
|
||||
|
||||
// Update display
|
||||
if(renderer.StartPlotter(false))
|
||||
{
|
||||
|
@ -281,6 +349,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start making a selection
|
||||
StartSelection();
|
||||
}
|
||||
}
|
||||
// Edit button?
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
|
@ -358,13 +431,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
{
|
||||
base.DragStart(e);
|
||||
|
||||
// Which button is used?
|
||||
if(e.Button == EditMode.SELECT_BUTTON)
|
||||
{
|
||||
// Make selection
|
||||
|
||||
}
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
// Edit button used?
|
||||
if(e.Button == EditMode.EDIT_BUTTON)
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -128,6 +128,17 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Selecting?
|
||||
if(selecting)
|
||||
{
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
|
@ -160,6 +171,37 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This is called wheh selection ends
|
||||
protected override void EndSelection()
|
||||
{
|
||||
// Go for all things
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
t.Selected = ((t.Position.x >= selectionrect.Left) &&
|
||||
(t.Position.y >= selectionrect.Top) &&
|
||||
(t.Position.x <= selectionrect.Right) &&
|
||||
(t.Position.y <= selectionrect.Bottom));
|
||||
}
|
||||
|
||||
base.EndSelection();
|
||||
if(renderer.StartOverlay(true)) renderer.Finish();
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This is called when the selection is updated
|
||||
protected override void UpdateSelection()
|
||||
{
|
||||
base.UpdateSelection();
|
||||
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
|
@ -208,6 +250,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start making a selection
|
||||
StartSelection();
|
||||
}
|
||||
}
|
||||
// Edit button?
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
|
@ -280,13 +327,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
{
|
||||
base.DragStart(e);
|
||||
|
||||
// Which button is used?
|
||||
if(e.Button == EditMode.SELECT_BUTTON)
|
||||
{
|
||||
// Make selection
|
||||
|
||||
}
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
// Edit button used?
|
||||
if(e.Button == EditMode.EDIT_BUTTON)
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -144,6 +144,17 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Finish();
|
||||
}
|
||||
|
||||
// Selecting?
|
||||
if(selecting)
|
||||
{
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
|
@ -175,6 +186,37 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
else
|
||||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
// This is called wheh selection ends
|
||||
protected override void EndSelection()
|
||||
{
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
{
|
||||
v.Selected = ((v.Position.x >= selectionrect.Left) &&
|
||||
(v.Position.y >= selectionrect.Top) &&
|
||||
(v.Position.x <= selectionrect.Right) &&
|
||||
(v.Position.y <= selectionrect.Bottom));
|
||||
}
|
||||
|
||||
base.EndSelection();
|
||||
if(renderer.StartOverlay(true)) renderer.Finish();
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This is called when the selection is updated
|
||||
protected override void UpdateSelection()
|
||||
{
|
||||
base.UpdateSelection();
|
||||
|
||||
// Render selection
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
RenderSelection();
|
||||
renderer.Finish();
|
||||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
|
@ -223,6 +265,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start making a selection
|
||||
StartSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,13 +296,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
|
|||
{
|
||||
base.DragStart(e);
|
||||
|
||||
// Which button is used?
|
||||
if(e.Button == EditMode.SELECT_BUTTON)
|
||||
{
|
||||
// Make selection
|
||||
|
||||
}
|
||||
else if(e.Button == EditMode.EDIT_BUTTON)
|
||||
// Edit button used?
|
||||
if(e.Button == EditMode.EDIT_BUTTON)
|
||||
{
|
||||
// Anything highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
|
|
|
@ -45,6 +45,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
private const float SCALE_MAX = 20f;
|
||||
private const float SCALE_MIN = 0.01f;
|
||||
private const float SELECTION_BORDER_SIZE = 2f;
|
||||
private const int SELECTION_ALPHA = 200;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -66,6 +68,11 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
protected bool mouseinside;
|
||||
protected MouseButtons mousedragging = MouseButtons.None;
|
||||
|
||||
// Selection
|
||||
protected bool selecting;
|
||||
private Vector2D selectstart;
|
||||
protected RectangleF selectionrect;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -329,6 +336,9 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
}
|
||||
}
|
||||
|
||||
// Selecting?
|
||||
if(selecting) UpdateSelection();
|
||||
|
||||
// Let the base class know
|
||||
base.MouseMove(e);
|
||||
}
|
||||
|
@ -355,6 +365,9 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
mousedragging = MouseButtons.None;
|
||||
}
|
||||
|
||||
// Selection stops
|
||||
if(selecting) EndSelection();
|
||||
|
||||
// Let the base class know
|
||||
base.MouseUp(e);
|
||||
}
|
||||
|
@ -392,6 +405,49 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
base.Cancel();
|
||||
}
|
||||
|
||||
// This starts a selection
|
||||
protected virtual void StartSelection()
|
||||
{
|
||||
selecting = true;
|
||||
selectstart = mousemappos;
|
||||
selectionrect = new RectangleF(selectstart.x, selectstart.y, 0, 0);
|
||||
}
|
||||
|
||||
// This updates a selection
|
||||
protected virtual void UpdateSelection()
|
||||
{
|
||||
selectionrect.X = selectstart.x;
|
||||
selectionrect.Y = selectstart.y;
|
||||
selectionrect.Width = mousemappos.x - selectstart.x;
|
||||
selectionrect.Height = mousemappos.y - selectstart.y;
|
||||
|
||||
if(selectionrect.Width < 0f)
|
||||
{
|
||||
selectionrect.Width = -selectionrect.Width;
|
||||
selectionrect.X -= selectionrect.Width;
|
||||
}
|
||||
|
||||
if(selectionrect.Height < 0f)
|
||||
{
|
||||
selectionrect.Height = -selectionrect.Height;
|
||||
selectionrect.Y -= selectionrect.Height;
|
||||
}
|
||||
}
|
||||
|
||||
// This is called when a selection is released
|
||||
protected virtual void EndSelection()
|
||||
{
|
||||
selecting = false;
|
||||
}
|
||||
|
||||
// This draws the selection on the overlay layer
|
||||
// Must call renderer.StartOverlay first!
|
||||
protected virtual void RenderSelection()
|
||||
{
|
||||
renderer.RenderRectangle(selectionrect, SELECTION_BORDER_SIZE,
|
||||
General.Colors.Highlight.WithAlpha(SELECTION_ALPHA), true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,11 +155,16 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
public virtual void MouseLeave(EventArgs e) { }
|
||||
public virtual void MouseMove(MouseEventArgs e) { }
|
||||
public virtual void MouseUp(MouseEventArgs e) { }
|
||||
public virtual void RedrawDisplay() { }
|
||||
public virtual void RefreshDisplay() { }
|
||||
public virtual void KeyDown(KeyEventArgs e) { }
|
||||
public virtual void KeyUp(KeyEventArgs e) { }
|
||||
public virtual void MouseInput(Vector2D delta) { }
|
||||
|
||||
/// <summary>
|
||||
/// NOTE: Do not call directly! Only for overriding. Call General.Interface.RedrawDisplay() instead.
|
||||
/// </summary>
|
||||
public virtual void RedrawDisplay() { }
|
||||
public virtual void RefreshDisplay() { }
|
||||
|
||||
public virtual void Process() { }
|
||||
|
||||
#endregion
|
||||
|
|
Loading…
Reference in a new issue