mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 18:32:56 +08:00
Add DeletedChildsPlaceholder to the bottom of the comments container
This commit is contained in:
parent
c9d5bea0f1
commit
107d39c3e9
@ -21,7 +21,8 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(DrawableComment),
|
||||
typeof(HeaderButton),
|
||||
typeof(SortSelector),
|
||||
typeof(ShowChildsButton)
|
||||
typeof(ShowChildsButton),
|
||||
typeof(DeletedChildsPlaceholder)
|
||||
};
|
||||
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
@ -104,9 +104,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
count++;
|
||||
});
|
||||
|
||||
if (IsDeleted)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,19 @@ namespace osu.Game.Overlays.Comments
|
||||
content.Add(new DrawableComment(c)
|
||||
{ ShowDeleted = { BindTarget = ShowDeleted } });
|
||||
}
|
||||
|
||||
int deletedComments = 0;
|
||||
|
||||
response.Comments.ForEach(comment =>
|
||||
{
|
||||
if (comment.IsDeleted && comment.IsTopLevel)
|
||||
deletedComments++;
|
||||
});
|
||||
|
||||
content.Add(new DeletedChildsPlaceholder(deletedComments)
|
||||
{
|
||||
ShowDeleted = { BindTarget = ShowDeleted }
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
58
osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
Normal file
58
osu.Game/Overlays/Comments/DeletedChildsPlaceholder.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class DeletedChildsPlaceholder : FillFlowContainer
|
||||
{
|
||||
private const int deleted_placeholder_margin = 80;
|
||||
private const int margin = 10;
|
||||
|
||||
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);
|
||||
Margin = new MarginPadding { Vertical = margin, Left = deleted_placeholder_margin };
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ namespace osu.Game.Overlays.Comments
|
||||
private const int chevron_margin = 30;
|
||||
private const int message_padding = 40;
|
||||
private const float separator_height = 1.5f;
|
||||
private const int deleted_placeholder_margin = 80;
|
||||
|
||||
public readonly BindableBool ShowDeleted = new BindableBool();
|
||||
|
||||
@ -175,7 +174,6 @@ namespace osu.Game.Overlays.Comments
|
||||
},
|
||||
new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = margin, Left = deleted_placeholder_margin },
|
||||
ShowDeleted = { BindTarget = ShowDeleted }
|
||||
}
|
||||
}
|
||||
@ -214,6 +212,8 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = separator_height,
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -269,48 +269,6 @@ 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