1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 09:37:23 +08:00

Merge pull request #7671 from peppy/rename-deleted-count

Rename and tidy up DeletedCommentsCounter
This commit is contained in:
Dan Balasescu 2020-01-30 14:20:38 +09:00 committed by GitHub
commit 33d964994c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 28 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(HeaderButton), typeof(HeaderButton),
typeof(SortTabControl), typeof(SortTabControl),
typeof(ShowChildrenButton), typeof(ShowChildrenButton),
typeof(DeletedChildrenPlaceholder), typeof(DeletedCommentsCounter),
typeof(VotePill) typeof(VotePill)
}; };

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Comments
private int currentPage; private int currentPage;
private FillFlowContainer content; private FillFlowContainer content;
private DeletedChildrenPlaceholder deletedChildrenPlaceholder; private DeletedCommentsCounter deletedCommentsCounter;
private CommentsShowMoreButton moreButton; private CommentsShowMoreButton moreButton;
private TotalCommentsCounter commentCounter; private TotalCommentsCounter commentCounter;
@ -84,7 +84,7 @@ namespace osu.Game.Overlays.Comments
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
deletedChildrenPlaceholder = new DeletedChildrenPlaceholder deletedCommentsCounter = new DeletedCommentsCounter
{ {
ShowDeleted = { BindTarget = ShowDeleted } ShowDeleted = { BindTarget = ShowDeleted }
}, },
@ -153,7 +153,7 @@ namespace osu.Game.Overlays.Comments
private void clearComments() private void clearComments()
{ {
currentPage = 1; currentPage = 1;
deletedChildrenPlaceholder.DeletedCount.Value = 0; deletedCommentsCounter.Count.Value = 0;
moreButton.IsLoading = true; moreButton.IsLoading = true;
content.Clear(); content.Clear();
} }
@ -184,7 +184,7 @@ namespace osu.Game.Overlays.Comments
{ {
content.Add(loaded); content.Add(loaded);
deletedChildrenPlaceholder.DeletedCount.Value += response.Comments.Count(c => c.IsDeleted && c.IsTopLevel); deletedCommentsCounter.Count.Value += response.Comments.Count(c => c.IsDeleted && c.IsTopLevel);
if (response.HasMore) if (response.HasMore)
{ {

View File

@ -12,51 +12,56 @@ using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Comments namespace osu.Game.Overlays.Comments
{ {
public class DeletedChildrenPlaceholder : FillFlowContainer public class DeletedCommentsCounter : CompositeDrawable
{ {
public readonly BindableBool ShowDeleted = new BindableBool(); public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt();
public readonly BindableInt Count = new BindableInt();
private readonly SpriteText countText; private readonly SpriteText countText;
public DeletedChildrenPlaceholder() public DeletedCommentsCounter()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal;
Spacing = new Vector2(3, 0);
Margin = new MarginPadding { Vertical = 10, Left = 80 }; Margin = new MarginPadding { Vertical = 10, Left = 80 };
Children = new Drawable[]
InternalChild = new FillFlowContainer
{ {
new SpriteIcon AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(3, 0),
Children = new Drawable[]
{ {
Icon = FontAwesome.Solid.Trash, new SpriteIcon
Size = new Vector2(14), {
}, Icon = FontAwesome.Solid.Trash,
countText = new OsuSpriteText Size = new Vector2(14),
{ },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), countText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
}
} }
}; };
} }
protected override void LoadComplete() protected override void LoadComplete()
{ {
DeletedCount.BindValueChanged(_ => updateDisplay(), true);
ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
base.LoadComplete(); base.LoadComplete();
Count.BindValueChanged(_ => updateDisplay(), true);
ShowDeleted.BindValueChanged(_ => updateDisplay(), true);
} }
private void updateDisplay() private void updateDisplay()
{ {
if (DeletedCount.Value != 0) if (!ShowDeleted.Value && Count.Value != 0)
{ {
countText.Text = @"deleted comment".ToQuantity(DeletedCount.Value); countText.Text = @"deleted comment".ToQuantity(Count.Value);
this.FadeTo(ShowDeleted.Value ? 0 : 1); Show();
} }
else else
{
Hide(); Hide();
}
} }
} }
} }

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Comments
{ {
LinkFlowContainer username; LinkFlowContainer username;
FillFlowContainer childCommentsContainer; FillFlowContainer childCommentsContainer;
DeletedChildrenPlaceholder deletedChildrenPlaceholder; DeletedCommentsCounter deletedCommentsCounter;
FillFlowContainer info; FillFlowContainer info;
LinkFlowContainer message; LinkFlowContainer message;
GridContainer content; GridContainer content;
@ -184,7 +184,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical Direction = FillDirection.Vertical
}, },
deletedChildrenPlaceholder = new DeletedChildrenPlaceholder deletedCommentsCounter = new DeletedCommentsCounter
{ {
ShowDeleted = { BindTarget = ShowDeleted } ShowDeleted = { BindTarget = ShowDeleted }
} }
@ -193,7 +193,7 @@ namespace osu.Game.Overlays.Comments
} }
}; };
deletedChildrenPlaceholder.DeletedCount.Value = comment.DeletedChildrenCount; deletedCommentsCounter.Count.Value = comment.DeletedChildrenCount;
if (comment.UserId.HasValue) if (comment.UserId.HasValue)
username.AddUserLink(comment.User); username.AddUserLink(comment.User);