1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00
osu-lazer/osu.Game.Rulesets.Osu/OsuInputManager.cs

55 lines
1.6 KiB
C#

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.ComponentModel;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Osu
{
public class OsuInputManager : RulesetInputManager<OsuAction>
{
public IEnumerable<OsuAction> PressedActions => KeyBindingContainer.PressedActions;
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 Handle(UIEvent e)
{
if (!AllowUserPresses) return false;
return base.Handle(e);
}
}
}
public enum OsuAction
{
[Description("Left button")]
LeftButton,
[Description("Right button")]
RightButton
}
}