mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
Allow specifying a custom position for a tooltip to snap to
This commit is contained in:
parent
f166c3d256
commit
b77edd80d5
2 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
/// </summary>
|
||||
public Paragraph Paragraph;
|
||||
/// <summary>
|
||||
/// The position that this tooltip should be following (or snapped to) instead of the <see cref="InputHandler.ViewportMousePosition"/>.
|
||||
/// If this value is unset, <see cref="InputHandler.ViewportMousePosition"/> will be used as the snap position.
|
||||
/// Note that <see cref="MouseOffset"/> is still applied with this value set.
|
||||
/// </summary>
|
||||
public virtual Vector2? SnapPosition { get; set; }
|
||||
|
||||
private TimeSpan delayCountdown;
|
||||
private bool autoHidden;
|
||||
|
@ -91,7 +98,8 @@ namespace MLEM.Ui.Elements {
|
|||
/// </summary>
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue