From e798450abd324c63fb0a8ac3d175657674570714 Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Mon, 24 Feb 2020 13:57:26 +0100 Subject: [PATCH] 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. --- .../VisualModes/BaseVisualMode.cs | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 082ab0ed..1c581609 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -4036,17 +4036,63 @@ namespace CodeImp.DoomBuilder.BuilderModes [BeginAction("slopebetweenhandles")] public void SlopeBetweenHandles() { - List handles = GetSelectedSlopeHandles(); - if(handles.Count != 2) + List selectedsectors = GetSelectedObjects(true, false, false, false, false); + if (selectedsectors.Count == 0) { - General.Interface.DisplayStatus(StatusType.Warning, "You need to have exactly two slope handles selected to slope between them."); + General.Interface.DisplayStatus(StatusType.Warning, "You need to select floors or ceilings to slope between slope handles."); return; } - List selectedsectors = GetSelectedObjects(true, false, false, false, false); - if(selectedsectors.Count == 0) + List handles = GetSelectedSlopeHandles(); + + // No handles selected, try to slope between highlighted handle and it smart pivot + if (handles.Count == 0 && HighlightedTarget is VisualSidedefSlope) { - General.Interface.DisplayStatus(StatusType.Warning, "You need to select floors or ceilings to slope between slope handles."); + 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; }