Fixed race condition in StarRatingDisplay

This commit is contained in:
Denrage
2021-04-21 13:53:08 +02:00
parent e9571b72cf
commit de04caeace

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -28,9 +29,10 @@ namespace osu.Game.Screens.Ranking.Expanded
private OsuColour colours { get; set; } private OsuColour colours { get; set; }
private CircularContainer colorContainer; private CircularContainer colorContainer;
private OsuTextFlowContainer textContainer;
private CancellationTokenSource cancellationTokenSource; private CancellationTokenSource cancellationTokenSource;
private IBindable<StarDifficulty?> bindableStarDifficulty; private IBindable<StarDifficulty?> bindableStarDifficulty;
private OsuSpriteText wholePartText;
private OsuSpriteText fractionPartText;
private readonly StarDifficulty starDifficulty; private readonly StarDifficulty starDifficulty;
private readonly BeatmapInfo beatmapInfo; private readonly BeatmapInfo beatmapInfo;
@ -66,24 +68,10 @@ namespace osu.Game.Screens.Ranking.Expanded
colorContainer.Colour = backgroundColour; colorContainer.Colour = backgroundColour;
textContainer.Text = string.Empty; wholePartText.Text = $"{wholePart}";
fractionPartText.Text = $"{separator}{fractionPart}";
textContainer.With(t =>
{
t.AddText($"{wholePart}", s =>
{
s.Colour = Color4.Black;
s.Font = s.Font.With(size: 14);
s.UseFullGlyphHeight = false;
});
t.AddText($"{separator}{fractionPart}", s =>
{
s.Colour = Color4.Black;
s.Font = s.Font.With(size: 7);
s.UseFullGlyphHeight = false;
});
});
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -130,14 +118,28 @@ namespace osu.Game.Screens.Ranking.Expanded
Icon = FontAwesome.Solid.Star, Icon = FontAwesome.Solid.Star,
Colour = Color4.Black Colour = Color4.Black
}, },
textContainer = new OsuTextFlowContainer(s => s.Font = OsuFont.Numeric.With(weight: FontWeight.Black)) new OsuTextFlowContainer(s => s.Font = OsuFont.Numeric.With(weight: FontWeight.Black))
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
TextAnchor = Anchor.BottomLeft, TextAnchor = Anchor.BottomLeft,
}, }.With(t =>
{
t.AddText(wholePartText = new OsuSpriteText(), s =>
{
s.Colour = Color4.Black;
s.Font = s.Font.With(size:14);
s.UseFullGlyphHeight = false;
});
t.AddText(fractionPartText = new OsuSpriteText(), s =>
{
s.Colour = Color4.Black;
s.Font = s.Font.With(size: 7);
s.UseFullGlyphHeight = false;
});
}),
} }
} }
}; };