mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 05:03:02 +08: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 SpriteText labelText;
|
||||||
|
|
||||||
private readonly OsuTextFlowContainer warningText;
|
private OsuTextFlowContainer warningText;
|
||||||
|
|
||||||
public bool ShowsDefaultIndicator = true;
|
public bool ShowsDefaultIndicator = true;
|
||||||
|
|
||||||
public string TooltipText { get; set; }
|
public string TooltipText { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
public virtual LocalisableString LabelText
|
public virtual LocalisableString LabelText
|
||||||
{
|
{
|
||||||
get => labelText?.Text ?? string.Empty;
|
get => labelText?.Text ?? string.Empty;
|
||||||
@ -67,6 +70,18 @@ namespace osu.Game.Overlays.Settings
|
|||||||
{
|
{
|
||||||
set
|
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.Alpha = string.IsNullOrWhiteSpace(value) ? 0 : 1;
|
||||||
warningText.Text = value;
|
warningText.Text = value;
|
||||||
}
|
}
|
||||||
@ -110,12 +125,6 @@ namespace osu.Game.Overlays.Settings
|
|||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
Control = CreateControl(),
|
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()
|
private void updateDisabled()
|
||||||
{
|
{
|
||||||
if (labelText != null)
|
if (labelText != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user