1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:42:54 +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
{
[Cached]
public partial class BeatmapInfoWedgeV2 : VisibilityContainer
{
private const float shear_width = 21;
@ -41,6 +40,9 @@ namespace osu.Game.Screens.Select
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
protected Container? DisplayedContent { get; private set; }
protected WedgeInfoText? Info { get; private set; }
@ -183,6 +185,14 @@ namespace osu.Game.Screens.Select
removeOldInfo();
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 ArtistLabel { get; private set; } = null!;
private StarRatingDisplay starRatingDisplay = null!;
public StarRatingDisplay StarRatingDisplay = null!;
private ILocalisedBindableString titleBinding = null!;
private ILocalisedBindableString artistBinding = null!;
@ -202,15 +212,9 @@ namespace osu.Game.Screens.Select
[Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
[Resolved]
private OsuColour colours { get; set; } = null!;
[Resolved]
private BeatmapDifficultyCache difficultyCache { get; set; } = null!;
[Resolved]
private BeatmapInfoWedgeV2 wedge { get; set; } = null!;
private ModSettingChangeTracker? settingChangeTracker;
private IBindable<StarDifficulty?>? starDifficulty;
@ -246,7 +250,7 @@ namespace osu.Game.Screens.Select
Spacing = new Vector2(0f, 5f),
Children = new Drawable[]
{
starRatingDisplay = new StarRatingDisplay(default, animated: true)
StarRatingDisplay = new StarRatingDisplay(default, animated: true)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
@ -302,24 +306,16 @@ namespace osu.Game.Screens.Select
{
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.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.)
if (!starRatingDisplay.IsPresent)
starRatingDisplay.FinishTransforms(true);
if (!StarRatingDisplay.IsPresent)
StarRatingDisplay.FinishTransforms(true);
starRatingDisplay.FadeIn(transition_duration);
StarRatingDisplay.FadeIn(transition_duration);
});
mods.BindValueChanged(m =>