mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 08:53:17 +08:00
refactor(InputTrigger): move out of KCD
I love JetBrains Rider.
This commit is contained in:
parent
1beec71037
commit
8c94b77de1
@ -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<OsuAction>
|
||||
public partial class TestActionKeyCounterTrigger : InputTrigger, IKeyBindingHandler<OsuAction>
|
||||
{
|
||||
public OsuAction Action { get; }
|
||||
|
||||
|
@ -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);
|
||||
|
23
osu.Game/Screens/Play/InputTrigger.cs
Normal file
23
osu.Game/Screens/Play/InputTrigger.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<bool>? OnActivate;
|
||||
public event Action<bool>? 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);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<bool>? OnActivate;
|
||||
public event Action<bool>? 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public partial class KeyCounterActionTrigger<T> : KeyCounter.InputTrigger
|
||||
public partial class KeyCounterActionTrigger<T> : InputTrigger
|
||||
where T : struct
|
||||
{
|
||||
public T Action { get; }
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public Bindable<bool> IsCounting { get; } = new BindableBool(true);
|
||||
|
||||
public IReadOnlyList<KeyCounter.InputTrigger> Triggers
|
||||
public IReadOnlyList<InputTrigger> 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<KeyCounter.InputTrigger> triggers) => triggers.ForEach(AddTrigger);
|
||||
public void AddTriggerRange(IEnumerable<InputTrigger> triggers) => triggers.ForEach(AddTrigger);
|
||||
|
||||
private bool checkType(KeyCounter key) => acceptedTypes.Length == 0 || acceptedTypes.Any(t => t.IsInstanceOfType(key));
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user