1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 21:17:33 +08:00
osu-lazer/osu.Game/Overlays/Comments/DeletedChildrenPlaceholder.cs

63 lines
1.9 KiB
C#
Raw Normal View History

// 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;
using Humanizer;
2019-11-25 10:30:55 +08:00
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Comments
{
2019-10-15 05:32:21 +08:00
public class DeletedChildrenPlaceholder : FillFlowContainer
{
public readonly BindableBool ShowDeleted = new BindableBool();
2019-10-13 17:38:50 +08:00
public readonly BindableInt DeletedCount = new BindableInt();
2019-10-13 17:38:50 +08:00
private readonly SpriteText countText;
2019-10-15 05:32:21 +08:00
public DeletedChildrenPlaceholder()
2019-10-13 17:38:50 +08:00
{
AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(3, 0);
2019-10-14 21:43:43 +08:00
Margin = new MarginPadding { Vertical = 10, Left = 80 };
Children = new Drawable[]
{
new SpriteIcon
{
Icon = FontAwesome.Solid.Trash,
Size = new Vector2(14),
},
2019-11-25 10:30:55 +08:00
countText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
}
};
}
protected override void LoadComplete()
{
DeletedCount.BindValueChanged(_ => updateDisplay(), true);
ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
base.LoadComplete();
}
private void updateDisplay()
2019-10-13 17:38:50 +08:00
{
if (DeletedCount.Value != 0)
{
countText.Text = @"deleted comment".ToQuantity(DeletedCount.Value);
this.FadeTo(ShowDeleted.Value ? 0 : 1);
}
else
2019-10-13 17:38:50 +08:00
{
Hide();
}
}
}
}