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;
|
|
|
|
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-15 03:42:55 +08:00
|
|
|
private int mentionCount;
|
|
|
|
|
2022-03-15 02:31:13 +08:00
|
|
|
public int MentionCount
|
|
|
|
{
|
|
|
|
get => mentionCount;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value == mentionCount)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mentionCount = value;
|
|
|
|
updateText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private OsuSpriteText? countText;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private OverlayColourProvider? colourProvider { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
Size = new Vector2(20, 12);
|
|
|
|
Alpha = 0f;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = colourProvider!.Colour1,
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
updateText();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateText()
|
|
|
|
{
|
2022-03-15 03:42:55 +08:00
|
|
|
countText!.Text = MentionCount > 99 ? "99+" : MentionCount.ToString();
|
2022-03-15 02:31:13 +08:00
|
|
|
|
|
|
|
if (mentionCount > 0)
|
2022-03-15 03:42:55 +08:00
|
|
|
Show();
|
2022-03-15 02:31:13 +08:00
|
|
|
else
|
2022-03-15 03:42:55 +08:00
|
|
|
Hide();
|
2022-03-15 02:31:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|