From 87bcd526f3637ff4dbe5d395df1cab92cfee7da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 17 Jul 2017 16:51:21 +0300 Subject: [PATCH] Get rid of raw AddDelay calls within osu.Game --- osu-framework | 2 +- .../Tests/TestCaseNotificationManager.cs | 5 +-- .../Tests/TestCaseTaikoPlayfield.cs | 8 +++-- .../Objects/Drawables/DrawableSliderTick.cs | 14 ++++---- .../Graphics/UserInterface/DialogButton.cs | 3 +- .../UserInterface/Volume/VolumeControl.cs | 3 +- osu.Game/OsuGame.cs | 3 +- osu.Game/Overlays/DialogOverlay.cs | 3 +- .../Notifications/ProgressNotification.cs | 5 +-- .../Rulesets/Judgements/DrawableJudgement.cs | 6 ++-- osu.Game/Screens/Menu/Disclaimer.cs | 17 ++++----- .../Screens/Play/HUD/StandardHealthDisplay.cs | 6 ++-- osu.Game/Screens/Play/PauseContainer.cs | 6 +--- osu.Game/Screens/Play/PlayerLoader.cs | 21 +++-------- osu.Game/Screens/Ranking/ResultsPage.cs | 3 +- osu.Game/Screens/Ranking/ResultsPageScore.cs | 6 ++-- osu.Game/Screens/ScreenWhiteBox.cs | 13 +++---- .../Select/Leaderboards/Leaderboard.cs | 4 +-- .../Select/Leaderboards/LeaderboardScore.cs | 35 ++++++++++--------- 19 files changed, 67 insertions(+), 96 deletions(-) diff --git a/osu-framework b/osu-framework index a3ed5b642f..8463ba949b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit a3ed5b642fcce039483801ca01fdbbf9117cec15 +Subproject commit 8463ba949b0a4a54c9aca157b2b24a8b0277608a diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index 837545b114..849df1263e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -56,10 +56,7 @@ namespace osu.Desktop.VisualTests.Tests } if (remaining > 0) - { - AddDelay(80); - Schedule(() => sendBarrage(remaining - 1)); - } + Scheduler.AddDelayed(() => sendBarrage(remaining - 1), 80); } protected override void Update() diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index 434689641f..8ca129eb91 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -67,6 +67,8 @@ namespace osu.Desktop.VisualTests.Tests private void changePlayfieldSize(int step) { + double delay = 0; + // Add new hits switch (step) { @@ -84,7 +86,7 @@ namespace osu.Desktop.VisualTests.Tests break; case 5: addSwell(1000); - playfieldContainer.AddDelay(scroll_time - 100); + delay = scroll_time - 100; break; } @@ -92,10 +94,10 @@ namespace osu.Desktop.VisualTests.Tests switch (step) { default: - playfieldContainer.ResizeTo(new Vector2(1, rng.Next(25, 400)), 500); + playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, rng.Next(25, 400)), 500); break; case 6: - playfieldContainer.ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT), 500); + playfieldContainer.Delay(delay).ResizeTo(new Vector2(1, TaikoPlayfield.DEFAULT_PLAYFIELD_HEIGHT), 500); break; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs index 92c7ff6f2a..f2631cf01c 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -62,14 +62,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { var animIn = Math.Min(150, sliderTick.StartTime - FadeInTime); - this.ScaleTo(0.5f); - this.ScaleTo(1.2f, animIn); - this.FadeIn(animIn); - - AddDelay(animIn); - this.ScaleTo(1, 150, EasingTypes.Out); - - AddDelay(-animIn); + this.Animate( + d => d.FadeIn(animIn), + d => d.ScaleTo(0.5f).ScaleTo(1.2f, animIn) + ).Then( + d => d.ScaleTo(1, 150, EasingTypes.Out) + ); } protected override void UpdateCurrentState(ArmedState state) diff --git a/osu.Game/Graphics/UserInterface/DialogButton.cs b/osu.Game/Graphics/UserInterface/DialogButton.cs index 67202c9e0d..460f4cea41 100644 --- a/osu.Game/Graphics/UserInterface/DialogButton.cs +++ b/osu.Game/Graphics/UserInterface/DialogButton.cs @@ -99,8 +99,7 @@ namespace osu.Game.Graphics.UserInterface colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, EasingTypes.In); flash(); - AddDelay(click_duration); - Schedule(delegate { + this.Delay(click_duration).Schedule(delegate { colourContainer.ResizeTo(new Vector2(0.8f, 1f)); spriteText.Spacing = Vector2.Zero; glowContainer.FadeOut(); diff --git a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs index 8c5347bd23..fa192b0825 100644 --- a/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs +++ b/osu.Game/Graphics/UserInterface/Volume/VolumeControl.cs @@ -106,8 +106,7 @@ namespace osu.Game.Graphics.UserInterface.Volume private void schedulePopOut() { popOutDelegate?.Cancel(); - AddDelay(1000); - popOutDelegate = Schedule(Hide); + this.Delay(1000).Schedule(Hide, out popOutDelegate); } } } \ No newline at end of file diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index e45f030fd1..0ab63c972f 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -119,8 +119,7 @@ namespace osu.Game if (!menu.IsCurrentScreen) { menu.MakeCurrent(); - AddDelay(500); - scoreLoad = Schedule(() => LoadScore(s)); + this.Delay(500).Schedule(() => LoadScore(s), out scoreLoad); return; } diff --git a/osu.Game/Overlays/DialogOverlay.cs b/osu.Game/Overlays/DialogOverlay.cs index c558ac5933..b384e110f9 100644 --- a/osu.Game/Overlays/DialogOverlay.cs +++ b/osu.Game/Overlays/DialogOverlay.cs @@ -35,8 +35,7 @@ namespace osu.Game.Overlays if (v != Visibility.Hidden) return; //handle the dialog being dismissed. - dialog.AddDelay(PopupDialog.EXIT_DURATION); - dialog.Expire(); + dialog.Delay(PopupDialog.EXIT_DURATION).Expire(); if (dialog == currentDialog) State = Visibility.Hidden; diff --git a/osu.Game/Overlays/Notifications/ProgressNotification.cs b/osu.Game/Overlays/Notifications/ProgressNotification.cs index 098088191f..bd7b8bf844 100644 --- a/osu.Game/Overlays/Notifications/ProgressNotification.cs +++ b/osu.Game/Overlays/Notifications/ProgressNotification.cs @@ -78,10 +78,7 @@ namespace osu.Game.Overlays.Notifications { case ProgressNotificationState.Completed: NotificationContent.MoveToY(-DrawSize.Y / 2, 200, EasingTypes.OutQuint); - this.FadeTo(0.01f, 200); //don't completely fade out or our scheduled task won't run. - - AddDelay(100); - Schedule(Completed); + this.FadeOut(200).Finally(d => Completed()); break; } } diff --git a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs index 5d471cb700..ac8a8e2005 100644 --- a/osu.Game/Rulesets/Judgements/DrawableJudgement.cs +++ b/osu.Game/Rulesets/Judgements/DrawableJudgement.cs @@ -75,15 +75,13 @@ namespace osu.Game.Rulesets.Judgements this.MoveToOffset(new Vector2(0, 100), 800, EasingTypes.InQuint); this.RotateTo(40, 800, EasingTypes.InQuint); - AddDelay(600); - this.FadeOut(200); + this.Delay(600).FadeOut(200); break; case HitResult.Hit: this.ScaleTo(0.9f); this.ScaleTo(1, 500, EasingTypes.OutElastic); - AddDelay(100); - this.FadeOut(400); + this.Delay(100).FadeOut(400); break; } diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index 908b64a3aa..6a176898a2 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -98,18 +98,13 @@ namespace osu.Game.Screens.Menu { base.OnEntering(last); - Content.FadeInFromZero(500); + icon.Delay(1500).FadeColour(iconColour, 200); - icon.AddDelay(1500); - icon.FadeColour(iconColour, 200); - - AddDelay(6000, true); - - Content.FadeOut(250); - - AddDelay(250); - - Schedule(() => Push(intro)); + Content + .FadeInFromZero(500) + .Then(5500) + .FadeOut(250) + .Finally(d => Push(intro)); } } } diff --git a/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs index 229c05859f..b4b3bd885e 100644 --- a/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs +++ b/osu.Game/Screens/Play/HUD/StandardHealthDisplay.cs @@ -97,9 +97,9 @@ namespace osu.Game.Screens.Play.HUD if (judgement.Result == HitResult.Miss) return; - fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, EasingTypes.OutQuint); - fill.AddDelay(glow_fade_delay); - fill.FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, EasingTypes.OutQuint); + fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, EasingTypes.OutQuint) + .Delay(glow_fade_delay) + .FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, EasingTypes.OutQuint); } protected override void SetHealth(float value) => fill.ResizeTo(new Vector2(value, 1), 200, EasingTypes.OutQuint); diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index 6683ba8fd5..eed5cd1c20 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -56,11 +56,7 @@ namespace osu.Game.Screens.Play AddInternal(pauseOverlay = new PauseOverlay { - OnResume = delegate - { - AddDelay(400); - Schedule(Resume); - }, + OnResume = () => this.Delay(400).Schedule(Resume), OnRetry = () => OnRetry(), OnQuit = () => OnQuit(), }); diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 50287ebe7d..9045067bd9 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -77,9 +77,7 @@ namespace osu.Game.Screens.Play Beatmap = player.Beatmap, }); - AddDelay(400); - - Schedule(pushWhenLoaded); + this.Delay(400).Schedule(pushWhenLoaded); } private void contentIn() @@ -104,16 +102,9 @@ namespace osu.Game.Screens.Play contentIn(); - AddDelay(500, true); - - logo.MoveToOffset(new Vector2(0, -180), 500, EasingTypes.InOutExpo); - AddDelay(250, true); - - info.FadeIn(500); - - AddDelay(1400, true); - - Schedule(pushWhenLoaded); + logo.Delay(500).MoveToOffset(new Vector2(0, -180), 500, EasingTypes.InOutExpo); + info.Delay(750).FadeIn(500); + this.Delay(2150).Schedule(pushWhenLoaded); } private void pushWhenLoaded() @@ -123,9 +114,7 @@ namespace osu.Game.Screens.Play contentOut(); - AddDelay(250); - - Schedule(() => + this.Delay(250).Schedule(() => { if (!IsCurrentScreen) return; diff --git a/osu.Game/Screens/Ranking/ResultsPage.cs b/osu.Game/Screens/Ranking/ResultsPage.cs index b88e993886..7f381ebf99 100644 --- a/osu.Game/Screens/Ranking/ResultsPage.cs +++ b/osu.Game/Screens/Ranking/ResultsPage.cs @@ -33,8 +33,7 @@ namespace osu.Game.Screens.Ranking protected override void LoadComplete() { base.LoadComplete(); - fill.AddDelay(400); - fill.FadeInFromZero(600); + fill.Delay(400).FadeInFromZero(600); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 4e3458e522..09db835144 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -178,9 +178,9 @@ namespace osu.Game.Screens.Ranking int delay = 0; foreach (var s in statisticsContainer.Children) { - s.FadeOut(); - s.AddDelay(delay += 200); - s.FadeIn(300 + delay, EasingTypes.Out); + s.FadeOut() + .Then(delay += 200) + .FadeIn(300 + delay, EasingTypes.Out); } }); } diff --git a/osu.Game/Screens/ScreenWhiteBox.cs b/osu.Game/Screens/ScreenWhiteBox.cs index 2ec721f0c0..7eac2407e9 100644 --- a/osu.Game/Screens/ScreenWhiteBox.cs +++ b/osu.Game/Screens/ScreenWhiteBox.cs @@ -44,13 +44,14 @@ namespace osu.Game.Screens boxContainer.ScaleTo(0.2f); boxContainer.RotateTo(-20); - Content.AddDelay(300, true); + using (Content.BeginDelayedSequence(300, true)) + { + boxContainer.ScaleTo(1, transition_time, EasingTypes.OutElastic); + boxContainer.RotateTo(0, transition_time / 2, EasingTypes.OutQuint); - boxContainer.ScaleTo(1, transition_time, EasingTypes.OutElastic); - boxContainer.RotateTo(0, transition_time / 2, EasingTypes.OutQuint); - - textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo); - Content.FadeIn(transition_time, EasingTypes.OutExpo); + textContainer.MoveTo(Vector2.Zero, transition_time, EasingTypes.OutExpo); + Content.FadeIn(transition_time, EasingTypes.OutExpo); + } } protected override bool OnExiting(Screen next) diff --git a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs index 4a00ef71a0..91bc55f143 100644 --- a/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs +++ b/osu.Game/Screens/Select/Leaderboards/Leaderboard.cs @@ -63,8 +63,8 @@ namespace osu.Game.Screens.Select.Leaderboards }; scrollFlow.Add(ls); - ls.AddDelay(i++ * 50, true); - ls.Show(); + using (BeginDelayedSequence(i++ * 50, true)) + ls.Show(); } scrollContainer.ScrollTo(0f, false); diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 3867d4e379..b0e234e5a2 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -64,23 +64,26 @@ namespace osu.Game.Screens.Select.Leaderboards this.FadeIn(200); content.MoveToY(0, 800, EasingTypes.OutQuint); - AddDelay(100, true); - avatar.FadeIn(300, EasingTypes.OutQuint); - nameLabel.FadeIn(350, EasingTypes.OutQuint); - - avatar.MoveToX(0, 300, EasingTypes.OutQuint); - nameLabel.MoveToX(0, 350, EasingTypes.OutQuint); - - AddDelay(250, true); - scoreLabel.FadeIn(200); - scoreRank.FadeIn(200); - - AddDelay(50, true); - var drawables = new Drawable[] { flagBadgeContainer, maxCombo, accuracy, modsContainer, }; - - for (int i = 0; i < drawables.Length; i++) + using (BeginDelayedSequence(100, true)) { - drawables[i].FadeIn(100 + i * 50); + avatar.FadeIn(300, EasingTypes.OutQuint); + nameLabel.FadeIn(350, EasingTypes.OutQuint); + + avatar.MoveToX(0, 300, EasingTypes.OutQuint); + nameLabel.MoveToX(0, 350, EasingTypes.OutQuint); + + using (BeginDelayedSequence(250, true)) + { + scoreLabel.FadeIn(200); + scoreRank.FadeIn(200); + + using (BeginDelayedSequence(50, true)) + { + var drawables = new Drawable[] { flagBadgeContainer, maxCombo, accuracy, modsContainer, }; + for (int i = 0; i < drawables.Length; i++) + drawables[i].FadeIn(100 + i * 50); + } + } } break;