1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

style(KeyCounter): rename methods and arguments

As for the second suggestion in
https://github.com/ppy/osu/pull/22654#discussion_r1109047998,
I went with the first one as only one Trigger actually uses this
argument for rewinding.
This commit is contained in:
tsrk 2023-02-16 23:15:03 +00:00
parent ddd6c1a1c6
commit c61fac578c
No known key found for this signature in database
GPG Key ID: EBD46BB3049B56D6
5 changed files with 18 additions and 18 deletions

View File

@ -593,7 +593,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
if (e.Action == Action) if (e.Action == Action)
{ {
LightUp(); Activate();
} }
return false; return false;
@ -602,7 +602,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e) public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
{ {
if (e.Action == Action) if (e.Action == Action)
Unlight(); Deactivate();
} }
} }

View File

@ -36,8 +36,8 @@ namespace osu.Game.Screens.Play
Trigger = trigger, Trigger = trigger,
}; };
Trigger.OnLightUp += LightUp; Trigger.OnActivate += Activate;
Trigger.OnUnlight += Unlight; Trigger.OnDeactivate += Deactivate;
Name = trigger.Name; Name = trigger.Name;
} }
@ -60,14 +60,14 @@ namespace osu.Game.Screens.Play
countPresses.Value--; countPresses.Value--;
} }
protected virtual void LightUp(bool increment = true) protected virtual void Activate(bool increment = true)
{ {
IsLit.Value = true; IsLit.Value = true;
if (increment) if (increment)
Increment(); Increment();
} }
protected virtual void Unlight(bool preserve = true) protected virtual void Deactivate(bool preserve = true)
{ {
IsLit.Value = false; IsLit.Value = false;
if (!preserve) if (!preserve)
@ -77,23 +77,23 @@ namespace osu.Game.Screens.Play
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
Trigger.OnLightUp -= LightUp; Trigger.OnActivate -= Activate;
Trigger.OnUnlight -= Unlight; Trigger.OnDeactivate -= Deactivate;
} }
public abstract partial class InputTrigger : Component public abstract partial class InputTrigger : Component
{ {
public event Action<bool>? OnLightUp; public event Action<bool>? OnActivate;
public event Action<bool>? OnUnlight; public event Action<bool>? OnDeactivate;
protected InputTrigger(string name) protected InputTrigger(string name)
{ {
Name = name; Name = name;
} }
protected void LightUp(bool increment = true) => OnLightUp?.Invoke(increment); protected void Activate(bool forwardPlayback = true) => OnActivate?.Invoke(forwardPlayback);
protected void Unlight(bool preserve = true) => OnUnlight?.Invoke(preserve); protected void Deactivate(bool forwardPlayback = true) => OnDeactivate?.Invoke(forwardPlayback);
} }
} }
} }

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Play
if (!EqualityComparer<T>.Default.Equals(action, Action)) if (!EqualityComparer<T>.Default.Equals(action, Action))
return false; return false;
LightUp(forwards); Activate(forwards);
return false; return false;
} }
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play
if (!EqualityComparer<T>.Default.Equals(action, Action)) if (!EqualityComparer<T>.Default.Equals(action, Action))
return; return;
Unlight(forwards); Deactivate(forwards);
} }
} }
} }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Screens.Play
{ {
if (e.Key == Key) if (e.Key == Key)
{ {
LightUp(); Activate();
} }
return base.OnKeyDown(e); return base.OnKeyDown(e);
@ -31,7 +31,7 @@ namespace osu.Game.Screens.Play
protected override void OnKeyUp(KeyUpEvent e) protected override void OnKeyUp(KeyUpEvent e)
{ {
if (e.Key == Key) if (e.Key == Key)
Unlight(); Deactivate();
base.OnKeyUp(e); base.OnKeyUp(e);
} }

View File

@ -39,7 +39,7 @@ namespace osu.Game.Screens.Play
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
if (e.Button == Button) if (e.Button == Button)
LightUp(); Activate();
return base.OnMouseDown(e); return base.OnMouseDown(e);
} }
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Play
protected override void OnMouseUp(MouseUpEvent e) protected override void OnMouseUp(MouseUpEvent e)
{ {
if (e.Button == Button) if (e.Button == Button)
Unlight(); Deactivate();
base.OnMouseUp(e); base.OnMouseUp(e);
} }