1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-10 19:38:43 +02:00

Prefer elements that have the same parent as the currently selected element when using gamepad navigation

This commit is contained in:
Ell 2022-03-10 15:00:42 +01:00
parent 45955bb5e8
commit a14a37cb91
2 changed files with 3 additions and 1 deletions

View file

@ -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

View file

@ -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;
}