1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

Use object initialisers and fix order of initialisation vs add

This commit is contained in:
Dean Herbert 2023-03-15 18:02:12 +09:00
parent 8908648f97
commit 9e444af380

View File

@ -13,17 +13,18 @@ namespace osu.Game.Screens.Play.HUD
private const int duration = 100; private const int duration = 100;
private const double key_fade_time = 80; private const double key_fade_time = 80;
private readonly FillFlowContainer<DefaultKeyCounter> keyFlow = new FillFlowContainer<DefaultKeyCounter>(); private readonly FillFlowContainer<DefaultKeyCounter> keyFlow;
public override IEnumerable<KeyCounter> Counters => keyFlow; public override IEnumerable<KeyCounter> Counters => keyFlow;
public DefaultKeyCounterDisplay() public DefaultKeyCounterDisplay()
{ {
keyFlow.Direction = FillDirection.Horizontal; InternalChild = keyFlow = new FillFlowContainer<DefaultKeyCounter>
keyFlow.AutoSizeAxes = Axes.Both; {
keyFlow.Alpha = 0; Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
InternalChild = keyFlow; Alpha = 0,
};
} }
protected override void Update() protected override void Update()
@ -36,13 +37,12 @@ namespace osu.Game.Screens.Play.HUD
} }
public override void AddTrigger(InputTrigger trigger) public override void AddTrigger(InputTrigger trigger)
keyFlow.Add(new DefaultKeyCounter(trigger)
{ {
DefaultKeyCounter key = new DefaultKeyCounter(trigger); FadeTime = key_fade_time,
keyFlow.Add(key); KeyDownTextColor = KeyDownTextColor,
key.FadeTime = key_fade_time; KeyUpTextColor = KeyUpTextColor,
key.KeyDownTextColor = KeyDownTextColor; });
key.KeyUpTextColor = KeyUpTextColor;
}
protected override void UpdateVisibility() => protected override void UpdateVisibility() =>
// Isolate changing visibility of the key counters from fading this component. // Isolate changing visibility of the key counters from fading this component.