diff --git a/CHANGELOG.md b/CHANGELOG.md index 3141739..d7ab2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Improvements - Allow ElementHelper's KeybindButton to query a combination at a given index - Automatically select the first element when a dropdown is opened in auto nav mode - Improved gamepad navigation by employing angles between elements +- Prefer elements that have the same parent as the currently selected element when using gamepad navigation Fixes - Fixed paragraph links having incorrect hover locations when using special text alignments diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs index f7efd18..bbb691e 100644 --- a/MLEM.Ui/UiControls.cs +++ b/MLEM.Ui/UiControls.cs @@ -377,7 +377,8 @@ namespace MLEM.Ui { if (Math.Abs(direction.Angle() - Math.Atan2(distVec.Y, distVec.X)) >= MathHelper.PiOver2 - Element.Epsilon) continue; var distSq = distVec.LengthSquared(); - if (closest == null || distSq < closestDistSq) { + // prefer navigating to elements that have the same parent as the currently selected element + if (closest == null || distSq < closestDistSq || closest.Parent != this.SelectedElement.Parent && child.Parent == this.SelectedElement.Parent) { closest = child; closestDistSq = distSq; }