2022-03-15 02:31:13 +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.Allocation;
|
2022-03-15 05:26:33 +08:00
|
|
|
using osu.Framework.Bindables;
|
2022-03-15 02:31:13 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osuTK;
|
2022-03-21 13:31:51 +08:00
|
|
|
using osuTK.Graphics;
|
2022-03-15 02:31:13 +08:00
|
|
|
|
2022-03-20 05:49:14 +08:00
|
|
|
namespace osu.Game.Overlays.Chat.ChannelList
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
2022-03-21 13:15:22 +08:00
|
|
|
public class ChannelListItemMentionPill : CircularContainer
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
2022-03-16 06:33:36 +08:00
|
|
|
public readonly BindableInt Mentions = new BindableInt();
|
2022-03-15 02:31:13 +08:00
|
|
|
|
2022-03-18 12:59:03 +08:00
|
|
|
private OsuSpriteText countText = null!;
|
2022-03-15 05:26:33 +08:00
|
|
|
|
2022-03-21 13:31:51 +08:00
|
|
|
private Box box = null!;
|
|
|
|
|
2022-03-15 02:31:13 +08:00
|
|
|
[BackgroundDependencyLoader]
|
2022-03-17 04:55:36 +08:00
|
|
|
private void load(OsuColour osuColour, OverlayColourProvider colourProvider)
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
Size = new Vector2(20, 12);
|
|
|
|
Alpha = 0f;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-03-21 13:31:51 +08:00
|
|
|
box = new Box
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-03-16 06:22:32 +08:00
|
|
|
Colour = osuColour.Orange1,
|
2022-03-15 02:31:13 +08:00
|
|
|
},
|
|
|
|
countText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Font = OsuFont.Torus.With(size: 11, weight: FontWeight.Bold),
|
|
|
|
Margin = new MarginPadding { Bottom = 1 },
|
|
|
|
Colour = colourProvider.Background5,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-15 05:26:33 +08:00
|
|
|
protected override void LoadComplete()
|
2022-03-15 02:31:13 +08:00
|
|
|
{
|
2022-03-15 05:26:33 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-03-16 06:33:36 +08:00
|
|
|
Mentions.BindValueChanged(change =>
|
2022-03-15 05:26:33 +08:00
|
|
|
{
|
|
|
|
int mentionCount = change.NewValue;
|
|
|
|
|
2022-03-18 12:59:03 +08:00
|
|
|
countText.Text = mentionCount > 99 ? "99+" : mentionCount.ToString();
|
2022-03-15 02:31:13 +08:00
|
|
|
|
2022-03-15 05:26:33 +08:00
|
|
|
if (mentionCount > 0)
|
2022-03-21 13:31:51 +08:00
|
|
|
{
|
|
|
|
this.FadeIn(1000, Easing.OutQuint);
|
|
|
|
box.FlashColour(Color4.White, 500, Easing.OutQuint);
|
|
|
|
}
|
2022-03-15 05:26:33 +08:00
|
|
|
else
|
2022-03-21 13:31:51 +08:00
|
|
|
this.FadeOut(100, Easing.OutQuint);
|
2022-03-15 05:26:33 +08:00
|
|
|
}, true);
|
2022-03-15 02:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|