mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 08:42:56 +08:00
Merge pull request #30078 from CloneWith/update/progresshover
Add progress tooltip for ArgonSongProgressBar
This commit is contained in:
commit
944f8f5f67
@ -6,15 +6,17 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public partial class ArgonSongProgressBar : SongProgressBar
|
||||
public partial class ArgonSongProgressBar : SongProgressBar, IHasTooltip
|
||||
{
|
||||
// Parent will handle restricting the area of valid input.
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
@ -33,6 +35,23 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private double trackTime => (EndTime - StartTime) * Progress;
|
||||
|
||||
private float lastMouseX;
|
||||
|
||||
public LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
double progress = Math.Clamp(lastMouseX, 0, DrawWidth) / DrawWidth;
|
||||
|
||||
TimeSpan currentSpan = TimeSpan.FromMilliseconds(Math.Round((EndTime - StartTime) * progress));
|
||||
|
||||
int seconds = currentSpan.Duration().Seconds;
|
||||
int minutes = (int)Math.Floor(currentSpan.Duration().TotalMinutes);
|
||||
|
||||
return $"{minutes}:{seconds:D2} ({progress:P0})";
|
||||
}
|
||||
}
|
||||
|
||||
public ArgonSongProgressBar(float barHeight)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -84,6 +103,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
playfieldBar.TransformTo(nameof(playfieldBar.AccentColour), mainColour, 200, Easing.In);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
lastMouseX = e.MousePosition.X;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (Interactive)
|
||||
|
Loading…
Reference in New Issue
Block a user