1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Merge pull request #17923 from peppy/fix-difficulty-tooltip-visibility

Fix high star ratings not being easily visible on tooltips
This commit is contained in:
Dan Balasescu 2022-04-22 16:49:32 +09:00 committed by GitHub
commit ca6c292a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<DifficultyIconTooltipContent>
{
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> starDifficulty = new Bindable<StarDifficulty>();
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;