2022-07-22 04:34:54 +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 System.Linq;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2024-06-28 12:00:30 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-07-22 04:34:54 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2023-03-16 18:15:50 +08:00
|
|
|
public partial class ModPresetTooltip : VisibilityContainer, ITooltip<ModPreset>
|
2022-07-22 04:34:54 +08:00
|
|
|
{
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
|
|
|
|
private const double transition_duration = 200;
|
|
|
|
|
2024-06-28 12:00:30 +08:00
|
|
|
private readonly OsuSpriteText descriptionText;
|
|
|
|
|
2022-07-22 04:34:54 +08:00
|
|
|
public ModPresetTooltip(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
Width = 250;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
CornerRadius = 7;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider.Background6
|
|
|
|
},
|
|
|
|
Content = new FillFlowContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2024-06-28 12:16:47 +08:00
|
|
|
Padding = new MarginPadding { Left = 10, Right = 10, Top = 5, Bottom = 5 },
|
2024-06-28 12:00:30 +08:00
|
|
|
Spacing = new Vector2(7),
|
|
|
|
Children = new[]
|
|
|
|
{
|
|
|
|
descriptionText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular),
|
2024-06-28 12:16:47 +08:00
|
|
|
Colour = colourProvider.Content1,
|
2024-06-28 12:00:30 +08:00
|
|
|
},
|
|
|
|
}
|
2022-07-22 04:34:54 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-16 18:15:50 +08:00
|
|
|
private ModPreset? lastPreset;
|
2022-07-22 04:34:54 +08:00
|
|
|
|
2023-03-16 18:15:50 +08:00
|
|
|
public void SetContent(ModPreset preset)
|
2022-07-22 04:34:54 +08:00
|
|
|
{
|
2023-03-16 18:15:50 +08:00
|
|
|
if (ReferenceEquals(preset, lastPreset))
|
2022-07-22 04:34:54 +08:00
|
|
|
return;
|
|
|
|
|
2024-06-28 12:00:30 +08:00
|
|
|
descriptionText.Text = preset.Description;
|
|
|
|
|
2023-03-16 18:15:50 +08:00
|
|
|
lastPreset = preset;
|
2024-06-28 12:00:30 +08:00
|
|
|
|
|
|
|
Content.RemoveAll(d => d is ModPresetRow, true);
|
|
|
|
Content.AddRange(preset.Mods.AsOrdered().Select(mod => new ModPresetRow(mod)));
|
2022-07-22 04:34:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void PopIn() => this.FadeIn(transition_duration, Easing.OutQuint);
|
|
|
|
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
|
|
|
|
|
|
|
|
public void Move(Vector2 pos) => Position = pos;
|
|
|
|
}
|
|
|
|
}
|