diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index ed57dad644..db81d22844 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -28,6 +28,7 @@ namespace osu.Game.Screens.Play private readonly SongProgressBar bar; private readonly SongProgressGraph graph; + private readonly SongProgressInfo info; public Action OnSeek; @@ -62,6 +63,14 @@ namespace osu.Game.Screens.Play Children = new Drawable[] { + info = new SongProgressInfo + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Y = -(bottom_bar_height + graph_height), + }, graph = new SongProgressGraph { RelativeSizeAxes = Axes.X, @@ -130,10 +139,15 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double progress = ((AudioClock?.CurrentTime ?? Time.Current) - firstHitTime) / lastHitTime; + double currentTime = (AudioClock?.CurrentTime ?? Time.Current); + double progress = (currentTime - firstHitTime) / lastHitTime; bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); + + info.TimeCurrent = TimeSpan.FromMilliseconds(currentTime).ToString(@"m\:ss"); + info.TimeLeft = TimeSpan.FromMilliseconds(lastHitTime - currentTime).ToString(@"m\:ss"); + info.Progress = ((int)(currentTime / lastHitTime * 100)).ToString(); } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs new file mode 100644 index 0000000000..7f32c18957 --- /dev/null +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -0,0 +1,87 @@ +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Primitives; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play +{ + public class SongProgressInfo : Container + { + private InfoText timeCurrent; + private InfoText timeLeft; + private InfoText progress; + + private const int margin = 10; + + public string TimeCurrent + { + set + { + timeCurrent.Text = value; + } + } + + public string TimeLeft + { + set + { + timeLeft.Text = @"-" + value; + } + } + public string Progress + { + set + { + progress.Text = value + @"%"; + } + } + + public SongProgressInfo() + { + Children = new Drawable[] + { + timeCurrent = new InfoText + { + Origin = Anchor.BottomLeft, + Anchor = Anchor.BottomLeft, + Margin = new MarginPadding + { + Left = margin, + }, + }, + progress = new InfoText + { + Origin = Anchor.BottomCentre, + Anchor = Anchor.BottomCentre, + }, + timeLeft = new InfoText + { + Origin = Anchor.BottomRight, + Anchor = Anchor.BottomRight, + Margin = new MarginPadding + { + Right = margin, + } + } + }; + } + + private class InfoText : OsuSpriteText + { + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + Colour = colours.BlueLighter; + Font = @"Venera"; + EdgeEffect = new EdgeEffect + { + Colour = colours.BlueDarker, + Type = EdgeEffectType.Glow, + Radius = 5, + }; + } + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index cb491055c4..6d7a1c43cd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -224,6 +224,7 @@ +