1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 03:03:21 +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.

105 lines
3.6 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.
2022-10-14 21:26:25 +08:00
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.Game.Graphics;
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.Resources.Localisation.Web;
2022-10-14 20:52:09 +08:00
using osuTK;
namespace osu.Game.Overlays.Comments
{
public class ReportCommentPopover : OsuPopover
{
2022-10-14 21:26:25 +08:00
private readonly Action<CommentReportReason, string> action;
private OsuEnumDropdown<CommentReportReason> reason = null!;
private OsuTextBox info = null!;
2022-10-14 20:52:09 +08:00
private ShakeContainer shaker = null!;
2022-10-14 21:26:25 +08:00
public ReportCommentPopover(Action<CommentReportReason, string> action)
2022-10-14 20:52:09 +08:00
{
2022-10-14 21:26:25 +08:00
this.action = action;
2022-10-14 20:52:09 +08:00
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Child = new FillFlowContainer
{
Direction = FillDirection.Vertical,
Width = 500,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(7),
Children = new Drawable[]
{
new OsuSpriteText
2022-10-14 20:52:09 +08:00
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Text = UsersStrings.ReportReason,
Font = OsuFont.Torus.With(size: 20),
2022-10-14 20:52:09 +08:00
},
reason = new OsuEnumDropdown<CommentReportReason>
2022-10-14 20:52:09 +08:00
{
RelativeSizeAxes = Axes.X
},
new OsuSpriteText
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Text = UsersStrings.ReportComments,
Font = OsuFont.Torus.With(size: 20),
},
info = new OsuTextBox
{
RelativeSizeAxes = Axes.X,
PlaceholderText = UsersStrings.ReportPlaceholder
2022-10-14 20:52:09 +08:00
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = shaker = new ShakeContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = new RoundedButton
{
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Width = 200,
BackgroundColour = colours.Red3,
Text = UsersStrings.ReportActionsSend,
Action = send,
Margin = new MarginPadding { Bottom = 5, Top = 10 },
2022-10-14 20:52:09 +08:00
}
}
}
}
};
}
private void send()
{
string infoValue = info.Current.Value;
var reasonValue = reason.Current.Value;
if (string.IsNullOrWhiteSpace(infoValue))
2022-10-14 20:52:09 +08:00
{
shaker.Shake();
return;
}
2022-10-14 21:26:25 +08:00
this.HidePopover();
action.Invoke(reasonValue, infoValue);
2022-10-14 20:52:09 +08:00
}
}
}