From fa480cc27bbcdf67a5ce4da55c4bd45bc63ed20d Mon Sep 17 00:00:00 2001 From: Dao Heng Liu Date: Thu, 20 Jul 2023 22:33:43 +0100 Subject: [PATCH] remove #nullable disable, pass action instead of container to DangerousActionDialog --- .../Screens/TestSceneLadderEditorScreen.cs | 8 +++----- .../Editors/Components/LadderResetTeamsDialog.cs | 13 ++++--------- .../Editors/Components/TournamentClearAllDialog.cs | 2 +- .../Screens/Editors/LadderEditorScreen.cs | 8 ++++++-- .../Screens/Editors/TournamentEditorScreen.cs | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs index bbf4da803e..c383e93e7f 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneLadderEditorScreen.cs @@ -1,15 +1,12 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using Newtonsoft.Json; using NUnit.Framework; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Logging; using osu.Game.Graphics.Cursor; using osu.Game.Tournament.Screens.Editors; using osu.Framework.Testing; @@ -23,12 +20,13 @@ namespace osu.Game.Tournament.Tests.Screens { public partial class TestSceneLadderEditorScreen : TournamentTestScene { - private LadderEditorScreen ladderEditorScreen; - private OsuContextMenuContainer osuContextMenuContainer; + private LadderEditorScreen ladderEditorScreen = null!; + private OsuContextMenuContainer? osuContextMenuContainer; [SetUp] public void Setup() => Schedule(() => { + ladderEditorScreen = new LadderEditorScreen(); Add(osuContextMenuContainer = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both, diff --git a/osu.Game.Tournament/Screens/Editors/Components/LadderResetTeamsDialog.cs b/osu.Game.Tournament/Screens/Editors/Components/LadderResetTeamsDialog.cs index 5fd5ae365e..8ed1b381f6 100644 --- a/osu.Game.Tournament/Screens/Editors/Components/LadderResetTeamsDialog.cs +++ b/osu.Game.Tournament/Screens/Editors/Components/LadderResetTeamsDialog.cs @@ -1,24 +1,19 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics.Containers; +using System; using osu.Framework.Graphics.Sprites; using osu.Game.Overlays.Dialog; -using osu.Game.Tournament.Screens.Ladder.Components; namespace osu.Game.Tournament.Screens.Editors.Components { public partial class LadderResetTeamsDialog : DangerousActionDialog { - public LadderResetTeamsDialog(Container matchesContainer) + public LadderResetTeamsDialog(Action action) { - HeaderText = @"Confirm reset teams?"; + HeaderText = @"Reset teams?"; Icon = FontAwesome.Solid.Undo; - DangerousAction = () => - { - foreach (var p in matchesContainer) - p.Match.Reset(); - }; + DangerousAction = action; } } } diff --git a/osu.Game.Tournament/Screens/Editors/Components/TournamentClearAllDialog.cs b/osu.Game.Tournament/Screens/Editors/Components/TournamentClearAllDialog.cs index 036a81dc62..050549fe76 100644 --- a/osu.Game.Tournament/Screens/Editors/Components/TournamentClearAllDialog.cs +++ b/osu.Game.Tournament/Screens/Editors/Components/TournamentClearAllDialog.cs @@ -11,7 +11,7 @@ namespace osu.Game.Tournament.Screens.Editors.Components { public TournamentClearAllDialog(IList storage) { - HeaderText = @"Confirm clear all?"; + HeaderText = @"Clear all?"; Icon = FontAwesome.Solid.Trash; DangerousAction = storage.Clear; } diff --git a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs index 86805b767f..32685ace36 100644 --- a/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs @@ -34,7 +34,7 @@ namespace osu.Game.Tournament.Screens.Editors private WarningBox rightClickMessage; - [Resolved] + [Resolved(canBeNull: true)] [CanBeNull] private IDialogOverlay dialogOverlay { get; set; } @@ -80,7 +80,11 @@ namespace osu.Game.Tournament.Screens.Editors }), new OsuMenuItem("Reset teams", MenuItemType.Destructive, () => { - dialogOverlay?.Push(new LadderResetTeamsDialog(MatchesContainer)); + dialogOverlay?.Push(new LadderResetTeamsDialog(() => + { + foreach (var p in MatchesContainer) + p.Match.Reset(); + })); }) }; } diff --git a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs index a6b2a9b1ab..cd6127f1ce 100644 --- a/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs +++ b/osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs @@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Screens.Editors { protected abstract BindableList Storage { get; } - [Resolved] + [Resolved(canBeNull: true)] [CanBeNull] private IDialogOverlay dialogOverlay { get; set; }