Show preset description text in tooltip popup

As proposed in https://github.com/ppy/osu/discussions/28610.
This commit is contained in:
Dean Herbert 2024-06-28 13:00:30 +09:00
parent 17151e81ee
commit 28d5278935
No known key found for this signature in database

View File

@ -6,6 +6,8 @@ using osu.Framework.Graphics;
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;
@ -17,6 +19,8 @@ namespace osu.Game.Overlays.Mods
private const double transition_duration = 200;
private readonly OsuSpriteText descriptionText;
public ModPresetTooltip(OverlayColourProvider colourProvider)
{
Width = 250;
@ -37,7 +41,15 @@ namespace osu.Game.Overlays.Mods
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,
},
}
}
};
}
@ -49,8 +61,12 @@ namespace osu.Game.Overlays.Mods
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);