1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

Move stardifficulty logic to main BeatmapInfoWedge class instead of text subclass ( for use by background star rating colour bar )

This commit is contained in:
mk56-spn 2023-01-07 23:53:19 +01:00
parent f561120295
commit c646f8479b

View File

@ -37,10 +37,16 @@ namespace osu.Game.Screens.Select
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; }
protected Container DisplayedContent { get; private set; }
protected WedgeInfoText Info { get; private set; }
private IBindable<StarDifficulty?> starDifficulty;
private CancellationTokenSource cancellationSource;
public BeatmapInfoWedgeV2()
{
Shear = wedged_container_shear;
@ -98,6 +104,19 @@ namespace osu.Game.Screens.Select
private Container loadingInfo;
protected override void LoadComplete()
{
base.LoadComplete();
starDifficulty = difficultyCache.GetBindableDifficulty(beatmap.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
cancellationSource?.Cancel();
}
private void updateDisplay()
{
Scheduler.AddOnce(perform);
@ -127,7 +146,7 @@ namespace osu.Game.Screens.Select
Children = new Drawable[]
{
new BeatmapInfoWedgeBackground(beatmap),
Info = new WedgeInfoText(beatmap),
Info = new WedgeInfoText(beatmap, starDifficulty),
}
}, loaded =>
{
@ -154,26 +173,22 @@ namespace osu.Game.Screens.Select
private ILocalisedBindableString artistBinding;
private readonly WorkingBeatmap working;
private readonly IBindable<StarDifficulty?> starDifficulty;
[Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private ModSettingChangeTracker settingChangeTracker;
public WedgeInfoText(WorkingBeatmap working)
public WedgeInfoText(WorkingBeatmap working, IBindable<StarDifficulty?> starDifficulty)
{
this.working = working;
this.starDifficulty = starDifficulty;
}
private CancellationTokenSource cancellationSource;
private IBindable<StarDifficulty?> starDifficulty;
[BackgroundDependencyLoader]
private void load(LocalisationManager localisation)
{
@ -309,7 +324,6 @@ namespace osu.Game.Screens.Select
difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue);
}, true);
starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token);
starDifficulty.BindValueChanged(s =>
{
starRatingDisplay.Current.Value = s.NewValue ?? default;
@ -349,7 +363,6 @@ namespace osu.Game.Screens.Select
{
base.Dispose(isDisposing);
settingChangeTracker?.Dispose();
cancellationSource?.Cancel();
}
}
}