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.
|
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat.ChannelControl
|
|
|
|
{
|
|
|
|
public class ControlItemMention : CircularContainer
|
|
|
|
{
|
2022-03-16 06:33:36 +08:00
|
|
|
public readonly BindableInt Mentions = new BindableInt();
|
2022-03-15 02:31:13 +08:00
|
|
|
|
2022-03-16 06:33:36 +08:00
|
|
|
private OsuSpriteText? countText;
|
2022-03-15 05:26:33 +08:00
|
|
|
|
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[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
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)
|
|
|
|
Show();
|
|
|
|
else
|
|
|
|
Hide();
|
|
|
|
}, true);
|
2022-03-15 02:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|