1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00

refactor: rename trigger classes

Makes it better to understand their purpose
This commit is contained in:
tsrk 2023-02-13 23:49:57 +00:00
parent a644fae364
commit 076eb81b21
No known key found for this signature in database
GPG Key ID: EBD46BB3049B56D6
9 changed files with 23 additions and 23 deletions

View File

@ -59,14 +59,14 @@ namespace osu.Game.Rulesets.Osu.Tests
Origin = Anchor.Centre,
Children = new Drawable[]
{
leftKeyCounter = new DefaultKeyCounter(new TestActionKeyCounter(OsuAction.LeftButton))
leftKeyCounter = new DefaultKeyCounter(new TestActionKeyCounterTrigger(OsuAction.LeftButton))
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreRight,
Depth = float.MinValue,
X = -100,
},
rightKeyCounter = new DefaultKeyCounter(new TestActionKeyCounter(OsuAction.RightButton))
rightKeyCounter = new DefaultKeyCounter(new TestActionKeyCounterTrigger(OsuAction.RightButton))
{
Anchor = Anchor.Centre,
Origin = Anchor.CentreLeft,
@ -579,11 +579,11 @@ 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 TestActionKeyCounter : KeyCounter.InputTrigger, IKeyBindingHandler<OsuAction>
public partial class TestActionKeyCounterTrigger : KeyCounter.InputTrigger, IKeyBindingHandler<OsuAction>
{
public OsuAction Action { get; }
public TestActionKeyCounter(OsuAction action)
public TestActionKeyCounterTrigger(OsuAction action)
: base(action.ToString())
{
Action = action;

View File

@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual.Gameplay
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
// Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboard(Key.Space)));
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboardTrigger(Key.Space)));
scoreProcessor.Combo.Value = 1;

View File

@ -25,20 +25,20 @@ namespace osu.Game.Tests.Visual.Gameplay
Anchor = Anchor.Centre,
Children = new[]
{
testCounter = new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Left)),
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Right)),
testCounter = new DefaultKeyCounter(new KeyCounterKeyboardTrigger(Key.X)),
new DefaultKeyCounter(new KeyCounterKeyboardTrigger(Key.X)),
new DefaultKeyCounter(new KeyCounterMouseTrigger(MouseButton.Left)),
new DefaultKeyCounter(new KeyCounterMouseTrigger(MouseButton.Right)),
},
};
AddStep("Add random", () =>
{
Key key = (Key)((int)Key.A + RNG.Next(26));
kc.Add(kc.CreateKeyCounter(new KeyCounterKeyboard(key)));
kc.Add(kc.CreateKeyCounter(new KeyCounterKeyboardTrigger(key)));
});
Key testKey = ((KeyCounterKeyboard)kc.Children.First().Trigger).Key;
Key testKey = ((KeyCounterKeyboardTrigger)kc.Children.First().Trigger).Key;
void addPressKeyStep()
{

View File

@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
};
// Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboard(Key.Space)));
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboardTrigger(Key.Space)));
scoreProcessor.Combo.Value = 1;
return new Container

View File

@ -88,7 +88,7 @@ namespace osu.Game.Tests.Visual.Gameplay
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
// Add any key just to display the key counter visually.
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboard(Key.Space)));
hudOverlay.KeyCounter.Add(hudOverlay.KeyCounter.CreateKeyCounter(new KeyCounterKeyboardTrigger(Key.Space)));
action?.Invoke(hudOverlay);

View File

@ -166,7 +166,7 @@ namespace osu.Game.Rulesets.UI
.Select(b => b.GetAction<T>())
.Distinct()
.OrderBy(action => action)
.Select(action => keyCounter.CreateKeyCounter(new KeyCounterAction<T>(action))));
.Select(action => keyCounter.CreateKeyCounter(new KeyCounterActionTrigger<T>(action))));
}
private partial class ActionReceptor : KeyCounterDisplay.Receptor, IKeyBindingHandler<T>
@ -176,14 +176,14 @@ namespace osu.Game.Rulesets.UI
{
}
public bool OnPressed(KeyBindingPressEvent<T> e) => Target.Children.Where(c => c.Trigger is KeyCounterAction<T>)
.Select(c => (KeyCounterAction<T>)c.Trigger)
public bool OnPressed(KeyBindingPressEvent<T> e) => Target.Children.Where(c => c.Trigger is KeyCounterActionTrigger<T>)
.Select(c => (KeyCounterActionTrigger<T>)c.Trigger)
.Any(c => c.OnPressed(e.Action, Clock.Rate >= 0));
public void OnReleased(KeyBindingReleaseEvent<T> e)
{
foreach (var c
in Target.Children.Where(c => c.Trigger is KeyCounterAction<T>).Select(c => (KeyCounterAction<T>)c.Trigger))
in Target.Children.Where(c => c.Trigger is KeyCounterActionTrigger<T>).Select(c => (KeyCounterActionTrigger<T>)c.Trigger))
c.OnReleased(e.Action, Clock.Rate >= 0);
}
}

View File

@ -7,12 +7,12 @@ using System.Collections.Generic;
namespace osu.Game.Screens.Play
{
public partial class KeyCounterAction<T> : KeyCounter.InputTrigger
public partial class KeyCounterActionTrigger<T> : KeyCounter.InputTrigger
where T : struct
{
public T Action { get; }
public KeyCounterAction(T action)
public KeyCounterActionTrigger(T action)
: base($"B{(int)(object)action + 1}")
{
Action = action;

View File

@ -8,11 +8,11 @@ using osuTK.Input;
namespace osu.Game.Screens.Play
{
public partial class KeyCounterKeyboard : KeyCounter.InputTrigger
public partial class KeyCounterKeyboardTrigger : KeyCounter.InputTrigger
{
public Key Key { get; }
public KeyCounterKeyboard(Key key)
public KeyCounterKeyboardTrigger(Key key)
: base(key.ToString())
{
Key = key;

View File

@ -9,11 +9,11 @@ using osuTK;
namespace osu.Game.Screens.Play
{
public partial class KeyCounterMouse : KeyCounter.InputTrigger
public partial class KeyCounterMouseTrigger : KeyCounter.InputTrigger
{
public MouseButton Button { get; }
public KeyCounterMouse(MouseButton button)
public KeyCounterMouseTrigger(MouseButton button)
: base(getStringRepresentation(button))
{
Button = button;