mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Retrieve KeyBindingContainer
via DI rather than traversal lookup
This commit is contained in:
parent
cc7fb0e559
commit
0e764538e0
@ -2,11 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.ComponentModel;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
[Cached] // Used for touch input, see ColumnTouchInputArea.
|
||||
public class ManiaInputManager : RulesetInputManager<ManiaAction>
|
||||
{
|
||||
public ManiaInputManager(RulesetInfo ruleset, int variant)
|
||||
|
@ -143,6 +143,11 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
public class ColumnTouchInputArea : Drawable
|
||||
{
|
||||
[Resolved(canBeNull: true)]
|
||||
private ManiaInputManager maniaInputManager { get; set; }
|
||||
|
||||
private KeyBindingContainer<ManiaAction> keyBindingContainer;
|
||||
|
||||
public ColumnTouchInputArea()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
@ -152,32 +157,30 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
keyBindingContainer = (ManiaInputManager.RulesetKeyBindingContainer)((ManiaInputManager)GetContainingInputManager()).KeyBindingContainer;
|
||||
keyBindingContainer = maniaInputManager?.KeyBindingContainer;
|
||||
}
|
||||
|
||||
private ManiaInputManager.RulesetKeyBindingContainer keyBindingContainer { get; set; }
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
keyBindingContainer.TriggerPressed(column.Action.Value);
|
||||
keyBindingContainer?.TriggerPressed(column.Action.Value);
|
||||
return base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseUpEvent e)
|
||||
{
|
||||
keyBindingContainer.TriggerReleased(column.Action.Value);
|
||||
keyBindingContainer?.TriggerReleased(column.Action.Value);
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override bool OnTouchDown(TouchDownEvent e)
|
||||
{
|
||||
keyBindingContainer.TriggerPressed(column.Action.Value);
|
||||
keyBindingContainer?.TriggerPressed(column.Action.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnTouchUp(TouchUpEvent e)
|
||||
{
|
||||
keyBindingContainer.TriggerReleased(column.Action.Value);
|
||||
keyBindingContainer?.TriggerReleased(column.Action.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ namespace osu.Game.Rulesets.UI
|
||||
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler, IHasRecordingHandler
|
||||
where T : struct
|
||||
{
|
||||
public readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||
|
||||
private ReplayRecorder recorder;
|
||||
|
||||
public ReplayRecorder Recorder
|
||||
@ -43,8 +45,6 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
protected override InputState CreateInitialState() => new RulesetInputManagerInputState<T>(base.CreateInitialState());
|
||||
|
||||
public readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private readonly Container content;
|
||||
|
Loading…
Reference in New Issue
Block a user