2019-10-09 14:10:05 +03: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.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Bindables;
|
2019-10-15 00:35:44 +03:00
|
|
|
|
using Humanizer;
|
2019-11-25 11:30:55 +09:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-10-09 14:10:05 +03:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Comments
|
|
|
|
|
{
|
2020-01-30 11:17:26 +09:00
|
|
|
|
public class DeletedCommentsCounter : CompositeDrawable
|
2019-10-09 14:10:05 +03:00
|
|
|
|
{
|
|
|
|
|
public readonly BindableBool ShowDeleted = new BindableBool();
|
2020-01-30 11:17:26 +09:00
|
|
|
|
|
|
|
|
|
public readonly BindableInt Count = new BindableInt();
|
2019-10-09 14:10:05 +03:00
|
|
|
|
|
2019-10-13 12:38:50 +03:00
|
|
|
|
private readonly SpriteText countText;
|
2019-10-09 14:10:05 +03:00
|
|
|
|
|
2020-01-30 11:17:26 +09:00
|
|
|
|
public DeletedCommentsCounter()
|
2019-10-13 12:38:50 +03:00
|
|
|
|
{
|
2019-10-09 14:10:05 +03:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2020-01-30 11:17:26 +09:00
|
|
|
|
InternalChild = new FillFlowContainer
|
2019-10-09 14:10:05 +03:00
|
|
|
|
{
|
2020-01-30 11:17:26 +09:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(3, 0),
|
|
|
|
|
Children = new Drawable[]
|
2019-10-09 14:10:05 +03:00
|
|
|
|
{
|
2020-01-30 11:17:26 +09:00
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
2021-03-22 19:32:17 -07:00
|
|
|
|
Icon = FontAwesome.Regular.TrashAlt,
|
2020-01-30 11:17:26 +09:00
|
|
|
|
Size = new Vector2(14),
|
|
|
|
|
},
|
|
|
|
|
countText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
|
|
|
|
}
|
2019-10-09 14:10:05 +03:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
2020-01-30 11:17:26 +09:00
|
|
|
|
|
|
|
|
|
Count.BindValueChanged(_ => updateDisplay(), true);
|
|
|
|
|
ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
|
2019-10-09 14:10:05 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 12:47:35 +03:00
|
|
|
|
private void updateDisplay()
|
2019-10-13 12:38:50 +03:00
|
|
|
|
{
|
2020-01-30 11:17:26 +09:00
|
|
|
|
if (!ShowDeleted.Value && Count.Value != 0)
|
2019-10-15 12:47:35 +03:00
|
|
|
|
{
|
2020-01-30 11:17:26 +09:00
|
|
|
|
countText.Text = @"deleted comment".ToQuantity(Count.Value);
|
|
|
|
|
Show();
|
2019-10-15 12:47:35 +03:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-10-13 12:38:50 +03:00
|
|
|
|
Hide();
|
|
|
|
|
}
|
2019-10-09 14:10:05 +03:00
|
|
|
|
}
|
|
|
|
|
}
|