1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 06:28:35 +01:00

Fixed gamepad auto-nav angle being incorrect for some elements

This commit is contained in:
Ell 2022-05-26 11:39:55 +02:00
parent b9f2de8290
commit 951f4babd5
2 changed files with 2 additions and 1 deletions

View file

@ -43,6 +43,7 @@ Fixes
- Fixed elements not being deselected when removed through RemoveChild - Fixed elements not being deselected when removed through RemoveChild
- Fixed elements sometimes staying hidden when they shouldn't in scrolling panels - 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 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 Removals
- Marked old Draw and DrawTransformed overloads as obsolete in favor of SpriteBatchContext ones - Marked old Draw and DrawTransformed overloads as obsolete in favor of SpriteBatchContext ones

View file

@ -415,7 +415,7 @@ namespace MLEM.Ui {
if (child == this.SelectedElement) if (child == this.SelectedElement)
continue; continue;
var (xOffset, yOffset) = child.Area.Center - this.SelectedElement.Area.Center; 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) if (angle >= MathHelper.PiOver2 - Element.Epsilon)
continue; continue;
var distSq = child.Area.DistanceSquared(this.SelectedElement.Area); var distSq = child.Area.DistanceSquared(this.SelectedElement.Area);