From 2fbd49062690c2bc4dd2402552a1291425abcde3 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 6 Nov 2017 14:58:05 +0900 Subject: [PATCH] Make RemainingTimeCounter into a Counter --- .../Play/BreaksOverlay/BreakOverlay.cs | 3 ++- .../BreaksOverlay/RemainingTimeCounter.cs | 21 ++++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs index b3d08c0c82..6128a8f3d7 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/BreakOverlay.cs @@ -7,6 +7,7 @@ using osu.Framework.Graphics.Shapes; using osu.Game.Beatmaps.Timing; using osu.Game.Rulesets.Scoring; using System.Collections.Generic; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Screens.Play.BreaksOverlay { @@ -115,7 +116,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay .Then() .ResizeWidthTo(1); - remainingTimeCounter.CountTo(b.Duration); + remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration); } using (BeginAbsoluteSequence(b.StartTime)) diff --git a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs index e144ac25da..9b043a6e90 100644 --- a/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs +++ b/osu.Game/Screens/Play/BreaksOverlay/RemainingTimeCounter.cs @@ -6,10 +6,11 @@ using osu.Game.Graphics.Sprites; using osu.Framework.Graphics; using System; using osu.Game.Beatmaps.Timing; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Screens.Play.BreaksOverlay { - public class RemainingTimeCounter : Container + public class RemainingTimeCounter : Counter { private const double fade_duration = BreakPeriod.MIN_BREAK_DURATION / 2; @@ -18,7 +19,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay public RemainingTimeCounter() { AutoSizeAxes = Axes.Both; - Child = counter = new OsuSpriteText + InternalChild = counter = new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -29,21 +30,7 @@ namespace osu.Game.Screens.Play.BreaksOverlay Alpha = 0; } - public void CountTo(double duration) - { - double offset = 0; - - while (duration > 0) - { - int seconds = (int)Math.Ceiling(duration / 1000); - counter.Delay(offset).TransformTextTo(seconds.ToString()); - - double localOffset = duration - (seconds - 1) * 1000 + 1; // +1 because we want the duration to be the next second when ceiled - - offset += localOffset; - duration -= localOffset; - } - } + protected override void OnCountChanged(double count) => counter.Text = ((int)Math.Ceiling(count / 1000)).ToString(); public override void Show() => this.FadeIn(fade_duration); public override void Hide() => this.FadeOut(fade_duration);