mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Fix RoundedButton
not using its default background colour
This commit is contained in:
parent
ace25af949
commit
1fcfeac05f
@ -1,7 +1,6 @@
|
||||
// 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.Diagnostics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -33,9 +32,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private Color4? backgroundColour;
|
||||
|
||||
/// <summary>
|
||||
/// Sets a custom background colour to this button, replacing the provided default.
|
||||
/// </summary>
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get => backgroundColour ?? Color4.White;
|
||||
get => backgroundColour ?? defaultBackgroundColour;
|
||||
set
|
||||
{
|
||||
backgroundColour = value;
|
||||
@ -43,6 +45,23 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 defaultBackgroundColour;
|
||||
|
||||
/// <summary>
|
||||
/// Sets a default background colour to this button.
|
||||
/// </summary>
|
||||
protected Color4 DefaultBackgroundColour
|
||||
{
|
||||
get => defaultBackgroundColour;
|
||||
set
|
||||
{
|
||||
defaultBackgroundColour = value;
|
||||
|
||||
if (backgroundColour == null)
|
||||
Background.FadeColour(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override Container<Drawable> Content { get; }
|
||||
|
||||
protected Box Hover;
|
||||
@ -89,8 +108,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
if (backgroundColour == null)
|
||||
BackgroundColour = colours.BlueDark;
|
||||
DefaultBackgroundColour = colours.BlueDark;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -106,10 +124,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Enabled.Value)
|
||||
{
|
||||
Debug.Assert(backgroundColour != null);
|
||||
Background.FlashColour(backgroundColour.Value.Lighten(0.4f), 200);
|
||||
}
|
||||
Background.FlashColour(BackgroundColour.Lighten(0.4f), 200);
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
@ -29,8 +28,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] OverlayColourProvider overlayColourProvider, OsuColour colours)
|
||||
{
|
||||
if (BackgroundColour == Color4.White)
|
||||
BackgroundColour = overlayColourProvider?.Highlight1 ?? colours.Blue3;
|
||||
DefaultBackgroundColour = overlayColourProvider?.Highlight1 ?? colours.Blue3;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
Loading…
Reference in New Issue
Block a user