From 42f64c2c44f34bceb9fbbadb8a5cb6d2f8ed04aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 14:48:33 +0900 Subject: [PATCH] Move load procedure to async method and simplify code --- .../Screens/Play/HUD/PlayerSettingsOverlay.cs | 2 ++ osu.Game/Screens/Play/ReplayPlayer.cs | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index b7f3dc36c3..8c74b0254d 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -41,5 +41,7 @@ public PlayerSettingsOverlay() protected override void PopIn() => this.FadeIn(fade_duration); protected override void PopOut() => this.FadeOut(fade_duration); + + public void Insert(int i, PlayerSettingsGroup drawable) => content.Insert(i, drawable); } } diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index f6e4ac489a..39df223a9d 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; @@ -50,18 +51,19 @@ public ReplayPlayer(Func, Score> createScore, Playe this.createScore = createScore; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load() { - base.LoadComplete(); - - if (HUDOverlay != null) + var playbackSettings = new PlaybackSettings { - var playerSettingsOverlay = new PlaybackSettings { Expanded = { Value = false } }; - HUDOverlay.PlayerSettingsOverlay.Add(playerSettingsOverlay); + Depth = float.MaxValue, + Expanded = { Value = false } + }; - if (GameplayClockContainer is MasterGameplayClockContainer master) - playerSettingsOverlay.UserPlaybackRate.BindTarget = master.UserPlaybackRate; - } + if (GameplayClockContainer is MasterGameplayClockContainer master) + playbackSettings.UserPlaybackRate.BindTo(master.UserPlaybackRate); + + HUDOverlay.PlayerSettingsOverlay.Insert(-1, playbackSettings); } protected override void PrepareReplay()