diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs index 4cb017cc56..ec8fad9bf3 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInput.cs @@ -579,7 +579,7 @@ namespace osu.Game.Rulesets.Osu.Tests private void checkNotPressed(OsuAction action) => AddAssert($"Not pressing {action}", () => !osuInputManager.PressedActions.Contains(action)); private void checkPressed(OsuAction action) => AddAssert($"Is pressing {action}", () => osuInputManager.PressedActions.Contains(action)); - public partial class TestActionKeyCounterTrigger : KeyCounter.InputTrigger, IKeyBindingHandler + public partial class TestActionKeyCounterTrigger : InputTrigger, IKeyBindingHandler { public OsuAction Action { get; } diff --git a/osu.Game/Screens/Play/DefaultKeyCounterDisplay.cs b/osu.Game/Screens/Play/DefaultKeyCounterDisplay.cs index 367eb483a0..10f5a3cfe0 100644 --- a/osu.Game/Screens/Play/DefaultKeyCounterDisplay.cs +++ b/osu.Game/Screens/Play/DefaultKeyCounterDisplay.cs @@ -42,7 +42,7 @@ namespace osu.Game.Screens.Play Size = keyFlow.Size; } - public override void AddTrigger(KeyCounter.InputTrigger trigger) + public override void AddTrigger(InputTrigger trigger) { DefaultKeyCounter key = new DefaultKeyCounter(trigger); Add(key); diff --git a/osu.Game/Screens/Play/InputTrigger.cs b/osu.Game/Screens/Play/InputTrigger.cs new file mode 100644 index 0000000000..b8951b0f8e --- /dev/null +++ b/osu.Game/Screens/Play/InputTrigger.cs @@ -0,0 +1,23 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics; + +namespace osu.Game.Screens.Play +{ + public abstract partial class InputTrigger : Component + { + public event Action? OnActivate; + public event Action? OnDeactivate; + + protected InputTrigger(string name) + { + Name = name; + } + + protected void Activate(bool forwardPlayback = true) => OnActivate?.Invoke(forwardPlayback); + + protected void Deactivate(bool forwardPlayback = true) => OnDeactivate?.Invoke(forwardPlayback); + } +} diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index 26bb6f1a22..7ee9c94f62 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -80,20 +79,5 @@ namespace osu.Game.Screens.Play Trigger.OnActivate -= Activate; Trigger.OnDeactivate -= Deactivate; } - - public abstract partial class InputTrigger : Component - { - public event Action? OnActivate; - public event Action? OnDeactivate; - - protected InputTrigger(string name) - { - Name = name; - } - - protected void Activate(bool forwardPlayback = true) => OnActivate?.Invoke(forwardPlayback); - - protected void Deactivate(bool forwardPlayback = true) => OnDeactivate?.Invoke(forwardPlayback); - } } } diff --git a/osu.Game/Screens/Play/KeyCounterActionTrigger.cs b/osu.Game/Screens/Play/KeyCounterActionTrigger.cs index 8bb9bdc886..be0d259f85 100644 --- a/osu.Game/Screens/Play/KeyCounterActionTrigger.cs +++ b/osu.Game/Screens/Play/KeyCounterActionTrigger.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; namespace osu.Game.Screens.Play { - public partial class KeyCounterActionTrigger : KeyCounter.InputTrigger + public partial class KeyCounterActionTrigger : InputTrigger where T : struct { public T Action { get; } diff --git a/osu.Game/Screens/Play/KeyCounterDisplay.cs b/osu.Game/Screens/Play/KeyCounterDisplay.cs index d1fbfe166d..01686ae6de 100644 --- a/osu.Game/Screens/Play/KeyCounterDisplay.cs +++ b/osu.Game/Screens/Play/KeyCounterDisplay.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play public Bindable IsCounting { get; } = new BindableBool(true); - public IReadOnlyList Triggers + public IReadOnlyList Triggers { get => Children.Select(c => c.Trigger).ToArray(); set @@ -56,9 +56,9 @@ namespace osu.Game.Screens.Play this.receptor = receptor; } - public abstract void AddTrigger(KeyCounter.InputTrigger trigger); + public abstract void AddTrigger(InputTrigger trigger); - public void AddTriggerRange(IEnumerable triggers) => triggers.ForEach(AddTrigger); + public void AddTriggerRange(IEnumerable triggers) => triggers.ForEach(AddTrigger); private bool checkType(KeyCounter key) => acceptedTypes.Length == 0 || acceptedTypes.Any(t => t.IsInstanceOfType(key)); diff --git a/osu.Game/Screens/Play/KeyCounterKeyboardTrigger.cs b/osu.Game/Screens/Play/KeyCounterKeyboardTrigger.cs index 56c5ab0083..1d89c58fc3 100644 --- a/osu.Game/Screens/Play/KeyCounterKeyboardTrigger.cs +++ b/osu.Game/Screens/Play/KeyCounterKeyboardTrigger.cs @@ -8,7 +8,7 @@ using osuTK.Input; namespace osu.Game.Screens.Play { - public partial class KeyCounterKeyboardTrigger : KeyCounter.InputTrigger + public partial class KeyCounterKeyboardTrigger : InputTrigger { public Key Key { get; } diff --git a/osu.Game/Screens/Play/KeyCounterMouseTrigger.cs b/osu.Game/Screens/Play/KeyCounterMouseTrigger.cs index 66890073a8..e710c6e33f 100644 --- a/osu.Game/Screens/Play/KeyCounterMouseTrigger.cs +++ b/osu.Game/Screens/Play/KeyCounterMouseTrigger.cs @@ -9,7 +9,7 @@ using osuTK; namespace osu.Game.Screens.Play { - public partial class KeyCounterMouseTrigger : KeyCounter.InputTrigger + public partial class KeyCounterMouseTrigger : InputTrigger { public MouseButton Button { get; }