Do not requere dialog overlay

This commit is contained in:
ansel 2022-10-08 17:11:09 +03:00
parent 4f084664ac
commit abf56c27a1
4 changed files with 50 additions and 58 deletions

View File

@ -25,9 +25,6 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
[Cached(typeof(IDialogOverlay))]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API; private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
private CommentsContainer commentsContainer; private CommentsContainer commentsContainer;
@ -35,15 +32,10 @@ namespace osu.Game.Tests.Visual.Online
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false); Child = new BasicScrollContainer
Children = new Drawable[]
{ {
new BasicScrollContainer RelativeSizeAxes = Axes.Both,
{ Child = commentsContainer = new CommentsContainer()
RelativeSizeAxes = Axes.Both,
Child = commentsContainer = new CommentsContainer()
},
dialogOverlay
}; };
}); });

View File

@ -20,15 +20,11 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
[Cached(typeof(IDialogOverlay))]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private Container container; private Container container;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new Box
@ -41,7 +37,6 @@ namespace osu.Game.Tests.Visual.Online
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
}, },
dialogOverlay
}; };
}); });

View File

@ -24,22 +24,18 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
[Cached(typeof(IDialogOverlay))]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private TestCommentsContainer comments; private TestCommentsContainer comments;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
if (dialogOverlay.Parent != null) Remove(dialogOverlay, false);
Clear(); Clear();
Add(new BasicScrollContainer Add(new BasicScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = comments = new TestCommentsContainer() Child = comments = new TestCommentsContainer()
}); });
Add(dialogOverlay);
}); });
[Test] [Test]

View File

@ -1,8 +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.
#nullable disable
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -35,7 +33,7 @@ namespace osu.Game.Overlays.Comments
{ {
private const int avatar_size = 40; private const int avatar_size = 40;
public Action<DrawableComment, int> RepliesRequested; public Action<DrawableComment, int> RepliesRequested = null!;
public readonly Comment Comment; public readonly Comment Comment;
@ -49,21 +47,21 @@ namespace osu.Game.Overlays.Comments
private int currentPage; private int currentPage;
private FillFlowContainer childCommentsVisibilityContainer; private FillFlowContainer childCommentsVisibilityContainer = null!;
private FillFlowContainer childCommentsContainer; private FillFlowContainer childCommentsContainer = null!;
private LoadRepliesButton loadRepliesButton; private LoadRepliesButton loadRepliesButton = null!;
private ShowMoreRepliesButton showMoreButton; private ShowMoreRepliesButton showMoreButton = null!;
private ShowRepliesButton showRepliesButton; private ShowRepliesButton showRepliesButton = null!;
private ChevronButton chevronButton; private ChevronButton chevronButton = null!;
private LinkFlowContainer actionsContainer; private LinkFlowContainer actionsContainer = null!;
private LoadingSpinner actionsLoading; private LoadingSpinner actionsLoading = null!;
private DeletedCommentsCounter deletedCommentsCounter; private DeletedCommentsCounter deletedCommentsCounter = null!;
[Resolved(canBeNull: true)]
private IDialogOverlay? dialogOverlay { get; set; }
[Resolved] [Resolved]
private IDialogOverlay dialogOverlay { get; set; } private IAPIProvider api { get; set; } = null!;
[Resolved]
private IAPIProvider api { get; set; }
public DrawableComment(Comment comment) public DrawableComment(Comment comment)
{ {
@ -278,7 +276,7 @@ namespace osu.Game.Overlays.Comments
if (Comment.UserId.HasValue) if (Comment.UserId.HasValue)
username.AddUserLink(Comment.User); username.AddUserLink(Comment.User);
else else
username.AddText(Comment.LegacyName); username.AddText(Comment.LegacyName!);
if (Comment.EditedAt.HasValue && Comment.EditedUser != null) if (Comment.EditedAt.HasValue && Comment.EditedUser != null)
{ {
@ -354,28 +352,39 @@ namespace osu.Game.Overlays.Comments
}; };
} }
/**
* Invokes comment deletion with confirmation.
*/
private void deleteComment() private void deleteComment()
{ {
dialogOverlay.Push(new ConfirmDialog("Do you really want to delete your comment?", () => if (dialogOverlay == null)
deleteCommentRequest();
else
dialogOverlay.Push(new ConfirmDialog("Do you really want to delete your comment?", deleteCommentRequest));
}
/**
* Invokes comment deletion directly.
*/
private void deleteCommentRequest()
{
actionsContainer.Hide();
actionsLoading.Show();
var request = new CommentDeleteRequest(Comment.Id);
request.Success += _ =>
{ {
actionsContainer.Hide(); actionsLoading.Hide();
actionsLoading.Show(); AutoSizeAxes = Axes.None;
var request = new CommentDeleteRequest(Comment.Id); Masking = true;
request.Success += _ => this.ResizeHeightTo(0, 1000, Easing.Out);
{ this.FadeOut(1000, Easing.Out).Expire();
actionsLoading.Hide(); };
AutoSizeAxes = Axes.None; request.Failure += _ =>
Masking = true; {
this.ResizeHeightTo(0, 1000, Easing.Out); actionsLoading.Hide();
this.FadeOut(1000, Easing.Out).Expire(); actionsContainer.Show();
}; };
request.Failure += _ => api.Queue(request);
{
actionsLoading.Hide();
actionsContainer.Show();
};
api.Queue(request);
}));
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -486,7 +495,7 @@ namespace osu.Game.Overlays.Comments
{ {
public LocalisableString TooltipText => getParentMessage(); public LocalisableString TooltipText => getParentMessage();
private readonly Comment parentComment; private readonly Comment? parentComment;
public ParentUsername(Comment comment) public ParentUsername(Comment comment)
{ {
@ -506,7 +515,7 @@ namespace osu.Game.Overlays.Comments
new OsuSpriteText new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Text = parentComment?.User?.Username ?? parentComment?.LegacyName Text = parentComment?.User?.Username ?? parentComment?.LegacyName!
} }
}; };
} }