Skip to content

Commit

Permalink
Syncrhronise colours across mod and preset tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jun 28, 2024
1 parent 28d5278 commit d370f50
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
5 changes: 4 additions & 1 deletion osu.Game/Overlays/Mods/IncompatibilityDisplayingModPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public partial class IncompatibilityDisplayingModPanel : ModPanel, IHasCustomToo
{
private readonly BindableBool incompatible = new BindableBool();

[Resolved]
private OverlayColourProvider overlayColourProvider { get; set; } = null!;

[Resolved]
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; } = null!;

Expand Down Expand Up @@ -55,7 +58,7 @@ protected override void UpdateState()

#region IHasCustomTooltip

public ITooltip<Mod> GetCustomTooltip() => new IncompatibilityDisplayingTooltip();
public ITooltip<Mod> GetCustomTooltip() => new IncompatibilityDisplayingTooltip(overlayColourProvider);

public Mod TooltipContent => Mod;

Expand Down
10 changes: 3 additions & 7 deletions osu.Game/Overlays/Mods/IncompatibilityDisplayingTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ internal partial class IncompatibilityDisplayingTooltip : ModButtonTooltip
[Resolved]
private Bindable<RulesetInfo> ruleset { get; set; } = null!;

public IncompatibilityDisplayingTooltip()
public IncompatibilityDisplayingTooltip(OverlayColourProvider colourProvider)
: base(colourProvider)
{
AddRange(new Drawable[]
{
incompatibleText = new OsuSpriteText
{
Margin = new MarginPadding { Top = 5 },
Colour = colourProvider.Content2,
Font = OsuFont.GetFont(weight: FontWeight.Regular),
Text = "Incompatible with:"
},
Expand All @@ -43,12 +45,6 @@ public IncompatibilityDisplayingTooltip()
});
}

[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
incompatibleText.Colour = colours.BlueLight;
}

protected override void UpdateDisplay(Mod mod)
{
base.UpdateDisplay(mod);
Expand Down
21 changes: 6 additions & 15 deletions osu.Game/Overlays/Mods/ModButtonTooltip.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// 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.Containers;
using osu.Framework.Graphics.Cursor;
Expand All @@ -18,21 +15,21 @@ namespace osu.Game.Overlays.Mods
public partial class ModButtonTooltip : VisibilityContainer, ITooltip<Mod>
{
private readonly OsuSpriteText descriptionText;
private readonly Box background;

protected override Container<Drawable> Content { get; }

public ModButtonTooltip()
public ModButtonTooltip(OverlayColourProvider colourProvider)
{
AutoSizeAxes = Axes.Both;
Masking = true;
CornerRadius = 5;

InternalChildren = new Drawable[]
{
background = new Box
new Box
{
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
},
Content = new FillFlowContainer
{
Expand All @@ -43,24 +40,18 @@ public ModButtonTooltip()
{
descriptionText = new OsuSpriteText
{
Colour = colourProvider.Content1,
Font = OsuFont.GetFont(weight: FontWeight.Regular),
},
}
},
};
}

[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 PopOut() => this.FadeOut(200, Easing.OutQuint);

private Mod lastMod;
private Mod? lastMod;

public void SetContent(Mod mod)
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Overlays/Mods/ModPresetTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public ModPresetTooltip(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(7),
Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
Spacing = new Vector2(7),
Children = new[]
{
descriptionText = new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Regular),
Colour = colourProvider.Content2,
Colour = colourProvider.Content1,
},
}
}
Expand Down

0 comments on commit d370f50

Please sign in to comment.