1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 08:22:56 +08:00

Integrate editor into comment

This commit is contained in:
ansel 2023-01-18 20:50:07 +03:00
parent 0d91277ea5
commit 77bc4fbf70

View File

@ -75,6 +75,7 @@ namespace osu.Game.Overlays.Comments
private OsuSpriteText deletedLabel = null!; private OsuSpriteText deletedLabel = null!;
private GridContainer content = null!; private GridContainer content = null!;
private VotePill votePill = null!; private VotePill votePill = null!;
private Container<CommentEditor> replyEditorContainer = null!;
[Resolved] [Resolved]
private IDialogOverlay? dialogOverlay { get; set; } private IDialogOverlay? dialogOverlay { get; set; }
@ -233,6 +234,12 @@ namespace osu.Game.Overlays.Comments
} }
} }
}, },
replyEditorContainer = new Container<CommentEditor>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Padding = new MarginPadding { Top = 10 },
},
new Container new Container
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
@ -255,6 +262,7 @@ namespace osu.Game.Overlays.Comments
}, },
childCommentsVisibilityContainer = new FillFlowContainer childCommentsVisibilityContainer = new FillFlowContainer
{ {
Name = @"Children comments",
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
@ -345,6 +353,8 @@ namespace osu.Game.Overlays.Comments
actionsContainer.AddLink(CommonStrings.ButtonsPermalink, copyUrl); actionsContainer.AddLink(CommonStrings.ButtonsPermalink, copyUrl);
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10)); actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
actionsContainer.AddLink(CommonStrings.ButtonsReply.ToLower(), toggleReply);
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id) if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
actionsContainer.AddLink(CommonStrings.ButtonsDelete.ToLower(), deleteComment); actionsContainer.AddLink(CommonStrings.ButtonsDelete.ToLower(), deleteComment);
@ -435,6 +445,26 @@ namespace osu.Game.Overlays.Comments
onScreenDisplay?.Display(new CopyUrlToast()); onScreenDisplay?.Display(new CopyUrlToast());
} }
private void toggleReply()
{
if (replyEditorContainer.Count == 0)
{
replyEditorContainer.Add(new ReplyCommentEditor(Comment)
{
OnPost = comments =>
{
Comment.RepliesCount += comments.Length;
showRepliesButton.Count = Comment.RepliesCount;
Replies.AddRange(comments);
}
});
}
else
{
replyEditorContainer.Clear(true);
}
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
ShowDeleted.BindValueChanged(show => ShowDeleted.BindValueChanged(show =>