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.
|
|
|
|
|
2023-03-11 11:31:33 +08:00
|
|
|
using System.Collections.Generic;
|
2022-07-22 04:34:54 +08:00
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Mods
|
|
|
|
{
|
2023-03-11 11:31:33 +08:00
|
|
|
public partial class ModPresetTooltip : VisibilityContainer, ITooltip<List<Mod>>
|
2022-07-22 04:34:54 +08:00
|
|
|
{
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
|
|
|
|
private const double transition_duration = 200;
|
|
|
|
|
|
|
|
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,
|
|
|
|
Padding = new MarginPadding(7),
|
|
|
|
Spacing = new Vector2(7)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-11 11:31:33 +08:00
|
|
|
private List<Mod>? lastPreset;
|
2022-07-22 04:34:54 +08:00
|
|
|
|
2023-03-11 11:31:33 +08:00
|
|
|
public void SetContent(List<Mod> mods)
|
2022-07-22 04:34:54 +08:00
|
|
|
{
|
2023-03-11 11:31:33 +08:00
|
|
|
if (ReferenceEquals(mods, lastPreset))
|
2022-07-22 04:34:54 +08:00
|
|
|
return;
|
|
|
|
|
2023-03-11 11:31:33 +08:00
|
|
|
lastPreset = mods;
|
|
|
|
Content.ChildrenEnumerable = mods.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;
|
|
|
|
}
|
|
|
|
}
|