Merge pull request #28650 from peppy/mod-preset-tooltip-improvements

Show mod preset description text in tooltip popup
This commit is contained in:
Dan Balasescu 2024-06-28 14:07:06 +09:00 committed by GitHub
commit 1668048fb7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 26 deletions

View File

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

View File

@ -24,13 +24,15 @@ namespace osu.Game.Overlays.Mods
[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:"
},
@ -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)
{
base.UpdateDisplay(mod);

View File

@ -1,9 +1,6 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
@ -18,11 +15,10 @@ 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;
@ -30,9 +26,10 @@ namespace osu.Game.Overlays.Mods
InternalChildren = new Drawable[]
{
background = new Box
new Box
{
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
},
Content = new FillFlowContainer
{
@ -43,6 +40,7 @@ namespace osu.Game.Overlays.Mods
{
descriptionText = new OsuSpriteText
{
Colour = colourProvider.Content1,
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 PopOut() => this.FadeOut(200, Easing.OutQuint);
private Mod lastMod;
private Mod? lastMod;
public void SetContent(Mod mod)
{

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;
@ -36,8 +40,16 @@ namespace osu.Game.Overlays.Mods
{
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,
},
}
}
};
}
@ -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);