mirror of
https://github.com/ppy/osu
synced 2024-12-16 20:05:41 +00:00
Finishing requested changes, and tidy up
This commit is contained in:
parent
b5e1f78c06
commit
264d8b9b86
@ -108,11 +108,11 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
[Test]
|
||||
public void TestSingleBindingResetButton()
|
||||
{
|
||||
SettingsKeyBindingRow settingsKeyBindingRow = null;
|
||||
RestorableKeyBindingRow settingsKeyBindingRow = null;
|
||||
|
||||
AddStep("click first row", () =>
|
||||
{
|
||||
settingsKeyBindingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First();
|
||||
settingsKeyBindingRow = panel.ChildrenOfType<RestorableKeyBindingRow>().First();
|
||||
|
||||
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
@ -137,11 +137,11 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
[Test]
|
||||
public void TestResetAllBindingsButton()
|
||||
{
|
||||
SettingsKeyBindingRow settingsKeyBindingRow = null;
|
||||
RestorableKeyBindingRow settingsKeyBindingRow = null;
|
||||
|
||||
AddStep("click first row", () =>
|
||||
{
|
||||
settingsKeyBindingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First();
|
||||
settingsKeyBindingRow = panel.ChildrenOfType<RestorableKeyBindingRow>().First();
|
||||
|
||||
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
@ -38,12 +38,12 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
||||
{
|
||||
// one row per valid action.
|
||||
Add(new SettingsKeyBindingRow(defaultGroup, bindings, Ruleset));
|
||||
Add(new RestorableKeyBindingRow(defaultGroup.Key, bindings, Ruleset, defaultGroup.Select(d => d.KeyCombination)));
|
||||
}
|
||||
|
||||
Add(new ResetButton
|
||||
{
|
||||
Action = () => Children.OfType<SettingsKeyBindingRow>().ForEach(k => k.KeyBindingRow.RestoreDefaults())
|
||||
Action = () => Children.OfType<RestorableKeyBindingRow>().ForEach(k => k.KeyBindingRow.RestoreDefaults())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,14 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
public class SettingsKeyBindingRow : Container, IFilterable
|
||||
public class RestorableKeyBindingRow : Container, IFilterable
|
||||
{
|
||||
private readonly IGrouping<object, Framework.Input.Bindings.KeyBinding> defaultGroup;
|
||||
private readonly object key;
|
||||
private readonly ICollection<Input.Bindings.DatabasedKeyBinding> bindings;
|
||||
public readonly KeyBindingRow KeyBindingRow;
|
||||
|
||||
@ -29,28 +30,29 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
public bool FilteringActive { get; set; }
|
||||
|
||||
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(defaultGroup.Key.ToString());
|
||||
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(key.ToString());
|
||||
|
||||
public SettingsKeyBindingRow(
|
||||
IGrouping<object, Framework.Input.Bindings.KeyBinding> defaultGroup,
|
||||
public RestorableKeyBindingRow(
|
||||
object key,
|
||||
ICollection<Input.Bindings.DatabasedKeyBinding> bindings,
|
||||
RulesetInfo ruleset)
|
||||
RulesetInfo ruleset,
|
||||
IEnumerable<KeyCombination> defaults)
|
||||
{
|
||||
this.defaultGroup = defaultGroup;
|
||||
this.key = key;
|
||||
this.bindings = bindings;
|
||||
|
||||
KeyBindingRow = new KeyBindingRow(defaultGroup.Key, bindings.Where(b => ((int)b.Action).Equals((int)defaultGroup.Key)))
|
||||
{
|
||||
AllowMainMouseButtons = ruleset != null,
|
||||
Defaults = defaultGroup.Select(d => d.KeyCombination)
|
||||
};
|
||||
|
||||
RestoreDefaultValueButton<bool> restoreDefaultButton;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Padding = new MarginPadding { Right = SettingsPanel.CONTENT_MARGINS };
|
||||
|
||||
KeyBindingRow = new KeyBindingRow(key, bindings.Where(b => ((int)b.Action).Equals((int)key)))
|
||||
{
|
||||
AllowMainMouseButtons = ruleset != null,
|
||||
Defaults = defaults
|
||||
};
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
restoreDefaultButton = new RestoreDefaultValueButton<bool>(),
|
Loading…
Reference in New Issue
Block a user