mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 17:43:12 +08:00
Make StarRatingDisplay dynamic.
This commit is contained in:
parent
670775cecb
commit
cf69eacae9
@ -24,6 +24,8 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmap;
|
||||||
|
|
||||||
|
private StarDifficulty? difficulty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="StarRatingDisplay"/>.
|
/// Creates a new <see cref="StarRatingDisplay"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,20 +33,33 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
public StarRatingDisplay(BeatmapInfo beatmap)
|
public StarRatingDisplay(BeatmapInfo beatmap)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
AutoSizeAxes = Axes.Both;
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="StarRatingDisplay"/> using an already computed <see cref="StarDifficulty"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="starDifficulty">The already computed <see cref="StarDifficulty"/> to display the star difficulty of.</param>
|
||||||
|
public StarRatingDisplay(StarDifficulty starDifficulty)
|
||||||
|
{
|
||||||
|
difficulty = starDifficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours, BeatmapDifficultyManager difficultyManager)
|
||||||
{
|
{
|
||||||
var starRatingParts = beatmap.StarDifficulty.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
if (!difficulty.HasValue)
|
||||||
|
difficulty = difficultyManager.GetDifficulty(beatmap);
|
||||||
|
|
||||||
|
var starRatingParts = difficulty.Value.Stars.ToString("0.00", CultureInfo.InvariantCulture).Split('.');
|
||||||
string wholePart = starRatingParts[0];
|
string wholePart = starRatingParts[0];
|
||||||
string fractionPart = starRatingParts[1];
|
string fractionPart = starRatingParts[1];
|
||||||
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
string separator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
|
||||||
|
|
||||||
ColourInfo backgroundColour = beatmap.DifficultyRating == DifficultyRating.ExpertPlus
|
ColourInfo backgroundColour = difficulty.Value.DifficultyRating == DifficultyRating.ExpertPlus
|
||||||
? ColourInfo.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
|
? ColourInfo.GradientVertical(Color4Extensions.FromHex("#C1C1C1"), Color4Extensions.FromHex("#595959"))
|
||||||
: (ColourInfo)colours.ForDifficultyRating(beatmap.DifficultyRating);
|
: (ColourInfo)colours.ForDifficultyRating(difficulty.Value.DifficultyRating);
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -238,7 +238,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Shear = wedged_container_shear,
|
Shear = wedged_container_shear,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
createStarRatingDisplay(beatmapInfo).With(display =>
|
createStarRatingDisplay(starDifficulty).With(display =>
|
||||||
{
|
{
|
||||||
display.Anchor = Anchor.TopRight;
|
display.Anchor = Anchor.TopRight;
|
||||||
display.Origin = Anchor.TopRight;
|
display.Origin = Anchor.TopRight;
|
||||||
@ -305,8 +305,8 @@ namespace osu.Game.Screens.Select
|
|||||||
StatusPill.Hide();
|
StatusPill.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drawable createStarRatingDisplay(BeatmapInfo beatmapInfo) => beatmapInfo.StarDifficulty > 0
|
private static Drawable createStarRatingDisplay(StarDifficulty difficulty) => difficulty.Stars > 0
|
||||||
? new StarRatingDisplay(beatmapInfo)
|
? new StarRatingDisplay(difficulty)
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Bottom = 5 }
|
Margin = new MarginPadding { Bottom = 5 }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user