1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:07:25 +08:00

Don't match on partial key chords when concurrent is disallowed

This commit is contained in:
Dean Herbert 2017-08-10 16:45:33 +09:00
parent d9e36237c7
commit da50101c25
2 changed files with 9 additions and 3 deletions

View File

@ -81,7 +81,7 @@ namespace osu.Game.Input
{ {
Binding validBinding; Binding validBinding;
if ((validBinding = mappings.Except(pressedBindings).LastOrDefault(m => m.Keys.CheckValid(state.Keyboard.Keys))) != null) if ((validBinding = mappings.Except(pressedBindings).LastOrDefault(m => m.Keys.CheckValid(state.Keyboard.Keys, !allowConcurrentActions))) != null)
{ {
// store both the pressed combination and the resulting action, just in case the assignments change while we are actuated. // store both the pressed combination and the resulting action, just in case the assignments change while we are actuated.
pressedBindings.Add(validBinding); pressedBindings.Add(validBinding);
@ -96,7 +96,7 @@ namespace osu.Game.Input
{ {
foreach (var binding in pressedBindings.ToList()) foreach (var binding in pressedBindings.ToList())
{ {
if (!binding.Keys.CheckValid(state.Keyboard.Keys)) if (!binding.Keys.CheckValid(state.Keyboard.Keys, !allowConcurrentActions))
{ {
// set data as KeyUp. // set data as KeyUp.
state.Data = binding.GetAction<T>(); state.Data = binding.GetAction<T>();

View File

@ -30,7 +30,13 @@ namespace osu.Game.Input
Keys = stringRepresentation.Split(',').Select(s => (Key)int.Parse(s)); Keys = stringRepresentation.Split(',').Select(s => (Key)int.Parse(s));
} }
public bool CheckValid(IEnumerable<Key> keys) => !Keys.Except(keys).Any(); public bool CheckValid(IEnumerable<Key> keys, bool requireExactMatch = false)
{
if (requireExactMatch)
return Keys.SequenceEqual(keys);
else
return !Keys.Except(keys).Any();
}
public bool Equals(KeyCombination other) public bool Equals(KeyCombination other)
{ {