mirror of https://github.com/ppy/osu
Allow using `ThemedDropdown` even if `OverlayColourProvider` not available
This is to accommodate `SettingsDropdown` usages without an available `OverlayColourProvider`, such as mod settings controls and tournament client usages.
This commit is contained in:
parent
7139c832b0
commit
7c5bd2db7b
|
@ -1,6 +1,8 @@
|
|||
// 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.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
@ -9,13 +11,15 @@
|
|||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
/// <summary>
|
||||
/// A variant of <see cref="OsuDropdown{T}"/> that uses the nearest <see cref="OverlayColourProvider"/> for theming purposes.
|
||||
/// A variant of <see cref="OsuDropdown{T}"/> that uses the nearest <see cref="OverlayColourProvider"/> for theming purposes, if one is available.
|
||||
/// </summary>
|
||||
public class ThemedDropdown<T> : OsuDropdown<T>
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OverlayColourProvider? colourProvider)
|
||||
{
|
||||
if (colourProvider == null) return;
|
||||
|
||||
AccentColour = colourProvider.Light4;
|
||||
}
|
||||
|
||||
|
@ -25,9 +29,11 @@ private void load(OverlayColourProvider colourProvider)
|
|||
|
||||
protected class ThemedDropdownMenu : OsuDropdownMenu
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OverlayColourProvider? colourProvider)
|
||||
{
|
||||
if (colourProvider == null) return;
|
||||
|
||||
BackgroundColour = colourProvider.Background5;
|
||||
((IHasAccentColour)ContentContainer).AccentColour = colourProvider.Highlight1;
|
||||
}
|
||||
|
@ -35,9 +41,11 @@ private void load(OverlayColourProvider colourProvider)
|
|||
|
||||
protected class ThemedDropdownHeader : OsuDropdownHeader
|
||||
{
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OverlayColourProvider? colourProvider)
|
||||
{
|
||||
if (colourProvider == null) return;
|
||||
|
||||
BackgroundColour = colourProvider.Background5;
|
||||
BackgroundColourHover = colourProvider.Light4;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue