mirror of
https://github.com/ppy/osu
synced 2025-01-09 23:59:44 +00:00
Implement DeletedChildsPlaceholder component
This commit is contained in:
parent
b2bd78308d
commit
7e3c97f496
@ -40,6 +40,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
scrollFlow.Clear();
|
||||
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 41823));
|
||||
});
|
||||
|
||||
AddStep("Airman comments", () =>
|
||||
{
|
||||
scrollFlow.Clear();
|
||||
scrollFlow.Add(new CommentsContainer(CommentableType.Beatmapset, 24313));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Newtonsoft.Json;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
@ -91,5 +92,22 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
return IsDeleted ? @"deleted" : MessageHTML.Replace("<div class='osu-md-default'>", "").Replace("<p class=\"osu-md-default__paragraph\">", "").Replace("<br />", "").Replace("</p>", "").Replace("</div>", "").Replace(""", "\"");
|
||||
}
|
||||
|
||||
public int GetDeletedChildsCount()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (ChildComments.Any())
|
||||
ChildComments.ForEach(child =>
|
||||
{
|
||||
if (child.IsDeleted)
|
||||
count++;
|
||||
});
|
||||
|
||||
if (IsDeleted)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private const int message_padding = 40;
|
||||
private const int duration = 200;
|
||||
private const float separator_height = 1.5f;
|
||||
private const int deleted_placeholder_margin = 80;
|
||||
|
||||
public readonly BindableBool ShowDeleted = new BindableBool();
|
||||
|
||||
@ -161,12 +162,26 @@ namespace osu.Game.Overlays.Comments
|
||||
AutoSizeDuration = duration,
|
||||
AutoSizeEasing = Easing.OutQuint,
|
||||
Masking = true,
|
||||
Child = childCommentsContainer = new FillFlowContainer
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Left = child_margin },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
childCommentsContainer = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Left = child_margin },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical
|
||||
},
|
||||
new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = margin, Left = deleted_placeholder_margin },
|
||||
ShowDeleted = { BindTarget = ShowDeleted }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,7 +236,8 @@ namespace osu.Game.Overlays.Comments
|
||||
}
|
||||
}
|
||||
|
||||
comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)));
|
||||
comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
|
||||
{ ShowDeleted = { BindTarget = ShowDeleted } }));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -258,6 +274,48 @@ namespace osu.Game.Overlays.Comments
|
||||
}
|
||||
}
|
||||
|
||||
private class DeletedChildsPlaceholder : FillFlowContainer
|
||||
{
|
||||
public readonly BindableBool ShowDeleted = new BindableBool();
|
||||
|
||||
private readonly bool canBeVisible;
|
||||
|
||||
public DeletedChildsPlaceholder(int count)
|
||||
{
|
||||
canBeVisible = count != 0;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Horizontal;
|
||||
Spacing = new Vector2(3, 0);
|
||||
Alpha = 0;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.Solid.Trash,
|
||||
Size = new Vector2(14),
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
||||
Text = $@"{count} deleted comments"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void onShowDeletedChanged(ValueChangedEvent<bool> showDeleted)
|
||||
{
|
||||
if (canBeVisible)
|
||||
this.FadeTo(showDeleted.NewValue ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
private class ChevronButton : ShowChildsButton
|
||||
{
|
||||
private readonly SpriteIcon icon;
|
||||
|
Loading…
Reference in New Issue
Block a user