1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:02:55 +08:00
This commit is contained in:
Andrei Zavatski 2019-10-14 16:43:43 +03:00
parent 7ac87494e0
commit 7cd3f5656d
6 changed files with 18 additions and 28 deletions

View File

@ -20,7 +20,7 @@ namespace osu.Game.Tests.Visual.Online
typeof(CommentsHeader), typeof(CommentsHeader),
typeof(DrawableComment), typeof(DrawableComment),
typeof(HeaderButton), typeof(HeaderButton),
typeof(SortSelector), typeof(SortTabControl),
typeof(ShowChildsButton), typeof(ShowChildsButton),
typeof(DeletedChildsPlaceholder) typeof(DeletedChildsPlaceholder)
}; };

View File

@ -6,6 +6,7 @@ using osu.Game.Users;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions;
namespace osu.Game.Online.API.Requests.Responses namespace osu.Game.Online.API.Requests.Responses
{ {
@ -90,7 +91,10 @@ namespace osu.Game.Online.API.Requests.Responses
public string GetMessage() public string GetMessage()
{ {
return IsDeleted ? @"deleted" : MessageHTML.Replace("<div class='osu-md-default'>", "").Replace("<p class=\"osu-md-default__paragraph\">", "").Replace("<br />", "").Replace("</p>", "").Replace("</div>", "").Replace("&quot;", "\""); if (IsDeleted)
return @"deleted";
return Regex.Replace(MessageHTML, @"\<.*?\>", "");
} }
public int GetDeletedChildsCount() public int GetDeletedChildsCount()

View File

@ -16,8 +16,6 @@ namespace osu.Game.Overlays.Comments
{ {
public class CommentsContainer : CompositeDrawable public class CommentsContainer : CompositeDrawable
{ {
private const int more_button_margin = 5;
private readonly CommentableType type; private readonly CommentableType type;
private readonly long id; private readonly long id;
@ -101,7 +99,7 @@ namespace osu.Game.Overlays.Comments
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Margin = new MarginPadding(more_button_margin), Margin = new MarginPadding(5),
Action = () => getComments(false), Action = () => getComments(false),
} }
} }

View File

@ -12,9 +12,6 @@ namespace osu.Game.Overlays.Comments
{ {
public class DeletedChildsPlaceholder : FillFlowContainer public class DeletedChildsPlaceholder : FillFlowContainer
{ {
private const int deleted_placeholder_margin = 80;
private const int margin = 10;
public readonly BindableBool ShowDeleted = new BindableBool(); public readonly BindableBool ShowDeleted = new BindableBool();
public readonly BindableInt DeletedCount = new BindableInt(); public readonly BindableInt DeletedCount = new BindableInt();
@ -27,7 +24,7 @@ namespace osu.Game.Overlays.Comments
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal; Direction = FillDirection.Horizontal;
Spacing = new Vector2(3, 0); Spacing = new Vector2(3, 0);
Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin }; Margin = new MarginPadding { Vertical = 10, Left = 80 };
Children = new Drawable[] Children = new Drawable[]
{ {
new SpriteIcon new SpriteIcon

View File

@ -21,18 +21,14 @@ namespace osu.Game.Overlays.Comments
{ {
private const int avatar_size = 40; private const int avatar_size = 40;
private const int margin = 10; private const int margin = 10;
private const int child_margin = 20;
private const int chevron_margin = 30;
private const int message_padding = 40;
private const float separator_height = 1.5f;
public readonly BindableBool ShowDeleted = new BindableBool(); public readonly BindableBool ShowDeleted = new BindableBool();
private readonly BindableBool childExpanded = new BindableBool(true); private readonly BindableBool childExpanded = new BindableBool(true);
private readonly FillFlowContainer childCommentsVisibilityContainer; private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
private readonly DeletedChildsPlaceholder deletedChildsPlaceholder; private readonly DeletedChildsPlaceholder deletedChildsPlaceholder;
private readonly Comment comment;
public DrawableComment(Comment comment) public DrawableComment(Comment comment)
{ {
@ -127,7 +123,7 @@ namespace osu.Game.Overlays.Comments
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Right = message_padding } Padding = new MarginPadding { Right = 40 }
}, },
info = new FillFlowContainer info = new FillFlowContainer
{ {
@ -164,7 +160,7 @@ namespace osu.Game.Overlays.Comments
{ {
childCommentsContainer = new FillFlowContainer childCommentsContainer = new FillFlowContainer
{ {
Margin = new MarginPadding { Left = child_margin }, Margin = new MarginPadding { Left = 20 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical Direction = FillDirection.Vertical
@ -180,10 +176,10 @@ namespace osu.Game.Overlays.Comments
deletedChildsPlaceholder.DeletedCount.Value = comment.GetDeletedChildsCount(); deletedChildsPlaceholder.DeletedCount.Value = comment.GetDeletedChildsCount();
if (comment.UserId == null) if (comment.UserId.HasValue)
username.AddText(comment.LegacyName);
else
username.AddUserLink(comment.User); username.AddUserLink(comment.User);
else
username.AddText(comment.LegacyName);
if (comment.EditedAt.HasValue) if (comment.EditedAt.HasValue)
{ {
@ -209,7 +205,7 @@ namespace osu.Game.Overlays.Comments
AddInternal(new Container AddInternal(new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = separator_height, Height = 1.5f,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Child = new Box Child = new Box
@ -225,7 +221,7 @@ namespace osu.Game.Overlays.Comments
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Margin = new MarginPadding { Right = chevron_margin, Top = margin }, Margin = new MarginPadding { Right = 30, Top = margin },
Expanded = { BindTarget = childExpanded } Expanded = { BindTarget = childExpanded }
}); });
} }
@ -240,15 +236,10 @@ namespace osu.Game.Overlays.Comments
protected override void LoadComplete() protected override void LoadComplete()
{ {
ShowDeleted.BindValueChanged(onShowDeletedChanged, true); ShowDeleted.BindValueChanged(onShowDeletedChanged, true);
childExpanded.BindValueChanged(onChildExpandedChanged, true); childExpanded.BindValueChanged(expanded => childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0), true);
base.LoadComplete(); base.LoadComplete();
} }
private void onChildExpandedChanged(ValueChangedEvent<bool> expanded)
{
childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0);
}
private void onShowDeletedChanged(ValueChangedEvent<bool> show) private void onShowDeletedChanged(ValueChangedEvent<bool> show)
{ {
if (comment.IsDeleted) if (comment.IsDeleted)

View File

@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Comments
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
Expanded.Value = !Expanded.Value; Expanded.Value = !Expanded.Value;
return base.OnClick(e); return true;
} }
} }
} }