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

Add basic UI for reporting

This commit is contained in:
ansel 2022-10-14 15:52:09 +03:00
parent 47d7d6fad9
commit c65a8a83f3
4 changed files with 109 additions and 5 deletions

View File

@ -10,6 +10,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Testing;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
@ -42,9 +43,13 @@ namespace osu.Game.Tests.Visual.Online
{
base.Content.AddRange(new Drawable[]
{
content = new OsuScrollContainer
new PopoverContainer()
{
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.Both,
Child = content = new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both
}
},
dialogOverlay
});

View File

@ -0,0 +1,14 @@
// 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.
namespace osu.Game.Overlays.Comments
{
public enum CommentReportReason
{
Insults,
Spam,
UnwantedContent,
Nonsense,
Other
}
}

View File

@ -19,6 +19,8 @@ using System;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.IEnumerableExtensions;
using System.Collections.Specialized;
using osu.Framework.Extensions;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
@ -29,7 +31,7 @@ using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Comments
{
public class DrawableComment : CompositeDrawable
public class DrawableComment : CompositeDrawable, IHasPopover
{
private const int avatar_size = 40;
@ -324,9 +326,9 @@ namespace osu.Game.Overlays.Comments
makeDeleted();
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
{
actionsContainer.AddLink("Delete", deleteComment);
}
else
actionsContainer.AddLink("Report", this.ShowPopover);
if (Comment.IsTopLevel)
{
@ -544,5 +546,10 @@ namespace osu.Game.Overlays.Comments
return parentComment.HasMessage ? parentComment.Message : parentComment.IsDeleted ? "deleted" : string.Empty;
}
}
public Popover GetPopover()
{
return new ReportCommentPopover(Comment.Id);
}
}
}

View File

@ -0,0 +1,78 @@
// 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;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Overlays.Comments
{
public class ReportCommentPopover : OsuPopover
{
public readonly long ID;
private LabelledEnumDropdown<CommentReportReason> reason = null!;
private LabelledTextBox info = null!;
private ShakeContainer shaker = null!;
public ReportCommentPopover(long id)
{
ID = id;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Child = new FillFlowContainer
{
Direction = FillDirection.Vertical,
Width = 500,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(7),
Children = new Drawable[]
{
reason = new LabelledEnumDropdown<CommentReportReason>
{
Label = "Reason"
},
info = new LabelledTextBox
{
Label = "Additional info",
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = shaker = new ShakeContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new RoundedButton
{
BackgroundColour = colours.Pink3,
Text = "Send report",
RelativeSizeAxes = Axes.X,
Action = send
}
}
}
}
};
}
private void send()
{
string infoValue = info.Current.Value;
var reasonValue = reason.Current.Value;
if (reasonValue == CommentReportReason.Other && string.IsNullOrWhiteSpace(infoValue))
{
shaker.Shake();
return;
}
}
}
}