1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 22:22:54 +08:00
osu-lazer/osu.Game/Overlays/Comments/CommentsPage.cs

93 lines
2.8 KiB
C#
Raw Normal View History

2020-01-29 11:22:08 +08:00
// 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.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using System.Linq;
namespace osu.Game.Overlays.Comments
{
2020-01-29 11:58:53 +08:00
public class CommentsPage : CompositeDrawable
2020-01-29 11:22:08 +08:00
{
public readonly BindableBool ShowDeleted = new BindableBool();
private readonly CommentBundle commentBundle;
public CommentsPage(CommentBundle commentBundle)
{
this.commentBundle = commentBundle;
}
[BackgroundDependencyLoader]
2020-01-29 11:58:53 +08:00
private void load(OverlayColourProvider colourProvider)
2020-01-29 11:22:08 +08:00
{
2020-01-29 11:58:53 +08:00
FillFlowContainer flow;
2020-01-29 11:22:08 +08:00
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
2020-01-29 11:58:53 +08:00
AddRangeInternal(new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5
},
flow = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
}
});
2020-01-29 11:22:08 +08:00
if (!commentBundle.Comments.Any())
{
2020-01-29 11:58:53 +08:00
flow.Add(new NoCommentsPlaceholder());
2020-01-29 11:22:08 +08:00
return;
}
foreach (var c in commentBundle.Comments)
{
if (c.IsTopLevel)
{
2020-01-29 11:58:53 +08:00
flow.Add(new DrawableComment(c)
2020-01-29 11:22:08 +08:00
{
ShowDeleted = { BindTarget = ShowDeleted }
});
}
}
}
private class NoCommentsPlaceholder : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Height = 80;
RelativeSizeAxes = Axes.X;
AddRangeInternal(new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 50 },
Text = @"No comments yet."
}
});
}
}
}
}