2019-10-09 19:10:05 +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.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Comments
|
|
|
|
|
{
|
|
|
|
|
public class DeletedChildsPlaceholder : FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
private const int deleted_placeholder_margin = 80;
|
|
|
|
|
private const int margin = 10;
|
|
|
|
|
|
|
|
|
|
public readonly BindableBool ShowDeleted = new BindableBool();
|
2019-10-13 17:38:50 +08:00
|
|
|
|
public readonly BindableInt DeletedCount = new BindableInt();
|
2019-10-09 19:10:05 +08:00
|
|
|
|
|
2019-10-13 17:38:50 +08:00
|
|
|
|
private bool canBeShown;
|
2019-10-09 19:10:05 +08:00
|
|
|
|
|
2019-10-13 17:38:50 +08:00
|
|
|
|
private readonly SpriteText countText;
|
2019-10-09 19:10:05 +08:00
|
|
|
|
|
2019-10-13 17:38:50 +08:00
|
|
|
|
public DeletedChildsPlaceholder()
|
|
|
|
|
{
|
2019-10-09 19:10:05 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Horizontal;
|
|
|
|
|
Spacing = new Vector2(3, 0);
|
|
|
|
|
Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin };
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.Trash,
|
|
|
|
|
Size = new Vector2(14),
|
|
|
|
|
},
|
2019-10-13 17:38:50 +08:00
|
|
|
|
countText = new SpriteText
|
2019-10-09 19:10:05 +08:00
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2019-10-13 17:38:50 +08:00
|
|
|
|
DeletedCount.BindValueChanged(onCountChanged, true);
|
2019-10-09 19:10:05 +08:00
|
|
|
|
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onShowDeletedChanged(ValueChangedEvent<bool> showDeleted)
|
|
|
|
|
{
|
2019-10-13 17:38:50 +08:00
|
|
|
|
if (canBeShown)
|
2019-10-09 19:10:05 +08:00
|
|
|
|
this.FadeTo(showDeleted.NewValue ? 0 : 1);
|
|
|
|
|
}
|
2019-10-13 17:38:50 +08:00
|
|
|
|
|
|
|
|
|
private void onCountChanged(ValueChangedEvent<int> count)
|
|
|
|
|
{
|
|
|
|
|
canBeShown = count.NewValue != 0;
|
|
|
|
|
|
|
|
|
|
if (!canBeShown)
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-13 19:43:30 +08:00
|
|
|
|
string str = $@"{count.NewValue} deleted comment";
|
|
|
|
|
|
|
|
|
|
if (!(count.NewValue.ToString().EndsWith("1") && !count.NewValue.ToString().EndsWith("11")))
|
|
|
|
|
str += "s";
|
|
|
|
|
|
|
|
|
|
countText.Text = str;
|
2019-10-13 17:38:50 +08:00
|
|
|
|
Show();
|
|
|
|
|
}
|
2019-10-09 19:10:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|