mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Block user input
This commit is contained in:
parent
bc22a28fef
commit
442f6795bc
@ -84,6 +84,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
// grab the input manager for future use.
|
// grab the input manager for future use.
|
||||||
osuInputManager = (OsuInputManager)rulesetContainer.KeyBindingInputManager;
|
osuInputManager = (OsuInputManager)rulesetContainer.KeyBindingInputManager;
|
||||||
|
osuInputManager.AllowUserPresses = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.EventArgs;
|
||||||
|
using osu.Framework.Input.States;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu
|
namespace osu.Game.Rulesets.Osu
|
||||||
@ -12,8 +14,34 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
public IEnumerable<OsuAction> PressedActions => KeyBindingContainer.PressedActions;
|
public IEnumerable<OsuAction> PressedActions => KeyBindingContainer.PressedActions;
|
||||||
|
|
||||||
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
|
public bool AllowUserPresses
|
||||||
{
|
{
|
||||||
|
set => ((OsuKeyBindingContainer)KeyBindingContainer).AllowUserPresses = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override RulesetKeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
=> new OsuKeyBindingContainer(ruleset, variant, unique);
|
||||||
|
|
||||||
|
public OsuInputManager(RulesetInfo ruleset)
|
||||||
|
: base(ruleset, 0, SimultaneousBindingMode.Unique)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OsuKeyBindingContainer : RulesetKeyBindingContainer
|
||||||
|
{
|
||||||
|
public bool AllowUserPresses = true;
|
||||||
|
|
||||||
|
public OsuKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
|
: base(ruleset, variant, unique)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) => AllowUserPresses && base.OnKeyDown( state,args);
|
||||||
|
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) => AllowUserPresses && base.OnKeyUp( state,args);
|
||||||
|
protected override bool OnJoystickPress(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickPress( state,args);
|
||||||
|
protected override bool OnJoystickRelease(InputState state, JoystickEventArgs args) => AllowUserPresses && base.OnJoystickRelease( state,args);
|
||||||
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => AllowUserPresses && base.OnMouseDown( state,args);
|
||||||
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => AllowUserPresses && base.OnMouseUp( state,args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +49,7 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
[Description("Left Button")]
|
[Description("Left Button")]
|
||||||
LeftButton,
|
LeftButton,
|
||||||
|
|
||||||
[Description("Right Button")]
|
[Description("Right Button")]
|
||||||
RightButton
|
RightButton
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user