diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f0315..5dda420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Improvements - 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 +- Allow specifying a custom position for a tooltip to snap to Fixes - Fixed paragraph links having incorrect hover locations when using special text alignments diff --git a/MLEM.Ui/Elements/Tooltip.cs b/MLEM.Ui/Elements/Tooltip.cs index c2be313..62d92ef 100644 --- a/MLEM.Ui/Elements/Tooltip.cs +++ b/MLEM.Ui/Elements/Tooltip.cs @@ -1,5 +1,6 @@ using System; using Microsoft.Xna.Framework; +using MLEM.Input; using MLEM.Ui.Style; namespace MLEM.Ui.Elements { @@ -22,6 +23,12 @@ namespace MLEM.Ui.Elements { /// The paragraph of text that this tooltip displays /// public Paragraph Paragraph; + /// + /// The position that this tooltip should be following (or snapped to) instead of the . + /// If this value is unset, will be used as the snap position. + /// Note that is still applied with this value set. + /// + public virtual Vector2? SnapPosition { get; set; } private TimeSpan delayCountdown; private bool autoHidden; @@ -91,7 +98,8 @@ namespace MLEM.Ui.Elements { /// public void SnapPositionToMouse() { var viewport = this.System.Viewport; - var offset = (this.Input.ViewportMousePosition.ToVector2() + this.MouseOffset.Value) / this.Scale; + var snapPosition = this.SnapPosition ?? this.Input.ViewportMousePosition.ToVector2(); + var offset = (snapPosition + this.MouseOffset.Value) / this.Scale; if (offset.X < viewport.X) offset.X = viewport.X; if (offset.Y < viewport.Y)