mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 17:57:29 +08:00
Override OnMouseMove for cursor position fetching
This commit is contained in:
parent
5dd28d5352
commit
2d7fdaf892
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Colour;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -39,8 +38,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private float relativePositionX;
|
private float relativePositionX;
|
||||||
|
|
||||||
private InputManager? inputManager;
|
|
||||||
|
|
||||||
public LocalisableString TooltipText => $"{(relativePositionX > 0 ? (EndTime - StartTime) * relativePositionX / DrawWidth : relativePositionX > DrawWidth ? EndTime : 0).ToEditorFormattedString()}"
|
public LocalisableString TooltipText => $"{(relativePositionX > 0 ? (EndTime - StartTime) * relativePositionX / DrawWidth : relativePositionX > DrawWidth ? EndTime : 0).ToEditorFormattedString()}"
|
||||||
+ $" - {(relativePositionX > 0 ? Math.Round(relativePositionX / DrawWidth * 100, 2) : relativePositionX > DrawWidth ? 100 : 0)}%";
|
+ $" - {(relativePositionX > 0 ? Math.Round(relativePositionX / DrawWidth * 100, 2) : relativePositionX > DrawWidth ? 100 : 0)}%";
|
||||||
|
|
||||||
@ -85,7 +82,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
catchUpColour = colours.BlueDark;
|
catchUpColour = colours.BlueDark;
|
||||||
inputManager = GetContainingInputManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -96,6 +92,16 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
playfieldBar.TransformTo(nameof(playfieldBar.AccentColour), mainColour, 200, Easing.In);
|
playfieldBar.TransformTo(nameof(playfieldBar.AccentColour), mainColour, 200, Easing.In);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
|
{
|
||||||
|
base.OnMouseMove(e);
|
||||||
|
|
||||||
|
var cursorPosition = e.ScreenSpaceMousePosition;
|
||||||
|
relativePositionX = ToLocalSpace(cursorPosition).X;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (Interactive)
|
if (Interactive)
|
||||||
@ -114,18 +120,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (inputManager != null)
|
|
||||||
{
|
|
||||||
// Update the cursor position in time
|
|
||||||
var cursorPosition = inputManager.CurrentState.Mouse.Position;
|
|
||||||
relativePositionX = ToLocalSpace(cursorPosition).X;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If null (e.g. before the game starts), try getting the input manager again
|
|
||||||
inputManager = GetContainingInputManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
playfieldBar.Length = (float)Interpolation.Lerp(playfieldBar.Length, Progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
playfieldBar.Length = (float)Interpolation.Lerp(playfieldBar.Length, Progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, AudioProgress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, AudioProgress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user