Overall cleanups

This commit is contained in:
Andrei Zavatski 2019-10-10 11:43:45 +03:00
parent 371b7841d0
commit f6b78ad661
6 changed files with 35 additions and 50 deletions

View File

@ -4,6 +4,7 @@
using osu.Framework.IO.Network;
using Humanizer;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Comments;
namespace osu.Game.Online.API.Requests
{
@ -43,11 +44,4 @@ namespace osu.Game.Online.API.Requests
Beatmapset,
NewsPost
}
public enum SortCommentsBy
{
New,
Old,
Top
}
}

View File

@ -91,7 +91,9 @@ namespace osu.Game.Overlays.Comments
{
if (c.IsTopLevel)
content.Add(new DrawableComment(c)
{ ShowDeleted = { BindTarget = ShowDeleted } });
{
ShowDeleted = { BindTarget = ShowDeleted }
});
}
int deletedComments = 0;

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
@ -62,7 +61,7 @@ namespace osu.Game.Overlays.Comments
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Current = { BindTarget = Sort }
Current = Sort
}
}
},

View File

@ -7,6 +7,7 @@ using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Bindables;
using System.Linq;
namespace osu.Game.Overlays.Comments
{
@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Comments
new SpriteText
{
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Text = $@"{count} deleted comments"
Text = $@"{count} deleted comment{(count.ToString().ToCharArray().Last() == '1' ? "" : "s")}"
}
};
}

View File

@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Comments
private readonly BindableBool childExpanded = new BindableBool(true);
private readonly Container childCommentsVisibilityContainer;
private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment;
public DrawableComment(Comment comment)
@ -47,7 +47,6 @@ namespace osu.Game.Overlays.Comments
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
@ -145,7 +144,9 @@ namespace osu.Game.Overlays.Comments
Text = HumanizerUtils.Humanize(comment.CreatedAt)
},
new RepliesButton(comment.RepliesCount)
{ Expanded = { BindTarget = childExpanded } },
{
Expanded = { BindTarget = childExpanded }
},
}
}
}
@ -153,29 +154,23 @@ namespace osu.Game.Overlays.Comments
}
}
},
childCommentsVisibilityContainer = new Container
childCommentsVisibilityContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Masking = true,
Child = new FillFlowContainer
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
childCommentsContainer = new FillFlowContainer
{
childCommentsContainer = new FillFlowContainer
{
Margin = new MarginPadding { Left = child_margin },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
},
new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
{
ShowDeleted = { BindTarget = ShowDeleted }
}
Margin = new MarginPadding { Left = child_margin },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical
},
new DeletedChildsPlaceholder(comment.GetDeletedChildsCount())
{
ShowDeleted = { BindTarget = ShowDeleted }
}
}
}
@ -234,7 +229,9 @@ namespace osu.Game.Overlays.Comments
}
comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
{ ShowDeleted = { BindTarget = ShowDeleted } }));
{
ShowDeleted = { BindTarget = ShowDeleted }
}));
}
protected override void LoadComplete()
@ -246,27 +243,13 @@ namespace osu.Game.Overlays.Comments
private void onChildExpandedChanged(ValueChangedEvent<bool> expanded)
{
if (expanded.NewValue)
childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
else
{
childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
childCommentsVisibilityContainer.ResizeHeightTo(0);
}
childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0);
}
private void onShowDeletedChanged(ValueChangedEvent<bool> show)
{
if (comment.IsDeleted)
{
if (show.NewValue)
AutoSizeAxes = Axes.Y;
else
{
AutoSizeAxes = Axes.None;
this.ResizeHeightTo(0);
}
}
this.FadeTo(show.NewValue ? 1 : 0);
}
private class ChevronButton : ShowChildsButton

View File

@ -1,7 +1,6 @@
// 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.Game.Online.API.Requests;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
@ -72,4 +71,11 @@ namespace osu.Game.Overlays.Comments
}
}
}
public enum SortCommentsBy
{
New,
Old,
Top
}
}