diff --git a/osu.Game/Screens/Play/SongProgress.cs b/osu.Game/Screens/Play/SongProgress.cs index 35aeb33528..b0a77afa51 100644 --- a/osu.Game/Screens/Play/SongProgress.cs +++ b/osu.Game/Screens/Play/SongProgress.cs @@ -139,15 +139,16 @@ namespace osu.Game.Screens.Play if (objects == null) return; - double currentTime = AudioClock?.CurrentTime ?? Time.Current; - double progress = (currentTime - firstHitTime) / lastHitTime; + double drawableCurrentTime = AudioClock?.CurrentTime ?? Time.Current; + double songCurrentTime = drawableCurrentTime - firstHitTime; + double progress = songCurrentTime / lastHitTime; bar.UpdatePosition((float)progress); graph.Progress = (int)(graph.ColumnCount * progress); - info.TimeCurrent = currentTime; - info.TimeLeft = lastHitTime - currentTime; - info.Progress = (int)(currentTime / lastHitTime * 100); + info.Progress = (int)(progress * 100); + info.TimeCurrent = songCurrentTime; + info.TimeLeft = lastHitTime - firstHitTime - songCurrentTime; } } } diff --git a/osu.Game/Screens/Play/SongProgressInfo.cs b/osu.Game/Screens/Play/SongProgressInfo.cs index ffee4e4094..17623ca9f7 100644 --- a/osu.Game/Screens/Play/SongProgressInfo.cs +++ b/osu.Game/Screens/Play/SongProgressInfo.cs @@ -13,22 +13,54 @@ namespace osu.Game.Screens.Play { public class SongProgressInfo : Container { - private OsuSpriteText timeCurrent; + private OsuSpriteText timeCurrentText; private OsuSpriteText timeLeft; - private OsuSpriteText progress; + private OsuSpriteText progressText; + + private int progress; + private double timeCurrent; private const int margin = 10; - public double TimeCurrent { set { timeCurrent.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public double TimeLeft { set { timeLeft.Text = @"- " + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); } } - public int Progress { set { progress.Text = value.ToString() + @"%"; } } + public double TimeCurrent + { + set + { + timeCurrent = value; + + if (value > 0) + timeCurrentText.Text = TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + } + } + public double TimeLeft + { + set + { + if(timeCurrent < 0) + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value + timeCurrent).ToString(@"m\:ss"); + else + timeLeft.Text = @"-" + TimeSpan.FromMilliseconds(value).ToString(@"m\:ss"); + } + } + public int Progress + { + set + { + if (progress == value) + return; + + progress = value; + if (value > 0) + progressText.Text = value.ToString() + @"%"; + } + } [BackgroundDependencyLoader] private void load(OsuColour colours) { Children = new Drawable[] { - timeCurrent = new OsuSpriteText + timeCurrentText = new OsuSpriteText { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, @@ -38,13 +70,15 @@ namespace osu.Game.Screens.Play { Left = margin, }, + Text = @"0:00", }, - progress = new OsuSpriteText + progressText = new OsuSpriteText { Origin = Anchor.BottomCentre, Anchor = Anchor.BottomCentre, Colour = colours.BlueLighter, Font = @"Venera", + Text = @"0%", }, timeLeft = new OsuSpriteText {