diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs index aba01a1294..5479644772 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIconTooltip.cs @@ -7,7 +7,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; @@ -16,11 +15,11 @@ namespace osu.Game.Beatmaps.Drawables { internal class DifficultyIconTooltip : VisibilityContainer, ITooltip { - private readonly OsuSpriteText difficultyName, starRating; - private readonly Box background; - private readonly FillFlowContainer difficultyFlow; + private OsuSpriteText difficultyName; + private StarRatingDisplay starRating; - public DifficultyIconTooltip() + [BackgroundDependencyLoader] + private void load(OsuColour colours) { AutoSizeAxes = Axes.Both; Masking = true; @@ -28,9 +27,10 @@ namespace osu.Game.Beatmaps.Drawables Children = new Drawable[] { - background = new Box + new Box { Alpha = 0.9f, + Colour = colours.Gray3, RelativeSizeAxes = Axes.Both }, new FillFlowContainer @@ -40,6 +40,7 @@ namespace osu.Game.Beatmaps.Drawables AutoSizeEasing = Easing.OutQuint, Direction = FillDirection.Vertical, Padding = new MarginPadding(10), + Spacing = new Vector2(5), Children = new Drawable[] { difficultyName = new OsuSpriteText @@ -48,57 +49,27 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.Centre, Font = OsuFont.GetFont(size: 16, weight: FontWeight.Bold), }, - difficultyFlow = new FillFlowContainer + starRating = new StarRatingDisplay(default, StarRatingDisplaySize.Small) { - AutoSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, - Direction = FillDirection.Horizontal, - Children = new Drawable[] - { - starRating = new OsuSpriteText - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Font = OsuFont.GetFont(size: 16, weight: FontWeight.Regular), - }, - new SpriteIcon - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Margin = new MarginPadding { Left = 4 }, - Icon = FontAwesome.Solid.Star, - Size = new Vector2(12), - }, - } } } } }; } - [Resolved] - private OsuColour colours { get; set; } - - [BackgroundDependencyLoader] - private void load() - { - background.Colour = colours.Gray3; - } - - private readonly IBindable starDifficulty = new Bindable(); + private DifficultyIconTooltipContent displayedContent; public void SetContent(DifficultyIconTooltipContent content) { - difficultyName.Text = content.BeatmapInfo.DifficultyName; + if (displayedContent != null) + starRating.Current.UnbindFrom(displayedContent.Difficulty); - starDifficulty.UnbindAll(); - starDifficulty.BindTo(content.Difficulty); - starDifficulty.BindValueChanged(difficulty => - { - starRating.Text = $"{difficulty.NewValue.Stars:0.##}"; - difficultyFlow.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars); - }, true); + displayedContent = content; + + starRating.Current.BindTarget = displayedContent.Difficulty; + difficultyName.Text = displayedContent.BeatmapInfo.DifficultyName; } public void Move(Vector2 pos) => Position = pos;