Move load procedure to async method and simplify code

This commit is contained in:
Dean Herbert 2024-01-17 14:48:33 +09:00
parent ccbba8a00b
commit 42f64c2c44
No known key found for this signature in database
2 changed files with 13 additions and 9 deletions

View File

@ -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);
}
}

View File

@ -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<IBeatmap, IReadOnlyList<Mod>, 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()