1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 18:03:11 +08:00

Flip ifs to reduce nesting

This commit is contained in:
Bartłomiej Dach 2024-02-07 13:36:46 +01:00
parent 9a3c947319
commit f22828bc50
No known key found for this signature in database

View File

@ -213,22 +213,36 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
private Drawable createDrawablePerformance() private Drawable createDrawablePerformance()
{ {
if (!Score.PP.HasValue) if (Score.PP.HasValue)
{ {
if (Score.Beatmap?.Status.GrantsPerformancePoints() == true) return new FillFlowContainer
{ {
if (!Score.Ranked) AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new[]
{ {
return new UnrankedPerformancePointsPlaceholder new OsuSpriteText
{ {
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(weight: FontWeight.Bold), Font = OsuFont.GetFont(weight: FontWeight.Bold),
Text = $"{Score.PP:0}",
Colour = colourProvider.Highlight1 Colour = colourProvider.Highlight1
}; },
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "pp",
Colour = colourProvider.Light3
}
} }
};
}
return new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(16), Colour = colourProvider.Highlight1 }; if (Score.Beatmap?.Status.GrantsPerformancePoints() != true)
} {
return new OsuSpriteText return new OsuSpriteText
{ {
Font = OsuFont.GetFont(weight: FontWeight.Bold), Font = OsuFont.GetFont(weight: FontWeight.Bold),
@ -237,30 +251,16 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
}; };
} }
return new FillFlowContainer if (!Score.Ranked)
{ {
AutoSizeAxes = Axes.Both, return new UnrankedPerformancePointsPlaceholder
Direction = FillDirection.Horizontal,
Children = new[]
{ {
new OsuSpriteText Font = OsuFont.GetFont(weight: FontWeight.Bold),
{ Colour = colourProvider.Highlight1
Anchor = Anchor.BottomLeft, };
Origin = Anchor.BottomLeft, }
Font = OsuFont.GetFont(weight: FontWeight.Bold),
Text = $"{Score.PP:0}", return new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(16), Colour = colourProvider.Highlight1 };
Colour = colourProvider.Highlight1
},
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "pp",
Colour = colourProvider.Light3
}
}
};
} }
private partial class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer private partial class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer