mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 08:52:58 +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:
parent
f561120295
commit
c646f8479b
@ -37,10 +37,16 @@ namespace osu.Game.Screens.Select
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapDifficultyCache difficultyCache { get; set; }
|
||||||
|
|
||||||
protected Container DisplayedContent { get; private set; }
|
protected Container DisplayedContent { get; private set; }
|
||||||
|
|
||||||
protected WedgeInfoText Info { get; private set; }
|
protected WedgeInfoText Info { get; private set; }
|
||||||
|
|
||||||
|
private IBindable<StarDifficulty?> starDifficulty;
|
||||||
|
private CancellationTokenSource cancellationSource;
|
||||||
|
|
||||||
public BeatmapInfoWedgeV2()
|
public BeatmapInfoWedgeV2()
|
||||||
{
|
{
|
||||||
Shear = wedged_container_shear;
|
Shear = wedged_container_shear;
|
||||||
@ -98,6 +104,19 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private Container loadingInfo;
|
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()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
Scheduler.AddOnce(perform);
|
Scheduler.AddOnce(perform);
|
||||||
@ -127,7 +146,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new BeatmapInfoWedgeBackground(beatmap),
|
new BeatmapInfoWedgeBackground(beatmap),
|
||||||
Info = new WedgeInfoText(beatmap),
|
Info = new WedgeInfoText(beatmap, starDifficulty),
|
||||||
}
|
}
|
||||||
}, loaded =>
|
}, loaded =>
|
||||||
{
|
{
|
||||||
@ -154,26 +173,22 @@ namespace osu.Game.Screens.Select
|
|||||||
private ILocalisedBindableString artistBinding;
|
private ILocalisedBindableString artistBinding;
|
||||||
|
|
||||||
private readonly WorkingBeatmap working;
|
private readonly WorkingBeatmap working;
|
||||||
|
private readonly IBindable<StarDifficulty?> starDifficulty;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private BeatmapDifficultyCache difficultyCache { get; set; }
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private ModSettingChangeTracker settingChangeTracker;
|
private ModSettingChangeTracker settingChangeTracker;
|
||||||
|
|
||||||
public WedgeInfoText(WorkingBeatmap working)
|
public WedgeInfoText(WorkingBeatmap working, IBindable<StarDifficulty?> starDifficulty)
|
||||||
{
|
{
|
||||||
this.working = working;
|
this.working = working;
|
||||||
|
this.starDifficulty = starDifficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource cancellationSource;
|
|
||||||
private IBindable<StarDifficulty?> starDifficulty;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationManager localisation)
|
private void load(LocalisationManager localisation)
|
||||||
{
|
{
|
||||||
@ -309,7 +324,6 @@ namespace osu.Game.Screens.Select
|
|||||||
difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue);
|
difficultyColourBar.Colour = colours.ForStarDifficulty(s.NewValue);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token);
|
|
||||||
starDifficulty.BindValueChanged(s =>
|
starDifficulty.BindValueChanged(s =>
|
||||||
{
|
{
|
||||||
starRatingDisplay.Current.Value = s.NewValue ?? default;
|
starRatingDisplay.Current.Value = s.NewValue ?? default;
|
||||||
@ -349,7 +363,6 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
settingChangeTracker?.Dispose();
|
settingChangeTracker?.Dispose();
|
||||||
cancellationSource?.Cancel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user