From 951f4babd5e5d9e499f831488250b985c18c5efb Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 26 May 2022 11:39:55 +0200 Subject: [PATCH] Fixed gamepad auto-nav angle being incorrect for some elements --- CHANGELOG.md | 1 + MLEM.Ui/UiControls.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7014ff7..8675743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Fixes - Fixed elements not being deselected when removed through RemoveChild - Fixed elements sometimes staying hidden when they shouldn't in scrolling panels - Fixed elements' OnDeselected events not being raised when CanBeSelected is set to false while selected +- Fixed gamepad auto-nav angle being incorrect for some elements Removals - Marked old Draw and DrawTransformed overloads as obsolete in favor of SpriteBatchContext ones diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs index 81be1bb..7b8195f 100644 --- a/MLEM.Ui/UiControls.cs +++ b/MLEM.Ui/UiControls.cs @@ -415,7 +415,7 @@ namespace MLEM.Ui { if (child == this.SelectedElement) continue; var (xOffset, yOffset) = child.Area.Center - this.SelectedElement.Area.Center; - var angle = Math.Abs(direction.Angle() - (float) Math.Atan2(yOffset, xOffset)); + var angle = Math.Abs(MathHelper.WrapAngle(direction.Angle() - (float) Math.Atan2(yOffset, xOffset))); if (angle >= MathHelper.PiOver2 - Element.Epsilon) continue; var distSq = child.Area.DistanceSquared(this.SelectedElement.Area);