2021-05-24 20:49:40 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
2021-05-24 20:49:40 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.KeyBinding
|
|
|
|
|
{
|
2021-05-18 02:57:48 +08:00
|
|
|
|
public class KeyBindingRow : Container, IFilterable
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-24 20:49:40 +08:00
|
|
|
|
private readonly object key;
|
|
|
|
|
private readonly ICollection<Input.Bindings.DatabasedKeyBinding> bindings;
|
|
|
|
|
public readonly BasicKeyBindingRow BasicKeyBindingRow;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
private bool matchingFilter;
|
|
|
|
|
|
|
|
|
|
public bool MatchingFilter
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => matchingFilter;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
matchingFilter = value;
|
|
|
|
|
this.FadeTo(!matchingFilter ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 23:29:07 +08:00
|
|
|
|
public bool FilteringActive { get; set; }
|
|
|
|
|
|
2021-05-24 20:49:40 +08:00
|
|
|
|
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(key.ToString());
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-05-25 19:00:38 +08:00
|
|
|
|
public KeyBindingRow(object key, ICollection<Input.Bindings.DatabasedKeyBinding> bindings, RulesetInfo ruleset, IEnumerable<KeyCombination> defaults) {
|
2021-05-24 20:49:40 +08:00
|
|
|
|
this.key = key;
|
|
|
|
|
this.bindings = bindings;
|
2021-05-15 09:24:08 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
2021-05-24 20:49:40 +08:00
|
|
|
|
Padding = new MarginPadding { Right = SettingsPanel.CONTENT_MARGINS };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-05-24 20:49:40 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-25 19:00:38 +08:00
|
|
|
|
new RestoreDefaultValueButton<bool>()
|
|
|
|
|
{
|
|
|
|
|
Current = BasicKeyBindingRow.IsDefault,
|
|
|
|
|
Action = () => { BasicKeyBindingRow.RestoreDefaults(); }
|
|
|
|
|
},
|
2021-05-24 20:49:40 +08:00
|
|
|
|
new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-05-24 20:49:40 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS },
|
2021-05-25 19:00:38 +08:00
|
|
|
|
Child = BasicKeyBindingRow = new BasicKeyBindingRow(key, bindings.Where(b => ((int)b.Action).Equals((int)key)))
|
|
|
|
|
{
|
|
|
|
|
AllowMainMouseButtons = ruleset != null,
|
|
|
|
|
Defaults = defaults
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-18 02:57:48 +08:00
|
|
|
|
}
|