mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:43:21 +08:00
Update colour scheme of footer in line with visible overlay
This commit is contained in:
parent
2319fa11ec
commit
b8816bfc28
@ -9,11 +9,11 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public class OverlayColourProvider
|
||||
{
|
||||
private readonly OverlayColourScheme colourScheme;
|
||||
public OverlayColourScheme ColourScheme { get; private set; }
|
||||
|
||||
public OverlayColourProvider(OverlayColourScheme colourScheme)
|
||||
{
|
||||
this.colourScheme = colourScheme;
|
||||
ColourScheme = colourScheme;
|
||||
}
|
||||
|
||||
// Note that the following five colours are also defined in `OsuColour` as `{colourScheme}{0,1,2,3,4}`.
|
||||
@ -47,7 +47,17 @@ namespace osu.Game.Overlays
|
||||
public Color4 Background5 => getColour(0.1f, 0.15f);
|
||||
public Color4 Background6 => getColour(0.1f, 0.1f);
|
||||
|
||||
private Color4 getColour(float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, 1));
|
||||
/// <summary>
|
||||
/// Changes the value of <see cref="ColourScheme"/> to a different colour scheme.
|
||||
/// Note that this does not trigger any kind of signal to any drawable that received colours from here, all drawables need to be updated manually.
|
||||
/// </summary>
|
||||
/// <param name="colourScheme">The proposed colour scheme.</param>
|
||||
public void ChangeColourScheme(OverlayColourScheme colourScheme)
|
||||
{
|
||||
ColourScheme = colourScheme;
|
||||
}
|
||||
|
||||
private Color4 getColour(float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(ColourScheme), saturation, lightness, 1));
|
||||
|
||||
// See https://github.com/ppy/osu-web/blob/5a536d217a21582aad999db50a981003d3ad5659/app/helpers.php#L1620-L1628
|
||||
private static float getBaseHue(OverlayColourScheme colourScheme)
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK;
|
||||
|
||||
@ -58,7 +59,7 @@ namespace osu.Game.Screens.Footer
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background5
|
||||
@ -194,6 +195,8 @@ namespace osu.Game.Screens.Footer
|
||||
|
||||
var targetPosition = targetButton?.ToSpaceOfOtherDrawable(targetButton.LayoutRectangle.TopRight, this) ?? fallbackPosition;
|
||||
|
||||
updateColourScheme(overlay.ColourProvider.ColourScheme);
|
||||
|
||||
var content = overlay.CreateFooterContent();
|
||||
|
||||
Add(contentContainer = new Container
|
||||
@ -229,6 +232,18 @@ namespace osu.Game.Screens.Footer
|
||||
temporarilyHiddenButtons.Clear();
|
||||
|
||||
expireTarget.Delay(timeUntilRun).Expire();
|
||||
|
||||
updateColourScheme(OverlayColourScheme.Aquamarine);
|
||||
}
|
||||
|
||||
private void updateColourScheme(OverlayColourScheme colourScheme)
|
||||
{
|
||||
colourProvider.ChangeColourScheme(colourScheme);
|
||||
|
||||
background.FadeColour(colourProvider.Background5, 150, Easing.OutQuint);
|
||||
|
||||
foreach (var button in buttonsFlow)
|
||||
button.UpdateDisplay();
|
||||
}
|
||||
|
||||
private void makeButtonAppearFromLeft(ScreenFooterButton button, int index, int count, float startDelay)
|
||||
|
@ -166,8 +166,8 @@ namespace osu.Game.Screens.Footer
|
||||
if (Overlay != null)
|
||||
OverlayState.BindTo(Overlay.State);
|
||||
|
||||
OverlayState.BindValueChanged(_ => updateDisplay());
|
||||
Enabled.BindValueChanged(_ => updateDisplay(), true);
|
||||
OverlayState.BindValueChanged(_ => UpdateDisplay());
|
||||
Enabled.BindValueChanged(_ => UpdateDisplay(), true);
|
||||
|
||||
FinishTransforms(true);
|
||||
}
|
||||
@ -186,11 +186,11 @@ namespace osu.Game.Screens.Footer
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateDisplay();
|
||||
UpdateDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e) => updateDisplay();
|
||||
protected override void OnHoverLost(HoverLostEvent e) => UpdateDisplay();
|
||||
|
||||
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
@ -202,7 +202,7 @@ namespace osu.Game.Screens.Footer
|
||||
|
||||
public virtual void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) { }
|
||||
|
||||
private void updateDisplay()
|
||||
public void UpdateDisplay()
|
||||
{
|
||||
Color4 backgroundColour = OverlayState.Value == Visibility.Visible ? buttonAccentColour : colourProvider.Background3;
|
||||
Color4 textColour = OverlayState.Value == Visibility.Visible ? colourProvider.Background6 : colourProvider.Content1;
|
||||
|
Loading…
Reference in New Issue
Block a user