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

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

View File

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

View File

@ -3,7 +3,6 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -62,7 +61,7 @@ namespace osu.Game.Overlays.Comments
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = 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 osu.Framework.Graphics.Sprites;
using osuTK; using osuTK;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using System.Linq;
namespace osu.Game.Overlays.Comments namespace osu.Game.Overlays.Comments
{ {
@ -38,7 +39,7 @@ namespace osu.Game.Overlays.Comments
new SpriteText new SpriteText
{ {
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), 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 BindableBool childExpanded = new BindableBool(true);
private readonly Container childCommentsVisibilityContainer; private readonly FillFlowContainer childCommentsVisibilityContainer;
private readonly Comment comment; private readonly Comment comment;
public DrawableComment(Comment comment) public DrawableComment(Comment comment)
@ -47,7 +47,6 @@ namespace osu.Game.Overlays.Comments
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Masking = true;
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -145,7 +144,9 @@ namespace osu.Game.Overlays.Comments
Text = HumanizerUtils.Humanize(comment.CreatedAt) Text = HumanizerUtils.Humanize(comment.CreatedAt)
}, },
new RepliesButton(comment.RepliesCount) new RepliesButton(comment.RepliesCount)
{ Expanded = { BindTarget = childExpanded } }, {
Expanded = { BindTarget = childExpanded }
},
} }
} }
} }
@ -153,12 +154,7 @@ namespace osu.Game.Overlays.Comments
} }
} }
}, },
childCommentsVisibilityContainer = new Container childCommentsVisibilityContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Masking = true,
Child = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -179,7 +175,6 @@ namespace osu.Game.Overlays.Comments
} }
} }
} }
}
}; };
if (comment.UserId == null) if (comment.UserId == null)
@ -234,7 +229,9 @@ namespace osu.Game.Overlays.Comments
} }
comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c) comment.ChildComments.ForEach(c => childCommentsContainer.Add(new DrawableComment(c)
{ ShowDeleted = { BindTarget = ShowDeleted } })); {
ShowDeleted = { BindTarget = ShowDeleted }
}));
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -246,27 +243,13 @@ namespace osu.Game.Overlays.Comments
private void onChildExpandedChanged(ValueChangedEvent<bool> expanded) private void onChildExpandedChanged(ValueChangedEvent<bool> expanded)
{ {
if (expanded.NewValue) childCommentsVisibilityContainer.FadeTo(expanded.NewValue ? 1 : 0);
childCommentsVisibilityContainer.AutoSizeAxes = Axes.Y;
else
{
childCommentsVisibilityContainer.AutoSizeAxes = Axes.None;
childCommentsVisibilityContainer.ResizeHeightTo(0);
}
} }
private void onShowDeletedChanged(ValueChangedEvent<bool> show) private void onShowDeletedChanged(ValueChangedEvent<bool> show)
{ {
if (comment.IsDeleted) if (comment.IsDeleted)
{ this.FadeTo(show.NewValue ? 1 : 0);
if (show.NewValue)
AutoSizeAxes = Axes.Y;
else
{
AutoSizeAxes = Axes.None;
this.ResizeHeightTo(0);
}
}
} }
private class ChevronButton : ShowChildsButton private class ChevronButton : ShowChildsButton

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // 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.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
@ -72,4 +71,11 @@ namespace osu.Game.Overlays.Comments
} }
} }
} }
public enum SortCommentsBy
{
New,
Old,
Top
}
} }