mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Adding a reset button to individual keybinds
This commit is contained in:
@ -104,6 +104,46 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSingleBindResetButton()
|
||||||
|
{
|
||||||
|
KeyBindingRow multiBindingRow = null;
|
||||||
|
|
||||||
|
AddStep("click first row with two bindings", () =>
|
||||||
|
{
|
||||||
|
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
|
||||||
|
InputManager.MoveMouseTo(multiBindingRow);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
clickSingleBindResetButton();
|
||||||
|
|
||||||
|
AddAssert("first binding cleared", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(0)));
|
||||||
|
|
||||||
|
AddStep("click second binding", () =>
|
||||||
|
{
|
||||||
|
var target = multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1);
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(target);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
clickSingleBindResetButton();
|
||||||
|
|
||||||
|
AddAssert("second binding cleared", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(1)));
|
||||||
|
|
||||||
|
void clickSingleBindResetButton()
|
||||||
|
{
|
||||||
|
AddStep("click reset button for single binding", () =>
|
||||||
|
{
|
||||||
|
var clearButton = multiBindingRow.ChildrenOfType<KeyBindingRow.SingleBindResetButton>().Single();
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(clearButton);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestClickRowSelectsFirstBinding()
|
public void TestClickRowSelectsFirstBinding()
|
||||||
{
|
{
|
||||||
|
@ -109,6 +109,7 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new CancelButton { Action = finalise },
|
new CancelButton { Action = finalise },
|
||||||
|
new SingleBindResetButton { Action = singleBindReset },
|
||||||
new ClearButton { Action = clear },
|
new ClearButton { Action = clear },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -281,6 +282,15 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
finalise();
|
finalise();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void singleBindReset()
|
||||||
|
{
|
||||||
|
if (bindTarget == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bindTarget.UpdateKeyCombination(Defaults.ElementAt(buttons.IndexOf(bindTarget)));
|
||||||
|
finalise();
|
||||||
|
}
|
||||||
|
|
||||||
private void finalise()
|
private void finalise()
|
||||||
{
|
{
|
||||||
if (bindTarget != null)
|
if (bindTarget != null)
|
||||||
@ -339,6 +349,24 @@ namespace osu.Game.Overlays.KeyBinding
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SingleBindResetButton : TriangleButton
|
||||||
|
{
|
||||||
|
public SingleBindResetButton()
|
||||||
|
{
|
||||||
|
Text = "Reset";
|
||||||
|
Size = new Vector2(80, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
BackgroundColour = colours.Green;
|
||||||
|
|
||||||
|
Triangles.ColourDark = colours.GreenDark;
|
||||||
|
Triangles.ColourLight = colours.GreenLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class ClearButton : TriangleButton
|
public class ClearButton : TriangleButton
|
||||||
{
|
{
|
||||||
public ClearButton()
|
public ClearButton()
|
||||||
|
Reference in New Issue
Block a user