2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
2018-10-02 03:02:47 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu
|
|
|
|
|
{
|
|
|
|
|
public class OsuInputManager : RulesetInputManager<OsuAction>
|
|
|
|
|
{
|
|
|
|
|
public IEnumerable<OsuAction> PressedActions => KeyBindingContainer.PressedActions;
|
|
|
|
|
|
2018-08-17 10:33:14 +00:00
|
|
|
|
public bool AllowUserPresses
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-08-17 10:33:14 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-19 11:52:57 +00:00
|
|
|
|
protected override bool Handle(UIEvent e)
|
|
|
|
|
{
|
|
|
|
|
if (!AllowUserPresses) return false;
|
|
|
|
|
return base.Handle(e);
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum OsuAction
|
|
|
|
|
{
|
2018-09-15 14:30:11 +00:00
|
|
|
|
[Description("Left button")]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
LeftButton,
|
2018-08-17 10:33:14 +00:00
|
|
|
|
|
2018-09-15 14:30:11 +00:00
|
|
|
|
[Description("Right button")]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
RightButton
|
|
|
|
|
}
|
|
|
|
|
}
|