mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
refactor: rename trigger classes
Makes it better to understand their purpose
This commit is contained in:
parent
a644fae364
commit
076eb81b21
@ -59,14 +59,14 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
leftKeyCounter = new DefaultKeyCounter(new TestActionKeyCounter(OsuAction.LeftButton))
|
leftKeyCounter = new DefaultKeyCounter(new TestActionKeyCounterTrigger(OsuAction.LeftButton))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Depth = float.MinValue,
|
Depth = float.MinValue,
|
||||||
X = -100,
|
X = -100,
|
||||||
},
|
},
|
||||||
rightKeyCounter = new DefaultKeyCounter(new TestActionKeyCounter(OsuAction.RightButton))
|
rightKeyCounter = new DefaultKeyCounter(new TestActionKeyCounterTrigger(OsuAction.RightButton))
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.CentreLeft,
|
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 checkNotPressed(OsuAction action) => AddAssert($"Not pressing {action}", () => !osuInputManager.PressedActions.Contains(action));
|
||||||
private void checkPressed(OsuAction action) => AddAssert($"Is 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 OsuAction Action { get; }
|
||||||
|
|
||||||
public TestActionKeyCounter(OsuAction action)
|
public TestActionKeyCounterTrigger(OsuAction action)
|
||||||
: base(action.ToString())
|
: base(action.ToString())
|
||||||
{
|
{
|
||||||
Action = action;
|
Action = action;
|
||||||
|
@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
|
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
|
||||||
|
|
||||||
// Add any key just to display the key counter visually.
|
// 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;
|
scoreProcessor.Combo.Value = 1;
|
||||||
|
|
||||||
|
@ -25,20 +25,20 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
testCounter = new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
|
testCounter = new DefaultKeyCounter(new KeyCounterKeyboardTrigger(Key.X)),
|
||||||
new DefaultKeyCounter(new KeyCounterKeyboard(Key.X)),
|
new DefaultKeyCounter(new KeyCounterKeyboardTrigger(Key.X)),
|
||||||
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Left)),
|
new DefaultKeyCounter(new KeyCounterMouseTrigger(MouseButton.Left)),
|
||||||
new DefaultKeyCounter(new KeyCounterMouse(MouseButton.Right)),
|
new DefaultKeyCounter(new KeyCounterMouseTrigger(MouseButton.Right)),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
AddStep("Add random", () =>
|
AddStep("Add random", () =>
|
||||||
{
|
{
|
||||||
Key key = (Key)((int)Key.A + RNG.Next(26));
|
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()
|
void addPressKeyStep()
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Add any key just to display the key counter visually.
|
// 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;
|
scoreProcessor.Combo.Value = 1;
|
||||||
|
|
||||||
return new Container
|
return new Container
|
||||||
|
@ -88,7 +88,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
|
hudOverlay = new HUDOverlay(null, Array.Empty<Mod>());
|
||||||
|
|
||||||
// Add any key just to display the key counter visually.
|
// 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);
|
action?.Invoke(hudOverlay);
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
.Select(b => b.GetAction<T>())
|
.Select(b => b.GetAction<T>())
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.OrderBy(action => action)
|
.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>
|
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>)
|
public bool OnPressed(KeyBindingPressEvent<T> e) => Target.Children.Where(c => c.Trigger is KeyCounterActionTrigger<T>)
|
||||||
.Select(c => (KeyCounterAction<T>)c.Trigger)
|
.Select(c => (KeyCounterActionTrigger<T>)c.Trigger)
|
||||||
.Any(c => c.OnPressed(e.Action, Clock.Rate >= 0));
|
.Any(c => c.OnPressed(e.Action, Clock.Rate >= 0));
|
||||||
|
|
||||||
public void OnReleased(KeyBindingReleaseEvent<T> e)
|
public void OnReleased(KeyBindingReleaseEvent<T> e)
|
||||||
{
|
{
|
||||||
foreach (var c
|
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);
|
c.OnReleased(e.Action, Clock.Rate >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public partial class KeyCounterAction<T> : KeyCounter.InputTrigger
|
public partial class KeyCounterActionTrigger<T> : KeyCounter.InputTrigger
|
||||||
where T : struct
|
where T : struct
|
||||||
{
|
{
|
||||||
public T Action { get; }
|
public T Action { get; }
|
||||||
|
|
||||||
public KeyCounterAction(T action)
|
public KeyCounterActionTrigger(T action)
|
||||||
: base($"B{(int)(object)action + 1}")
|
: base($"B{(int)(object)action + 1}")
|
||||||
{
|
{
|
||||||
Action = action;
|
Action = action;
|
@ -8,11 +8,11 @@ using osuTK.Input;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public partial class KeyCounterKeyboard : KeyCounter.InputTrigger
|
public partial class KeyCounterKeyboardTrigger : KeyCounter.InputTrigger
|
||||||
{
|
{
|
||||||
public Key Key { get; }
|
public Key Key { get; }
|
||||||
|
|
||||||
public KeyCounterKeyboard(Key key)
|
public KeyCounterKeyboardTrigger(Key key)
|
||||||
: base(key.ToString())
|
: base(key.ToString())
|
||||||
{
|
{
|
||||||
Key = key;
|
Key = key;
|
@ -9,11 +9,11 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public partial class KeyCounterMouse : KeyCounter.InputTrigger
|
public partial class KeyCounterMouseTrigger : KeyCounter.InputTrigger
|
||||||
{
|
{
|
||||||
public MouseButton Button { get; }
|
public MouseButton Button { get; }
|
||||||
|
|
||||||
public KeyCounterMouse(MouseButton button)
|
public KeyCounterMouseTrigger(MouseButton button)
|
||||||
: base(getStringRepresentation(button))
|
: base(getStringRepresentation(button))
|
||||||
{
|
{
|
||||||
Button = button;
|
Button = button;
|
Loading…
x
Reference in New Issue
Block a user