mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Initialise warning text flow lazily as most items will not use it
This commit is contained in:
parent
1288f69fad
commit
19ffcd00c2
@ -36,12 +36,15 @@ namespace osu.Game.Overlays.Settings
|
||||
|
||||
private SpriteText labelText;
|
||||
|
||||
private readonly OsuTextFlowContainer warningText;
|
||||
private OsuTextFlowContainer warningText;
|
||||
|
||||
public bool ShowsDefaultIndicator = true;
|
||||
|
||||
public string TooltipText { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public virtual LocalisableString LabelText
|
||||
{
|
||||
get => labelText?.Text ?? string.Empty;
|
||||
@ -67,6 +70,18 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
set
|
||||
{
|
||||
if (warningText == null)
|
||||
{
|
||||
// construct lazily for cases where the label is not needed (may be provided by the Control).
|
||||
FlowContent.Add(warningText = new OsuTextFlowContainer
|
||||
{
|
||||
Colour = colours.Yellow,
|
||||
Margin = new MarginPadding { Bottom = 5 },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
});
|
||||
}
|
||||
|
||||
warningText.Alpha = string.IsNullOrWhiteSpace(value) ? 0 : 1;
|
||||
warningText.Text = value;
|
||||
}
|
||||
@ -110,12 +125,6 @@ namespace osu.Game.Overlays.Settings
|
||||
Children = new[]
|
||||
{
|
||||
Control = CreateControl(),
|
||||
warningText = new OsuTextFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Alpha = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -132,12 +141,6 @@ namespace osu.Game.Overlays.Settings
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
warningText.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
private void updateDisabled()
|
||||
{
|
||||
if (labelText != null)
|
||||
|
Loading…
Reference in New Issue
Block a user