Visual Mode: added toggleable option to select all adjacent visual vertex slope handle when selecting a visual slope vertex handle. The action is called "Toggle Adjacent Visual Vertex Slope Selection"

This commit is contained in:
biwa 2022-01-07 16:28:06 +01:00
parent cfada3b4c9
commit 9612b80924
5 changed files with 91 additions and 1 deletions

View file

@ -143,6 +143,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool eventlinedistinctcolors;
private bool useoppositesmartpivothandle;
private bool selectchangedafterundoredo;
private bool selectadjacentvisualvertexslopehandles;
#endregion
@ -203,6 +204,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool EventLineDistinctColors { get { return eventlinedistinctcolors; } internal set { eventlinedistinctcolors = value; } }
public bool UseOppositeSmartPivotHandle { get { return useoppositesmartpivothandle; } internal set { useoppositesmartpivothandle = value; } }
public bool SelectChangedafterUndoRedo { get { return selectchangedafterundoredo; } internal set { selectchangedafterundoredo = value; } }
public bool SelectAdjacentVisualVertexSlopeHandles { get { return selectadjacentvisualvertexslopehandles; } internal set { selectadjacentvisualvertexslopehandles = value; } }
//mxd. "Make Door" action persistent settings
internal MakeDoorSettings MakeDoor;

View file

@ -1436,6 +1436,16 @@ togglevisualvertexslopepicking
allowscroll = false;
}
togglevisualvertexslopeadjacentselection
{
title = "Toggle Adjacent Visual Vertex Slope Selection";
category = "visual";
description = "Toggles selection of adjacent visual vertex slopes, so that selecting one visual vertex slope handle will select all adjacent visual vertex slope handles.";
allowkeys = true;
allowmouse = true;
allowscroll = false;
}
resetslope
{
title = "Reset Plane Slope";

View file

@ -4470,6 +4470,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
[BeginAction("togglevisualvertexslopeadjacentselection")]
public void ToggleVisualVertexSlopeAdjacentSelection()
{
if (!General.Map.UDMF)
{
General.Interface.DisplayStatus(StatusType.Warning, "Visual sloping is supported in UDMF only!");
return;
}
BuilderPlug.Me.SelectAdjacentVisualVertexSlopeHandles = !BuilderPlug.Me.SelectAdjacentVisualVertexSlopeHandles;
General.Interface.DisplayStatus(StatusType.Action, "Adjacant selection of visual vertex slop handles is " + (BuilderPlug.Me.SelectAdjacentVisualVertexSlopeHandles ? "ENABLED" : "DISABLED"));
}
[BeginAction("resetslope")]
public void ResetSlope()

View file

@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.VisualModes
#region ================== Events
// Select or deselect
public void OnSelectEnd()
public virtual void OnSelectEnd()
{
if (this.selected)
{

View file

@ -356,6 +356,70 @@ namespace CodeImp.DoomBuilder.VisualModes
mode.SetActionResult("Changed slope.");
}
public override void OnSelectEnd()
{
// The base's OnSelectEnd might not change the selection status if the user tries to select
// a pivot handle, so we have to check if the selection status changed
bool oldselected = selected;
base.OnSelectEnd();
if (selected != oldselected && BuilderPlug.Me.SelectAdjacentVisualVertexSlopeHandles)
{
HashSet<Sector> sectors = new HashSet<Sector>();
// Get the z position of this vertex slope handle. By comparing the t position of
// other vertex slope handles we can find the ones that are really adjacent, since
// there can be many vertex slope handles on one vertex on different heights especially
// with 3D floors. The rounding is done since there can be the tiniest differences in
// the planes, which lead to different z positions even when they are the "same".
double z = Math.Round(level.plane.GetZ(vertex.Position), 5);
// Get all sectors around the this slope handle's vertex
foreach (Linedef ld in vertex.Linedefs)
{
if (ld.Front != null)
sectors.Add(ld.Front.Sector);
if (ld.Back != null)
sectors.Add(ld.Back.Sector);
}
foreach (Sector s in sectors)
{
foreach (VisualVertexSlope vs in mode.VertexSlopeHandles[s])
{
if (vs.vertex != vertex || vs == this)
continue;
// See above for the explanation of the rounding
double z1 = Math.Round(vs.level.plane.GetZ(vertex.Position), 5);
if (z == z1)
{
if (selected)
{
if (!vs.selected)
{
vs.selected = true;
mode.AddSelectedObject(vs);
mode.UsedSlopeHandles.Add(vs);
}
}
else
{
if (vs.selected)
{
vs.selected = false;
mode.RemoveSelectedObject(vs);
mode.UsedSlopeHandles.Remove(vs);
}
}
}
}
}
}
}
#endregion
}
}