Skip to content

Commit

Permalink
Fix legacy key counter's background being visible when intended to be…
Browse files Browse the repository at this point in the history
… hidden
  • Loading branch information
peppy committed Aug 6, 2024
1 parent 90395ae commit 5f69b74
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class ArgonKeyCounterDisplay : KeyCounterDisplay

public ArgonKeyCounterDisplay()
{
InternalChild = KeyFlow = new FillFlowContainer<KeyCounter>
Child = KeyFlow = new FillFlowContainer<KeyCounter>
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Screens/Play/HUD/DefaultKeyCounterDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class DefaultKeyCounterDisplay : KeyCounterDisplay

public DefaultKeyCounterDisplay()
{
InternalChild = KeyFlow = new FillFlowContainer<KeyCounter>
Child = KeyFlow = new FillFlowContainer<KeyCounter>
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Expand Down
35 changes: 23 additions & 12 deletions osu.Game/Screens/Play/HUD/KeyCounterDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace osu.Game.Screens.Play.HUD
/// <summary>
/// A flowing display of all gameplay keys. Individual keys can be added using <see cref="InputTrigger"/> implementations.
/// </summary>
public abstract partial class KeyCounterDisplay : CompositeDrawable, ISerialisableDrawable
public abstract partial class KeyCounterDisplay : Container, ISerialisableDrawable
{
/// <summary>
/// Whether the key counter should be visible regardless of the configuration value.
Expand All @@ -29,25 +29,22 @@ public abstract partial class KeyCounterDisplay : CompositeDrawable, ISerialisab

private readonly IBindableList<InputTrigger> triggers = new BindableList<InputTrigger>();

protected override Container<Drawable> Content { get; } = new Container
{
Alpha = 0,
AutoSizeAxes = Axes.Both,
};

[Resolved]
private InputCountController controller { get; set; } = null!;

private const int duration = 100;

protected void UpdateVisibility()
protected KeyCounterDisplay()
{
bool visible = AlwaysVisible.Value || ConfigVisibility.Value;

// Isolate changing visibility of the key counters from fading this component.
KeyFlow.FadeTo(visible ? 1 : 0, duration);

// Ensure a valid size is immediately obtained even if partially off-screen
// See https://github.com/ppy/osu/issues/14793.
KeyFlow.AlwaysPresent = visible;
AddInternal(Content);
}

protected abstract KeyCounter CreateCounter(InputTrigger trigger);

[BackgroundDependencyLoader]
private void load(OsuConfigManager config, DrawableRuleset? drawableRuleset)
{
Expand All @@ -70,6 +67,20 @@ protected override void LoadComplete()
ConfigVisibility.BindValueChanged(_ => UpdateVisibility(), true);
}

protected void UpdateVisibility()
{
bool visible = AlwaysVisible.Value || ConfigVisibility.Value;

// Isolate changing visibility of the key counters from fading this component.
Content.FadeTo(visible ? 1 : 0, duration);

// Ensure a valid size is immediately obtained even if partially off-screen
// See https://github.com/ppy/osu/issues/14793.
Content.AlwaysPresent = visible;
}

protected abstract KeyCounter CreateCounter(InputTrigger trigger);

private void triggersChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
KeyFlow.Clear();
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Skinning/LegacyKeyCounterDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public LegacyKeyCounterDisplay()
{
AutoSizeAxes = Axes.Both;

AddRangeInternal(new Drawable[]
AddRange(new Drawable[]
{
backgroundSprite = new Sprite
{
Expand Down

0 comments on commit 5f69b74

Please sign in to comment.