Fix RestoreDefaultValueButton's colour weirdness

This commit is contained in:
Dean Herbert 2021-08-17 12:48:30 +09:00
parent 212842c537
commit bc86bafc08
2 changed files with 5 additions and 7 deletions

View File

@ -36,6 +36,7 @@ namespace osu.Game.Graphics.UserInterface
public Color4 BackgroundColour public Color4 BackgroundColour
{ {
get => backgroundColour ?? Color4.White;
set set
{ {
backgroundColour = value; backgroundColour = value;

View File

@ -45,8 +45,6 @@ namespace osu.Game.Overlays
} }
} }
private Color4 buttonColour;
private bool hovering; private bool hovering;
public RestoreDefaultValueButton() public RestoreDefaultValueButton()
@ -61,12 +59,11 @@ namespace osu.Game.Overlays
private void load(OsuColour colour) private void load(OsuColour colour)
{ {
BackgroundColour = colour.Yellow; BackgroundColour = colour.Yellow;
buttonColour = colour.Yellow;
Content.Width = 0.33f; Content.Width = 0.33f;
Content.CornerRadius = 3; Content.CornerRadius = 3;
Content.EdgeEffect = new EdgeEffectParameters Content.EdgeEffect = new EdgeEffectParameters
{ {
Colour = buttonColour.Opacity(0.1f), Colour = BackgroundColour.Opacity(0.1f),
Type = EdgeEffectType.Glow, Type = EdgeEffectType.Glow,
Radius = 2, Radius = 2,
}; };
@ -87,7 +84,7 @@ namespace osu.Game.Overlays
// avoid unnecessary transforms on first display. // avoid unnecessary transforms on first display.
Alpha = currentAlpha; Alpha = currentAlpha;
Colour = currentColour; Background.Colour = currentColour;
} }
public LocalisableString TooltipText => "revert to default"; public LocalisableString TooltipText => "revert to default";
@ -108,7 +105,7 @@ namespace osu.Game.Overlays
public void UpdateState() => Scheduler.AddOnce(updateState); public void UpdateState() => Scheduler.AddOnce(updateState);
private float currentAlpha => current.IsDefault ? 0f : hovering && !current.Disabled ? 1f : 0.65f; private float currentAlpha => current.IsDefault ? 0f : hovering && !current.Disabled ? 1f : 0.65f;
private ColourInfo currentColour => current.Disabled ? Color4.Gray : buttonColour; private ColourInfo currentColour => current.Disabled ? Color4.Gray : BackgroundColour;
private void updateState() private void updateState()
{ {
@ -116,7 +113,7 @@ namespace osu.Game.Overlays
return; return;
this.FadeTo(currentAlpha, 200, Easing.OutQuint); this.FadeTo(currentAlpha, 200, Easing.OutQuint);
this.FadeColour(currentColour, 200, Easing.OutQuint); Background.FadeColour(currentColour, 200, Easing.OutQuint);
} }
} }
} }