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
|
|
|
|
{
|
|
|
|
private OsuSpriteText? countText;
|
|
|
|
|
2022-03-15 05:26:33 +08:00
|
|
|
[Resolved]
|
|
|
|
private BindableInt mentions { get; set; } = null!;
|
|
|
|
|
2022-03-15 05:14:33 +08:00
|
|
|
[Resolved]
|
|
|
|
private OsuColour osuColour { get; set; } = null!;
|
|
|
|
|
2022-03-15 02:31:13 +08:00
|
|
|
[Resolved]
|
2022-03-15 04:14:04 +08:00
|
|
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
2022-03-15 02:31:13 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Masking = true;
|
|
|
|
Size = new Vector2(20, 12);
|
|
|
|
Alpha = 0f;
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2022-03-15 05:14:33 +08:00
|
|
|
Colour = osuColour.YellowLight,
|
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();
|
|
|
|
|
|
|
|
mentions.BindValueChanged(change =>
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|