Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix key counter not updating activation state on initial load #30718

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions osu.Game/Screens/Play/HUD/InputTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public abstract partial class InputTrigger : Component
/// </summary>
public IBindable<int> ActivationCount => activationCount;

/// <summary>
/// Whether this <see cref="InputTrigger"/> is currently active.
/// </summary>
public bool IsActive { get; private set; }

/// <summary>
/// Whether any activation or deactivation of this <see cref="InputTrigger"/> impacts its <see cref="ActivationCount"/>
/// </summary>
Expand All @@ -49,6 +54,7 @@ protected void Activate(bool forwardPlayback = true)
if (forwardPlayback && isCounting.Value)
activationCount.Value++;

IsActive = true;
OnActivate?.Invoke(forwardPlayback);
}

Expand All @@ -57,6 +63,7 @@ protected void Deactivate(bool forwardPlayback = true)
if (!forwardPlayback && isCounting.Value)
activationCount.Value--;

IsActive = false;
OnDeactivate?.Invoke(forwardPlayback);
}
}
Expand Down
8 changes: 8 additions & 0 deletions osu.Game/Screens/Play/HUD/KeyCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ protected KeyCounter(InputTrigger trigger)
Trigger.OnDeactivate += Deactivate;
}

protected override void LoadComplete()
{
base.LoadComplete();

if (Trigger.IsActive)
Activate();
}

protected virtual void Activate(bool forwardPlayback = true)
{
isActive.Value = true;
Expand Down
Loading