mirror of https://github.com/ppy/osu
Simplify default handling flow
This commit is contained in:
parent
7c9383b586
commit
c05dfee220
|
@ -58,7 +58,7 @@ public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
|
||||||
private FillFlowContainer cancelAndClearButtons;
|
private FillFlowContainer cancelAndClearButtons;
|
||||||
private FillFlowContainer<KeyButton> buttons;
|
private FillFlowContainer<KeyButton> buttons;
|
||||||
|
|
||||||
public Bindable<bool> IsDefault { get; } = new BindableBool(true);
|
private Bindable<bool> isDefault { get; } = new BindableBool(true);
|
||||||
|
|
||||||
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(text.Text.ToString());
|
public IEnumerable<string> FilterTerms => bindings.Select(b => b.KeyCombination.ReadableString()).Prepend(text.Text.ToString());
|
||||||
|
|
||||||
|
@ -77,8 +77,6 @@ public KeyBindingRow(object action, IEnumerable<Framework.Input.Bindings.KeyBind
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
updateIsDefaultValue();
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS };
|
Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS };
|
||||||
|
@ -87,7 +85,7 @@ private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
new RestoreDefaultValueButton<bool>
|
new RestoreDefaultValueButton<bool>
|
||||||
{
|
{
|
||||||
Current = IsDefault,
|
Current = isDefault,
|
||||||
Action = RestoreDefaults,
|
Action = RestoreDefaults,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
|
@ -143,19 +141,8 @@ private void load(OsuColour colours)
|
||||||
|
|
||||||
foreach (var b in bindings)
|
foreach (var b in bindings)
|
||||||
buttons.Add(new KeyButton(b));
|
buttons.Add(new KeyButton(b));
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
updateIsDefaultValue();
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
IsDefault.BindValueChanged(isDefault =>
|
|
||||||
{
|
|
||||||
if (isDefault.NewValue)
|
|
||||||
{
|
|
||||||
finalise();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestoreDefaults()
|
public void RestoreDefaults()
|
||||||
|
@ -169,7 +156,7 @@ public void RestoreDefaults()
|
||||||
store.Update(button.KeyBinding);
|
store.Update(button.KeyBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateIsDefaultValue();
|
isDefault.Value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
|
@ -376,7 +363,7 @@ private void updateBindTarget()
|
||||||
|
|
||||||
private void updateIsDefaultValue()
|
private void updateIsDefaultValue()
|
||||||
{
|
{
|
||||||
IsDefault.Value = bindings.Select(b => b.KeyCombination).SequenceEqual(Defaults);
|
isDefault.Value = bindings.Select(b => b.KeyCombination).SequenceEqual(Defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CancelButton : TriangleButton
|
private class CancelButton : TriangleButton
|
||||||
|
|
Loading…
Reference in New Issue