Skip to content

Commit

Permalink
Show preset description text in tooltip popup
Browse files Browse the repository at this point in the history
As proposed in #28610.
  • Loading branch information
peppy committed Jun 28, 2024
1 parent 17151e8 commit 28d5278
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 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 @@ -37,7 +41,15 @@ public ModPresetTooltip(OverlayColourProvider colourProvider)
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(7),
Spacing = new Vector2(7)
Spacing = new Vector2(7),
Children = new[]
{
descriptionText = new OsuSpriteText
{
Font = OsuFont.GetFont(weight: FontWeight.Regular),
Colour = colourProvider.Content2,
},
}
}
};
}
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 28d5278

Please sign in to comment.