1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 04:22:54 +08:00

Position tooltip better; remove need for lastState.

This commit is contained in:
Dean Herbert 2017-04-20 16:08:36 +09:00
parent 00d8cacba8
commit a884ac215e
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49

View File

@ -30,8 +30,6 @@ namespace osu.Game.Graphics.Cursor
private IHasTooltip currentlyDisplayed; private IHasTooltip currentlyDisplayed;
private IMouseState lastState;
public TooltipContainer(CursorContainer cursor) public TooltipContainer(CursorContainer cursor)
{ {
this.cursor = cursor; this.cursor = cursor;
@ -48,21 +46,18 @@ namespace osu.Game.Graphics.Cursor
protected override void Update() protected override void Update()
{ {
if (tooltip.IsPresent && lastState != null) if (tooltip.IsPresent)
{ {
if (currentlyDisplayed != null) if (currentlyDisplayed != null)
tooltip.TooltipText = currentlyDisplayed.TooltipText; tooltip.TooltipText = currentlyDisplayed.TooltipText;
//update the position of the displayed tooltip. //update the position of the displayed tooltip.
tooltip.Position = new Vector2( tooltip.Position = ToLocalSpace(cursor.ActiveCursor.ScreenSpaceDrawQuad.Centre) + new Vector2(10);
lastState.Position.X,
Math.Min(cursor.ActiveCursor.BoundingBox.Bottom, lastState.Position.Y + cursor.ActiveCursor.DrawHeight));
} }
} }
protected override bool OnMouseMove(InputState state) protected override bool OnMouseMove(InputState state)
{ {
lastState = state.Mouse;
if (currentlyDisplayed?.Hovering != true) if (currentlyDisplayed?.Hovering != true)
{ {