1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Merge pull request #27969 from bdach/enter-to-confirm-keybinding-conflict

Allow confirming keybinding overwrite on conflict via "select" binding
This commit is contained in:
Dean Herbert 2024-04-23 23:38:50 +08:00 committed by GitHub
commit 999c8fdc38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 2 deletions

View File

@ -296,7 +296,7 @@ namespace osu.Game.Tests.Visual.Settings
}
[Test]
public void TestBindingConflictResolvedByRollback()
public void TestBindingConflictResolvedByRollbackViaMouse()
{
AddStep("reset taiko section to default", () =>
{
@ -315,7 +315,7 @@ namespace osu.Game.Tests.Visual.Settings
}
[Test]
public void TestBindingConflictResolvedByOverwrite()
public void TestBindingConflictResolvedByOverwriteViaMouse()
{
AddStep("reset taiko section to default", () =>
{
@ -333,6 +333,46 @@ namespace osu.Game.Tests.Visual.Settings
checkBinding("Left (rim)", "M1");
}
[Test]
public void TestBindingConflictResolvedByRollbackViaKeyboard()
{
AddStep("reset taiko & global sections to default", () =>
{
panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset))
.ChildrenOfType<ResetButton>().Single().TriggerClick();
panel.ChildrenOfType<ResetButton>().First().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
scrollToAndStartBinding("Left (rim)");
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
AddUntilStep("wait for popover", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
AddStep("press Esc", () => InputManager.Key(Key.Escape));
checkBinding("Left (centre)", "M1");
checkBinding("Left (rim)", "M2");
}
[Test]
public void TestBindingConflictResolvedByOverwriteViaKeyboard()
{
AddStep("reset taiko & global sections to default", () =>
{
panel.ChildrenOfType<VariantBindingsSubsection>().First(section => new TaikoRuleset().RulesetInfo.Equals(section.Ruleset))
.ChildrenOfType<ResetButton>().Single().TriggerClick();
panel.ChildrenOfType<ResetButton>().First().TriggerClick();
});
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(panel.ScreenSpaceDrawQuad.Centre));
scrollToAndStartBinding("Left (rim)");
AddStep("attempt to bind M1 to two keys", () => InputManager.Click(MouseButton.Left));
AddUntilStep("wait for popover", () => panel.ChildrenOfType<KeyBindingConflictPopover>().SingleOrDefault(), () => Is.Not.Null);
AddStep("press Enter", () => InputManager.Key(Key.Enter));
checkBinding("Left (centre)", InputSettingsStrings.ActionHasNoKeyBinding.ToString());
checkBinding("Left (rim)", "M1");
}
[Test]
public void TestBindingConflictCausedByResetToDefaultOfSingleRow()
{

View File

@ -152,6 +152,17 @@ namespace osu.Game.Overlays.Settings.Sections.Input
newPreview.IsChosen.Value = applyNewButton.IsHovered;
}
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Action == GlobalAction.Select && !e.Repeat)
{
applyNew();
return true;
}
return base.OnPressed(e);
}
private partial class ConflictingKeyBindingPreview : CompositeDrawable
{
private readonly object action;