Skip to content

Commit

Permalink
Merge pull request #28650 from peppy/mod-preset-tooltip-improvements
Browse files Browse the repository at this point in the history
Show mod preset description text in tooltip popup
  • Loading branch information
smoogipoo authored Jun 28, 2024
2 parents 17151e8 + d370f50 commit 1668048
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 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
22 changes: 19 additions & 3 deletions osu.Game/Overlays/Mods/ModPresetTooltip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods;
using osuTK;

Expand All @@ -17,6 +19,8 @@ public partial class ModPresetTooltip : VisibilityContainer, ITooltip<ModPreset>

private const double transition_duration = 200;

private readonly OsuSpriteText descriptionText;

public ModPresetTooltip(OverlayColourProvider colourProvider)
{
Width = 250;
Expand All @@ -36,8 +40,16 @@ public ModPresetTooltip(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(7),
Spacing = new Vector2(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.Content1,
},
}
}
};
}
Expand All @@ -49,8 +61,12 @@ public void SetContent(ModPreset preset)
if (ReferenceEquals(preset, lastPreset))
return;

descriptionText.Text = preset.Description;

lastPreset = preset;
Content.ChildrenEnumerable = preset.Mods.AsOrdered().Select(mod => new ModPresetRow(mod));

Content.RemoveAll(d => d is ModPresetRow, true);
Content.AddRange(preset.Mods.AsOrdered().Select(mod => new ModPresetRow(mod)));
}

protected override void PopIn() => this.FadeIn(transition_duration, Easing.OutQuint);
Expand Down

0 comments on commit 1668048

Please sign in to comment.