mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Finishing requested changes, and tidy up
This commit is contained in:
@ -108,11 +108,11 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestSingleBindingResetButton()
|
public void TestSingleBindingResetButton()
|
||||||
{
|
{
|
||||||
SettingsKeyBindingRow settingsKeyBindingRow = null;
|
RestorableKeyBindingRow settingsKeyBindingRow = null;
|
||||||
|
|
||||||
AddStep("click first row", () =>
|
AddStep("click first row", () =>
|
||||||
{
|
{
|
||||||
settingsKeyBindingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First();
|
settingsKeyBindingRow = panel.ChildrenOfType<RestorableKeyBindingRow>().First();
|
||||||
|
|
||||||
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
@ -137,11 +137,11 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestResetAllBindingsButton()
|
public void TestResetAllBindingsButton()
|
||||||
{
|
{
|
||||||
SettingsKeyBindingRow settingsKeyBindingRow = null;
|
RestorableKeyBindingRow settingsKeyBindingRow = null;
|
||||||
|
|
||||||
AddStep("click first row", () =>
|
AddStep("click first row", () =>
|
||||||
{
|
{
|
||||||
settingsKeyBindingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First();
|
settingsKeyBindingRow = panel.ChildrenOfType<RestorableKeyBindingRow>().First();
|
||||||
|
|
||||||
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
InputManager.MoveMouseTo(settingsKeyBindingRow);
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
|
@ -38,12 +38,12 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
||||||
{
|
{
|
||||||
// one row per valid 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
|
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 System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.KeyBinding
|
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;
|
private readonly ICollection<Input.Bindings.DatabasedKeyBinding> bindings;
|
||||||
public readonly KeyBindingRow KeyBindingRow;
|
public readonly KeyBindingRow KeyBindingRow;
|
||||||
|
|
||||||
@ -29,28 +30,29 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
|
|
||||||
public bool FilteringActive { get; set; }
|
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(
|
public RestorableKeyBindingRow(
|
||||||
IGrouping<object, Framework.Input.Bindings.KeyBinding> defaultGroup,
|
object key,
|
||||||
ICollection<Input.Bindings.DatabasedKeyBinding> bindings,
|
ICollection<Input.Bindings.DatabasedKeyBinding> bindings,
|
||||||
RulesetInfo ruleset)
|
RulesetInfo ruleset,
|
||||||
|
IEnumerable<KeyCombination> defaults)
|
||||||
{
|
{
|
||||||
this.defaultGroup = defaultGroup;
|
this.key = key;
|
||||||
this.bindings = bindings;
|
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;
|
RestoreDefaultValueButton<bool> restoreDefaultButton;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Padding = new MarginPadding { Right = SettingsPanel.CONTENT_MARGINS };
|
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[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
restoreDefaultButton = new RestoreDefaultValueButton<bool>(),
|
restoreDefaultButton = new RestoreDefaultValueButton<bool>(),
|
Reference in New Issue
Block a user