1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-04 02:13:22 +08:00

Update BreakInfoLine to formatting standards

This commit is contained in:
Joseph Madamba 2023-07-29 11:05:15 -07:00
parent 6ebfafa9c3
commit 4ddf05602f

View File

@ -21,21 +21,30 @@ namespace osu.Game.Screens.Play.Break
public Bindable<T> Current = new Bindable<T>(); public Bindable<T> Current = new Bindable<T>();
private readonly OsuSpriteText text; private readonly LocalisableString name;
private readonly OsuSpriteText valueText;
private OsuSpriteText valueText = null!;
public BreakInfoLine(LocalisableString name) public BreakInfoLine(LocalisableString name)
{ {
this.name = name;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Children = new Drawable[] Children = new Drawable[]
{ {
text = new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Text = name, Text = name,
Font = OsuFont.GetFont(size: 17), Font = OsuFont.GetFont(size: 17),
Margin = new MarginPadding { Right = margin } Margin = new MarginPadding { Right = margin },
Colour = colours.Yellow,
}, },
valueText = new OsuSpriteText valueText = new OsuSpriteText
{ {
@ -43,11 +52,17 @@ namespace osu.Game.Screens.Play.Break
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = @"-", Text = @"-",
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17),
Margin = new MarginPadding { Left = margin } Margin = new MarginPadding { Left = margin },
Colour = colours.YellowLight,
} }
}; };
}
Current.ValueChanged += text => valueText.Text = Format(text.NewValue); protected override void LoadComplete()
{
base.LoadComplete();
Current.BindValueChanged(text => valueText.Text = Format(text.NewValue), true);
} }
protected virtual LocalisableString Format(T count) protected virtual LocalisableString Format(T count)
@ -57,13 +72,6 @@ namespace osu.Game.Screens.Play.Break
return count.ToString() ?? string.Empty; return count.ToString() ?? string.Empty;
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
text.Colour = colours.Yellow;
valueText.Colour = colours.YellowLight;
}
} }
public partial class PercentageBreakInfoLine : BreakInfoLine<double> public partial class PercentageBreakInfoLine : BreakInfoLine<double>