1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:43:02 +08:00

Expose star difficulty to wedge to allow updating starcounter and background colour internally.

This commit is contained in:
mk56-spn 2023-01-18 13:55:52 +01:00
parent 74b72e4ac0
commit 0ac7cd7409

View File

@ -24,7 +24,6 @@ using osu.Game.Rulesets.Mods;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
[Cached]
public partial class BeatmapInfoWedgeV2 : VisibilityContainer public partial class BeatmapInfoWedgeV2 : VisibilityContainer
{ {
private const float shear_width = 21; private const float shear_width = 21;
@ -41,6 +40,9 @@ namespace osu.Game.Screens.Select
[Resolved] [Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!; private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
protected Container? DisplayedContent { get; private set; } protected Container? DisplayedContent { get; private set; }
protected WedgeInfoText? Info { get; private set; } protected WedgeInfoText? Info { get; private set; }
@ -183,6 +185,14 @@ namespace osu.Game.Screens.Select
removeOldInfo(); removeOldInfo();
Add(DisplayedContent = loaded); Add(DisplayedContent = loaded);
Info.StarRatingDisplay.DisplayedStars.BindValueChanged(s =>
{
starCounter.Current = (float)s.NewValue;
starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f);
difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue));
}, true);
}); });
} }
} }
@ -192,7 +202,7 @@ namespace osu.Game.Screens.Select
public OsuSpriteText TitleLabel { get; private set; } = null!; public OsuSpriteText TitleLabel { get; private set; } = null!;
public OsuSpriteText ArtistLabel { get; private set; } = null!; public OsuSpriteText ArtistLabel { get; private set; } = null!;
private StarRatingDisplay starRatingDisplay = null!; public StarRatingDisplay StarRatingDisplay = null!;
private ILocalisedBindableString titleBinding = null!; private ILocalisedBindableString titleBinding = null!;
private ILocalisedBindableString artistBinding = null!; private ILocalisedBindableString artistBinding = null!;
@ -202,15 +212,9 @@ namespace osu.Game.Screens.Select
[Resolved] [Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!; private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } = null!; private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
[Resolved]
private BeatmapInfoWedgeV2 wedge { get; set; } = null!;
private ModSettingChangeTracker? settingChangeTracker; private ModSettingChangeTracker? settingChangeTracker;
private IBindable<StarDifficulty?>? starDifficulty; private IBindable<StarDifficulty?>? starDifficulty;
@ -246,7 +250,7 @@ namespace osu.Game.Screens.Select
Spacing = new Vector2(0f, 5f), Spacing = new Vector2(0f, 5f),
Children = new Drawable[] Children = new Drawable[]
{ {
starRatingDisplay = new StarRatingDisplay(default, animated: true) StarRatingDisplay = new StarRatingDisplay(default, animated: true)
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
@ -302,24 +306,16 @@ namespace osu.Game.Screens.Select
{ {
base.LoadComplete(); base.LoadComplete();
starRatingDisplay.DisplayedStars.BindValueChanged(s =>
{
wedge.starCounter.Current = (float)s.NewValue;
wedge.starCounter.Colour = s.NewValue >= 6.5 ? colours.Orange1 : Colour4.Black.Opacity(0.75f);
wedge.difficultyColourBar.FadeColour(colours.ForStarDifficulty(s.NewValue));
}, true);
starDifficulty = difficultyCache.GetBindableDifficulty(working.BeatmapInfo, (cancellationSource = new CancellationTokenSource()).Token); 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;
// Don't roll the counter on initial display (but still allow it to roll on applying mods etc.) // Don't roll the counter on initial display (but still allow it to roll on applying mods etc.)
if (!starRatingDisplay.IsPresent) if (!StarRatingDisplay.IsPresent)
starRatingDisplay.FinishTransforms(true); StarRatingDisplay.FinishTransforms(true);
starRatingDisplay.FadeIn(transition_duration); StarRatingDisplay.FadeIn(transition_duration);
}); });
mods.BindValueChanged(m => mods.BindValueChanged(m =>