The sloping between handles action is now a bit more convenient and tries to figure out what the user wants to do even if not exactly two slope handles are selected.

This commit is contained in:
biwa 2020-02-24 13:57:26 +01:00
parent afef349220
commit e798450abd

View file

@ -4036,13 +4036,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
[BeginAction("slopebetweenhandles")]
public void SlopeBetweenHandles()
{
List<VisualSidedefSlope> handles = GetSelectedSlopeHandles();
if(handles.Count != 2)
{
General.Interface.DisplayStatus(StatusType.Warning, "You need to have exactly two slope handles selected to slope between them.");
return;
}
List<IVisualEventReceiver> selectedsectors = GetSelectedObjects(true, false, false, false, false);
if (selectedsectors.Count == 0)
{
@ -4050,6 +4043,59 @@ namespace CodeImp.DoomBuilder.BuilderModes
return;
}
List<VisualSidedefSlope> handles = GetSelectedSlopeHandles();
// No handles selected, try to slope between highlighted handle and it smart pivot
if (handles.Count == 0 && HighlightedTarget is VisualSidedefSlope)
{
VisualSidedefSlope handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)HighlightedTarget, this);
if (handle == null)
{
General.Interface.DisplayStatus(StatusType.Warning, "Couldn't find a smart pivot handle.");
return;
}
handles.Add((VisualSidedefSlope)HighlightedTarget);
handles.Add(handle);
}
// One handle selected, try to slope between it and the highlighted handle or the selected one's smart pivot
else if (handles.Count == 1)
{
if (HighlightedTarget == handles[0] || !(HighlightedTarget is VisualSidedefSlope))
{
VisualSidedefSlope handle;
if(HighlightedTarget is VisualSidedefSlope)
handle = VisualSidedefSlope.GetSmartPivotHandle((VisualSidedefSlope)HighlightedTarget, this);
else
handle = VisualSidedefSlope.GetSmartPivotHandle(handles[0], this);
if (handle == null)
{
General.Interface.DisplayStatus(StatusType.Warning, "Couldn't find a smart pivot handle.");
return;
}
handles.Add(handle);
}
else
{
handles.Add((VisualSidedefSlope)HighlightedTarget);
}
}
// Return if more than two handles are selected
else if(handles.Count > 2)
{
General.Interface.DisplayStatus(StatusType.Warning, "Too many slope handles selected.");
return;
}
// Everything else
else if(handles.Count != 2)
{
General.Interface.DisplayStatus(StatusType.Warning, "No slope handles selected or highlighted.");
return;
}
General.Map.UndoRedo.CreateUndo("Slope between slope handles");
// Create the new plane