mirror of https://github.com/ppy/osu
Get key binding container once instead of getting on every touch
This commit is contained in:
parent
327822de5b
commit
58994b790c
|
@ -13,6 +13,11 @@ public ManiaInputManager(RulesetInfo ruleset, int variant)
|
||||||
: base(ruleset, variant, SimultaneousBindingMode.Unique)
|
: base(ruleset, variant, SimultaneousBindingMode.Unique)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RulesetKeyBindingContainer GetKeyBindingContainer()
|
||||||
|
{
|
||||||
|
return (RulesetKeyBindingContainer)KeyBindingContainer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ManiaAction
|
public enum ManiaAction
|
||||||
|
|
|
@ -136,31 +136,22 @@ public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://github.com/ppy/osu-framework/blob/49c954321c3686628b2c223670363438f88a0341/osu.Framework/Graphics/Drawable.cs#L1513-L1524
|
private ManiaInputManager.RulesetKeyBindingContainer keyBindingContainer { get; set; }
|
||||||
private T findClosestParent<T>() where T : class, IDrawable
|
|
||||||
|
private ManiaInputManager.RulesetKeyBindingContainer getKeyBindingManager()
|
||||||
{
|
{
|
||||||
Drawable cursor = this;
|
return keyBindingContainer ??= ((ManiaInputManager)GetContainingInputManager()).GetKeyBindingContainer();
|
||||||
|
|
||||||
while ((cursor = cursor.Parent) != null)
|
|
||||||
{
|
|
||||||
if (cursor is T match)
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
|
|
||||||
return default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ManiaInputManager.RulesetKeyBindingContainer keyBindingManager => findClosestParent<ManiaInputManager.RulesetKeyBindingContainer>();
|
|
||||||
|
|
||||||
protected override bool OnTouchDown(TouchDownEvent e)
|
protected override bool OnTouchDown(TouchDownEvent e)
|
||||||
{
|
{
|
||||||
keyBindingManager.TriggerPressed(Action.Value);
|
getKeyBindingManager().TriggerPressed(Action.Value);
|
||||||
return base.OnTouchDown(e);
|
return base.OnTouchDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTouchUp(TouchUpEvent e)
|
protected override void OnTouchUp(TouchUpEvent e)
|
||||||
{
|
{
|
||||||
keyBindingManager.TriggerReleased(Action.Value);
|
getKeyBindingManager().TriggerReleased(Action.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
||||||
|
|
|
@ -50,6 +50,7 @@ public abstract class DrawableRuleset<TObject> : DrawableRuleset, IProvideCursor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The key conversion input manager for this DrawableRuleset.
|
/// The key conversion input manager for this DrawableRuleset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Cached]
|
||||||
public PassThroughInputManager KeyBindingInputManager;
|
public PassThroughInputManager KeyBindingInputManager;
|
||||||
|
|
||||||
public override double GameplayStartTime => Objects.FirstOrDefault()?.StartTime - 2000 ?? 0;
|
public override double GameplayStartTime => Objects.FirstOrDefault()?.StartTime - 2000 ?? 0;
|
||||||
|
|
Loading…
Reference in New Issue