Move badge hierarchy declaration to constructor for safer access

This commit is contained in:
Salman Ahmed 2022-05-14 21:54:52 +03:00
parent 1878578196
commit 4bb06873d5
1 changed files with 9 additions and 7 deletions

View File

@ -32,26 +32,22 @@ public Colour4 BadgeColour
set => badgeLabel.Colour = value;
}
private OsuSpriteText badgeLabel = null!;
private readonly Box background;
private readonly OsuSpriteText badgeLabel;
protected BeatmapBadge()
{
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, OverlayColourProvider? colourProvider)
{
InternalChild = new CircularContainer
{
Masking = true,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider?.Background5 ?? colours.Gray2,
},
badgeLabel = new OsuSpriteText
{
@ -61,5 +57,11 @@ private void load(OsuColour colours, OverlayColourProvider? colourProvider)
}
};
}
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, OverlayColourProvider? colourProvider)
{
background.Colour = colourProvider?.Background5 ?? colours.Gray2;
}
}
}