2021-08-22 10:13:34 +08:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class ModButtonTooltip : VisibilityContainer, ITooltip<Mod>
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
|
|
|
private readonly OsuSpriteText descriptionText;
|
|
|
|
|
2021-08-28 07:38:45 +08:00
|
|
|
protected override Container<Drawable> Content { get; }
|
2021-08-22 10:13:34 +08:00
|
|
|
|
2024-06-28 12:16:47 +08:00
|
|
|
public ModButtonTooltip(OverlayColourProvider colourProvider)
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 5;
|
|
|
|
|
2021-08-28 07:38:45 +08:00
|
|
|
InternalChildren = new Drawable[]
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
2024-06-28 12:16:47 +08:00
|
|
|
new Box
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
2024-06-28 12:16:47 +08:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider.Background6,
|
2021-08-22 10:13:34 +08:00
|
|
|
},
|
2021-08-28 07:38:45 +08:00
|
|
|
Content = new FillFlowContainer
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
descriptionText = new OsuSpriteText
|
|
|
|
{
|
2024-06-28 12:16:47 +08:00
|
|
|
Colour = colourProvider.Content1,
|
2021-08-22 10:13:34 +08:00
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn() => this.FadeIn(200, Easing.OutQuint);
|
|
|
|
protected override void PopOut() => this.FadeOut(200, Easing.OutQuint);
|
|
|
|
|
2024-06-28 12:16:47 +08:00
|
|
|
private Mod? lastMod;
|
2021-08-22 10:13:34 +08:00
|
|
|
|
2021-09-01 00:36:27 +08:00
|
|
|
public void SetContent(Mod mod)
|
2021-08-22 10:13:34 +08:00
|
|
|
{
|
2021-09-01 00:36:27 +08:00
|
|
|
if (mod.Equals(lastMod))
|
|
|
|
return;
|
2021-08-22 10:13:34 +08:00
|
|
|
|
2021-08-24 09:50:09 +08:00
|
|
|
lastMod = mod;
|
2021-08-22 10:13:34 +08:00
|
|
|
|
2021-08-28 07:38:45 +08:00
|
|
|
UpdateDisplay(mod);
|
2021-08-22 10:13:34 +08:00
|
|
|
}
|
|
|
|
|
2021-08-28 07:38:45 +08:00
|
|
|
protected virtual void UpdateDisplay(Mod mod)
|
|
|
|
{
|
|
|
|
descriptionText.Text = mod.Description;
|
|
|
|
}
|
|
|
|
|
2021-08-22 10:13:34 +08:00
|
|
|
public void Move(Vector2 pos) => Position = pos;
|
|
|
|
}
|
|
|
|
}
|