1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

remove #nullable disable, pass action instead of container to DangerousActionDialog

This commit is contained in:
Dao Heng Liu 2023-07-20 22:33:43 +01:00
parent 68495c937d
commit fa480cc27b
5 changed files with 15 additions and 18 deletions

View File

@ -1,15 +1,12 @@
// 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.
#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,

View File

@ -1,24 +1,19 @@
// 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.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<DrawableTournamentMatch> 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;
}
}
}

View File

@ -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;
}

View File

@ -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();
}));
})
};
}

View File

@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Screens.Editors
{
protected abstract BindableList<TModel> Storage { get; }
[Resolved]
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }