mirror of https://github.com/ppy/osu
Merge pull request #30718 from frenzibyte/initial-key-counter-state
Fix key counter not updating activation state on initial load
This commit is contained in:
commit
b070a50ac9
|
@ -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>
|
||||
|
@ -49,6 +54,7 @@ protected void Activate(bool forwardPlayback = true)
|
|||
if (forwardPlayback && isCounting.Value)
|
||||
activationCount.Value++;
|
||||
|
||||
IsActive = true;
|
||||
OnActivate?.Invoke(forwardPlayback);
|
||||
}
|
||||
|
||||
|
@ -57,6 +63,7 @@ protected void Deactivate(bool forwardPlayback = true)
|
|||
if (!forwardPlayback && isCounting.Value)
|
||||
activationCount.Value--;
|
||||
|
||||
IsActive = false;
|
||||
OnDeactivate?.Invoke(forwardPlayback);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue