1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 06:13:03 +08:00

Fix RestoreDefaultValueButton not behaving correctly on number types

This commit is contained in:
Salman Ahmed 2021-06-29 23:39:32 +03:00
parent 5031707048
commit bc0ab7dd4f

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays
{
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
private readonly BindableWithCurrent<T> current = new BindableWithCurrent<T>();
private readonly IBindableWithCurrent<T> current = IBindableWithCurrent<T>.Create();
// this is done to ensure a click on this button doesn't trigger focus on a parent element which contains the button.
public override bool AcceptsFocus => true;
@ -62,7 +62,8 @@ namespace osu.Game.Overlays
Action += () =>
{
if (!current.Disabled) current.SetDefault();
if (!Current.Disabled)
Current.SetDefault();
};
}
@ -96,12 +97,12 @@ namespace osu.Game.Overlays
private void updateState()
{
if (current == null)
if (Current == null)
return;
this.FadeTo(current.IsDefault ? 0f :
hovering && !current.Disabled ? 1f : 0.65f, 200, Easing.OutQuint);
this.FadeColour(current.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint);
this.FadeTo(Current.IsDefault ? 0f :
hovering && !Current.Disabled ? 1f : 0.65f, 200, Easing.OutQuint);
this.FadeColour(Current.Disabled ? Color4.Gray : buttonColour, 200, Easing.OutQuint);
}
}
}