1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:17:51 +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()
{
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),
Text = $"{Score.PP:0}",
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
{
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,
Direction = FillDirection.Horizontal,
Children = new[]
return new UnrankedPerformancePointsPlaceholder
{
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(weight: FontWeight.Bold),
Text = $"{Score.PP:0}",
Colour = colourProvider.Highlight1
},
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "pp",
Colour = colourProvider.Light3
}
}
};
Font = OsuFont.GetFont(weight: FontWeight.Bold),
Colour = colourProvider.Highlight1
};
}
return new UnprocessedPerformancePointsPlaceholder { Size = new Vector2(16), Colour = colourProvider.Highlight1 };
}
private partial class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer