Update KeyCounterCollection to support action-based buttons

This commit is contained in:
Dean Herbert
2017-08-21 12:31:21 +09:00
parent aa5afc30ef
commit 16e96888ab
23 changed files with 140 additions and 65 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The key conversion input manager for this RulesetContainer.
/// </summary>
protected readonly PassThroughInputManager KeyConversionInputManager;
public readonly PassThroughInputManager KeyBindingInputManager;
/// <summary>
/// Whether we are currently providing the local user a gameplay cursor.
@ -76,8 +76,10 @@ namespace osu.Game.Rulesets.UI
internal RulesetContainer(Ruleset ruleset)
{
Ruleset = ruleset;
KeyConversionInputManager = CreateKeyBindingInputManager();
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
KeyBindingInputManager = CreateInputManager();
if (!(KeyBindingInputManager is ICanAttachKeyCounter))
throw new InvalidOperationException($"Rulesets should create input managers of type {nameof(ICanAttachKeyCounter)}");
KeyBindingInputManager.RelativeSizeAxes = Axes.Both;
}
/// <summary>
@ -92,10 +94,10 @@ namespace osu.Game.Rulesets.UI
public abstract ScoreProcessor CreateScoreProcessor();
/// <summary>
/// Creates a key conversion input manager.
/// Creates a key conversion input manager. An exception will be thrown if a valid <see cref="RulesetInputManager{T}"/> is not returned.
/// </summary>
/// <returns>The input manager.</returns>
public virtual PassThroughInputManager CreateKeyBindingInputManager() => new PassThroughInputManager();
public abstract PassThroughInputManager CreateInputManager();
protected virtual FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new FramedReplayInputHandler(replay);
@ -253,7 +255,7 @@ namespace osu.Game.Rulesets.UI
InputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new[] { KeyConversionInputManager }
Children = new[] { KeyBindingInputManager }
});
AddInternal(InputManager);
@ -262,7 +264,7 @@ namespace osu.Game.Rulesets.UI
[BackgroundDependencyLoader]
private void load()
{
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
KeyBindingInputManager.Add(Playfield = CreatePlayfield());
loadObjects();