mirror of https://github.com/ppy/osu
Always use `OverlayColourProvider` in dropdowns if available
This commit is contained in:
parent
d205483a36
commit
d4e3460912
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
@ -14,6 +16,7 @@
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
|
@ -34,11 +37,11 @@ public Color4 AccentColour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours)
|
private void load(OverlayColourProvider? colourProvider, OsuColour colours)
|
||||||
{
|
{
|
||||||
if (accentColour == default)
|
if (accentColour == default)
|
||||||
accentColour = colours.PinkDarker;
|
accentColour = colourProvider?.Light4 ?? colours.PinkDarker;
|
||||||
updateAccentColour();
|
updateAccentColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,14 +62,13 @@ protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour
|
||||||
{
|
{
|
||||||
public override bool HandleNonPositionalInput => State == MenuState.Open;
|
public override bool HandleNonPositionalInput => State == MenuState.Open;
|
||||||
|
|
||||||
private Sample sampleOpen;
|
private Sample? sampleOpen;
|
||||||
private Sample sampleClose;
|
private Sample? sampleClose;
|
||||||
|
|
||||||
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
// todo: this uses the same styling as OsuMenu. hopefully we can just use OsuMenu in the future with some refactoring
|
||||||
public OsuDropdownMenu()
|
public OsuDropdownMenu()
|
||||||
{
|
{
|
||||||
CornerRadius = corner_radius;
|
CornerRadius = corner_radius;
|
||||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
|
||||||
|
|
||||||
MaskingContainer.CornerRadius = corner_radius;
|
MaskingContainer.CornerRadius = corner_radius;
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
|
@ -75,9 +77,11 @@ public OsuDropdownMenu()
|
||||||
ItemsContainer.Padding = new MarginPadding(5);
|
ItemsContainer.Padding = new MarginPadding(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio)
|
private void load(OverlayColourProvider? colourProvider, AudioManager audio)
|
||||||
{
|
{
|
||||||
|
BackgroundColour = colourProvider?.Background5 ?? Color4.Black.Opacity(0.5f);
|
||||||
|
|
||||||
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
||||||
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
||||||
}
|
}
|
||||||
|
@ -312,11 +316,11 @@ public OsuDropdownHeader()
|
||||||
AddInternal(new HoverClickSounds());
|
AddInternal(new HoverClickSounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colours)
|
private void load(OverlayColourProvider? colourProvider, OsuColour colours)
|
||||||
{
|
{
|
||||||
BackgroundColour = Color4.Black.Opacity(0.5f);
|
BackgroundColour = colourProvider?.Background5 ?? Color4.Black.Opacity(0.5f);
|
||||||
BackgroundColourHover = colours.PinkDarker;
|
BackgroundColourHover = colourProvider?.Light4 ?? colours.PinkDarker;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue