mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 11:42:56 +08:00
Reformatting
This commit is contained in:
parent
753bdf2083
commit
1603b92211
@ -4,7 +4,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Overlays;
|
||||
@ -32,16 +31,14 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
[Test]
|
||||
public void TestClickTwiceOnClearButton()
|
||||
{
|
||||
SettingsKeyBindingRow firstSettingRow = null;
|
||||
KeyBindingRow firstRow = null;
|
||||
|
||||
AddStep("click first row", () =>
|
||||
{
|
||||
firstSettingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First();
|
||||
InputManager.MoveMouseTo(firstSettingRow);
|
||||
InputManager.MoveMouseTo(panel.ChildrenOfType<SettingsKeyBindingRow>().First());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
||||
firstRow = firstSettingRow.KeyBindingRow;
|
||||
firstRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First().KeyBindingRow;
|
||||
});
|
||||
|
||||
AddStep("schedule button clicks", () =>
|
||||
@ -111,12 +108,10 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
[Test]
|
||||
public void TestSingleBindResetButton()
|
||||
{
|
||||
SettingsKeyBindingRow multiSettingsBindingRow = null;
|
||||
KeyBindingRow multiBindingRow = null;
|
||||
|
||||
AddStep("click first row with two bindings", () =>
|
||||
{
|
||||
multiSettingsBindingRow = panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1);
|
||||
multiBindingRow = panel.ChildrenOfType<KeyBindingRow>().First(row => row.Defaults.Count() > 1);
|
||||
InputManager.MoveMouseTo(multiBindingRow);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
@ -124,20 +119,20 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
InputManager.ReleaseKey(Key.P);
|
||||
});
|
||||
|
||||
AddUntilStep("restore button shown", () => multiSettingsBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha > 0);
|
||||
AddUntilStep("restore button shown", () => panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1).ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha > 0);
|
||||
|
||||
clickSingleBindResetButton();
|
||||
|
||||
AddAssert("first binding cleared", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(0)));
|
||||
AddAssert("second binding cleared", () => multiBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(1)));
|
||||
AddAssert("first binding cleared", () => panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1).ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(0)));
|
||||
AddAssert("second binding cleared", () => panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1).ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(1).KeyBinding.KeyCombination.Equals(multiBindingRow.Defaults.ElementAt(1)));
|
||||
|
||||
AddUntilStep("restore button hidden", () => multiSettingsBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
|
||||
AddUntilStep("restore button hidden", () => panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1).ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
|
||||
|
||||
void clickSingleBindResetButton()
|
||||
{
|
||||
AddStep("click reset button for bindings", () =>
|
||||
{
|
||||
var clearButton = multiSettingsBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().Single();
|
||||
var clearButton = panel.ChildrenOfType<SettingsKeyBindingRow>().First(row => row.KeyBindingRow.Defaults.Count() > 1).ChildrenOfType<RestoreDefaultValueButton<bool>>().Single();
|
||||
|
||||
InputManager.MoveMouseTo(clearButton);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
|
@ -53,7 +53,8 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
private FillFlowContainer cancelAndClearButtons;
|
||||
private FillFlowContainer<KeyButton> buttons;
|
||||
|
||||
private BindableWithCurrent<bool> isKeysDefaultValue;
|
||||
private readonly BindableWithCurrent<bool> isKeysDefaultValue;
|
||||
|
||||
public Bindable<bool> Current
|
||||
{
|
||||
get => isKeysDefaultValue.Current;
|
||||
@ -67,7 +68,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
this.action = action;
|
||||
this.bindings = bindings;
|
||||
|
||||
isKeysDefaultValue = new BindableWithCurrent<bool>()
|
||||
isKeysDefaultValue = new BindableWithCurrent<bool>
|
||||
{
|
||||
Default = true
|
||||
};
|
||||
@ -314,6 +315,7 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
store.Update(bindTarget.KeyBinding);
|
||||
|
||||
KeyCombination keyDefault = Defaults.ElementAt(buttons.IndexOf(bindTarget));
|
||||
|
||||
if (isKeysDefaultValue.Value)
|
||||
{
|
||||
if (!keyDefault.Equals(bindTarget.KeyBinding.KeyCombination))
|
||||
|
@ -1,20 +1,17 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Overlays.KeyBinding
|
||||
{
|
||||
@ -41,8 +38,6 @@ namespace osu.Game.Overlays.KeyBinding
|
||||
|
||||
foreach (var defaultGroup in Defaults.GroupBy(d => d.Action))
|
||||
{
|
||||
int intKey = (int)defaultGroup.Key;
|
||||
|
||||
// one row per valid action.
|
||||
Add(new SettingsKeyBindingRow(defaultGroup, bindings, Ruleset));
|
||||
}
|
||||
|
@ -5,16 +5,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
Loading…
Reference in New Issue
Block a user