diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs
index 02df4d8fb3..73acb1759f 100644
--- a/osu.Game/Rulesets/UI/DrawableRuleset.cs
+++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs
@@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.UI
/// Displays an interactive ruleset gameplay instance.
///
/// The type of HitObject contained by this DrawableRuleset.
- public abstract class DrawableRuleset : DrawableRuleset, IProvideCursor, ICanAttachKeyCounter
+ public abstract class DrawableRuleset : DrawableRuleset, IProvideCursor, ICanAttachHUDPieces
where TObject : HitObject
{
public override event Action NewResult;
@@ -339,9 +339,10 @@ namespace osu.Game.Rulesets.UI
public abstract DrawableHitObject CreateDrawableRepresentation(TObject h);
public void Attach(KeyCounterDisplay keyCounter) =>
- (KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(keyCounter);
+ (KeyBindingInputManager as ICanAttachHUDPieces)?.Attach(keyCounter);
- public void Attach(ClicksPerSecondCalculator calculator) => (KeyBindingInputManager as ICanAttachKeyCounter)?.Attach(calculator);
+ public void Attach(ClicksPerSecondCalculator calculator) =>
+ (KeyBindingInputManager as ICanAttachHUDPieces)?.Attach(calculator);
///
/// Creates a key conversion input manager. An exception will be thrown if a valid is not returned.
diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs
index 4b7ce22cfc..401ebbfd74 100644
--- a/osu.Game/Rulesets/UI/RulesetInputManager.cs
+++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs
@@ -25,7 +25,7 @@ using static osu.Game.Input.Handlers.ReplayInputHandler;
namespace osu.Game.Rulesets.UI
{
- public abstract class RulesetInputManager : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler, IHasRecordingHandler
+ public abstract class RulesetInputManager : PassThroughInputManager, ICanAttachHUDPieces, IHasReplayHandler, IHasRecordingHandler
where T : struct
{
public readonly KeyBindingContainer KeyBindingContainer;
@@ -169,7 +169,7 @@ namespace osu.Game.Rulesets.UI
.Select(action => new KeyCounterAction(action)));
}
- public class ActionReceptor : KeyCounterDisplay.Receptor, IKeyBindingHandler
+ private class ActionReceptor : KeyCounterDisplay.Receptor, IKeyBindingHandler
{
public ActionReceptor(KeyCounterDisplay target)
: base(target)
@@ -191,8 +191,6 @@ namespace osu.Game.Rulesets.UI
public void Attach(ClicksPerSecondCalculator calculator)
{
- if (calculator == null) return;
-
var listener = new ActionListener(calculator);
KeyBindingContainer.Add(listener);
@@ -200,23 +198,22 @@ namespace osu.Game.Rulesets.UI
calculator.Listener = listener;
}
- public class ActionListener : ClicksPerSecondCalculator.InputListener, IKeyBindingHandler
+ private class ActionListener : ClicksPerSecondCalculator.InputListener, IKeyBindingHandler
{
+ public ActionListener(ClicksPerSecondCalculator calculator)
+ : base(calculator)
+ {
+ }
+
public bool OnPressed(KeyBindingPressEvent e)
{
Calculator.AddTimestamp();
-
return false;
}
public void OnReleased(KeyBindingReleaseEvent e)
{
}
-
- public ActionListener(ClicksPerSecondCalculator calculator)
- : base(calculator)
- {
- }
}
#endregion
@@ -256,10 +253,10 @@ namespace osu.Game.Rulesets.UI
}
///
- /// Supports attaching a .
+ /// Supports attaching various HUD pieces.
/// Keys will be populated automatically and a receptor will be injected inside.
///
- public interface ICanAttachKeyCounter
+ public interface ICanAttachHUDPieces
{
void Attach(KeyCounterDisplay keyCounter);
void Attach(ClicksPerSecondCalculator calculator);
diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs
index b27efaf13a..f9f3693385 100644
--- a/osu.Game/Screens/Play/HUDOverlay.cs
+++ b/osu.Game/Screens/Play/HUDOverlay.cs
@@ -264,8 +264,11 @@ namespace osu.Game.Screens.Play
protected virtual void BindDrawableRuleset(DrawableRuleset drawableRuleset)
{
- (drawableRuleset as ICanAttachKeyCounter)?.Attach(KeyCounter);
- (drawableRuleset as ICanAttachKeyCounter)?.Attach(clicksPerSecondCalculator);
+ if (drawableRuleset is ICanAttachHUDPieces attachTarget)
+ {
+ attachTarget.Attach(KeyCounter);
+ attachTarget.Attach(clicksPerSecondCalculator);
+ }
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
}