1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 08:52:54 +08:00
osu-lazer/osu.Game/Overlays/Comments/ReportCommentPopover.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

112 lines
4.1 KiB
C#
Raw Normal View History

2022-10-14 20:52:09 +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 System;
2022-10-14 20:52:09 +08:00
using osu.Framework.Allocation;
2022-10-14 21:26:25 +08:00
using osu.Framework.Extensions;
2022-10-14 20:52:09 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2022-10-14 20:52:09 +08:00
using osu.Game.Graphics;
2022-10-20 23:22:55 +08:00
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
2022-10-14 20:52:09 +08:00
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
2022-10-14 20:52:09 +08:00
using osuTK;
namespace osu.Game.Overlays.Comments
{
public class ReportCommentPopover : OsuPopover
{
public Action<CommentReportReason, string>? Action;
private readonly Comment? comment;
private OsuEnumDropdown<CommentReportReason> reasonDropdown = null!;
private OsuTextBox commentsTextBox = null!;
2022-10-20 23:12:20 +08:00
private RoundedButton submitButton = null!;
2022-10-14 20:52:09 +08:00
public ReportCommentPopover(Comment? comment)
2022-10-14 20:52:09 +08:00
{
2022-10-18 01:41:13 +08:00
this.comment = comment;
2022-10-14 20:52:09 +08:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
2022-10-20 23:22:55 +08:00
Child = new ReverseChildIDFillFlowContainer<Drawable>
2022-10-14 20:52:09 +08:00
{
Direction = FillDirection.Vertical,
Width = 500,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(7),
Children = new Drawable[]
{
2022-10-22 07:45:28 +08:00
new SpriteIcon
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Icon = FontAwesome.Solid.ExclamationTriangle,
Size = new Vector2(36),
},
2022-10-18 01:41:13 +08:00
new OsuSpriteText
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Text = ReportStrings.CommentTitle(comment?.User?.Username ?? comment?.LegacyName ?? @"Someone"),
2022-10-18 01:41:13 +08:00
Font = OsuFont.Torus.With(size: 25),
Margin = new MarginPadding { Bottom = 10 }
},
new OsuSpriteText
2022-10-14 20:52:09 +08:00
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Text = UsersStrings.ReportReason,
2022-10-14 20:52:09 +08:00
},
2022-10-20 23:22:55 +08:00
new Container
2022-10-14 20:52:09 +08:00
{
2022-10-20 23:22:55 +08:00
RelativeSizeAxes = Axes.X,
Height = 40,
Child = reasonDropdown = new OsuEnumDropdown<CommentReportReason>
2022-10-20 23:22:55 +08:00
{
RelativeSizeAxes = Axes.X
}
},
new OsuSpriteText
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Text = UsersStrings.ReportComments,
},
commentsTextBox = new OsuTextBox
{
RelativeSizeAxes = Axes.X,
2022-10-20 23:12:20 +08:00
PlaceholderText = UsersStrings.ReportPlaceholder,
2022-10-14 20:52:09 +08:00
},
2022-10-20 23:12:20 +08:00
submitButton = new RoundedButton
2022-10-14 20:52:09 +08:00
{
2022-10-20 23:12:20 +08:00
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Width = 200,
BackgroundColour = colours.Red3,
Text = UsersStrings.ReportActionsSend,
Action = () =>
{
Action?.Invoke(reasonDropdown.Current.Value, commentsTextBox.Text);
this.HidePopover();
},
2022-10-20 23:12:20 +08:00
Margin = new MarginPadding { Bottom = 5, Top = 10 },
2022-10-14 20:52:09 +08:00
}
}
};
commentsTextBox.Current.BindValueChanged(e =>
2022-10-20 23:12:20 +08:00
{
submitButton.Enabled.Value = !string.IsNullOrWhiteSpace(e.NewValue);
}, true);
2022-10-14 20:52:09 +08:00
}
}
}