1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 12:42:56 +08:00

Syncrhronise colours across mod and preset tooltips

This commit is contained in:
Dean Herbert 2024-06-28 13:16:47 +09:00
parent 28d5278935
commit d370f50cc1
No known key found for this signature in database
4 changed files with 15 additions and 25 deletions

View File

@ -16,6 +16,9 @@ namespace osu.Game.Overlays.Mods
{ {
private readonly BindableBool incompatible = new BindableBool(); private readonly BindableBool incompatible = new BindableBool();
[Resolved]
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
[Resolved] [Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!; private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;
@ -55,7 +58,7 @@ namespace osu.Game.Overlays.Mods
#region IHasCustomTooltip #region IHasCustomTooltip
public ITooltip<Mod> GetCustomTooltip() => new IncompatibilityDisplayingTooltip(); public ITooltip<Mod> GetCustomTooltip() => new IncompatibilityDisplayingTooltip(overlayColourProvider);
public Mod TooltipContent => Mod; public Mod TooltipContent => Mod;

View File

@ -24,13 +24,15 @@ namespace osu.Game.Overlays.Mods
[Resolved] [Resolved]
private Bindable<RulesetInfo> ruleset { get; set; } = null!; private Bindable<RulesetInfo> ruleset { get; set; } = null!;
public IncompatibilityDisplayingTooltip() public IncompatibilityDisplayingTooltip(OverlayColourProvider colourProvider)
: base(colourProvider)
{ {
AddRange(new Drawable[] AddRange(new Drawable[]
{ {
incompatibleText = new OsuSpriteText incompatibleText = new OsuSpriteText
{ {
Margin = new MarginPadding { Top = 5 }, Margin = new MarginPadding { Top = 5 },
Colour = colourProvider.Content2,
Font = OsuFont.GetFont(weight: FontWeight.Regular), Font = OsuFont.GetFont(weight: FontWeight.Regular),
Text = "Incompatible with:" Text = "Incompatible with:"
}, },
@ -43,12 +45,6 @@ namespace osu.Game.Overlays.Mods
}); });
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
incompatibleText.Colour = colours.BlueLight;
}
protected override void UpdateDisplay(Mod mod) protected override void UpdateDisplay(Mod mod)
{ {
base.UpdateDisplay(mod); base.UpdateDisplay(mod);

View File

@ -1,9 +1,6 @@
// 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 disable
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
@ -18,11 +15,10 @@ namespace osu.Game.Overlays.Mods
public partial class ModButtonTooltip : VisibilityContainer, ITooltip<Mod> public partial class ModButtonTooltip : VisibilityContainer, ITooltip<Mod>
{ {
private readonly OsuSpriteText descriptionText; private readonly OsuSpriteText descriptionText;
private readonly Box background;
protected override Container<Drawable> Content { get; } protected override Container<Drawable> Content { get; }
public ModButtonTooltip() public ModButtonTooltip(OverlayColourProvider colourProvider)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Masking = true; Masking = true;
@ -30,9 +26,10 @@ namespace osu.Game.Overlays.Mods
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
background = new Box new Box
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
}, },
Content = new FillFlowContainer Content = new FillFlowContainer
{ {
@ -43,6 +40,7 @@ namespace osu.Game.Overlays.Mods
{ {
descriptionText = new OsuSpriteText descriptionText = new OsuSpriteText
{ {
Colour = colourProvider.Content1,
Font = OsuFont.GetFont(weight: FontWeight.Regular), Font = OsuFont.GetFont(weight: FontWeight.Regular),
}, },
} }
@ -50,17 +48,10 @@ namespace osu.Game.Overlays.Mods
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.Gray3;
descriptionText.Colour = colours.BlueLighter;
}
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint); protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint); protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
private Mod lastMod; private Mod? lastMod;
public void SetContent(Mod mod) public void SetContent(Mod mod)
{ {

View File

@ -40,14 +40,14 @@ namespace osu.Game.Overlays.Mods
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(7), Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
Spacing = new Vector2(7), Spacing = new Vector2(7),
Children = new[] Children = new[]
{ {
descriptionText = new OsuSpriteText descriptionText = new OsuSpriteText
{ {
Font = OsuFont.GetFont(weight: FontWeight.Regular), Font = OsuFont.GetFont(weight: FontWeight.Regular),
Colour = colourProvider.Content2, Colour = colourProvider.Content1,
}, },
} }
} }