mirror of
https://github.com/ppy/osu
synced 2024-12-29 18:32:39 +00:00
Fix high star ratings not being easily visible on tooltips
Resolves issue mentioned in https://github.com/ppy/osu/discussions/17920.
This commit is contained in:
parent
51eee511b0
commit
c44f7d9f93
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user