Skip to content

Commit

Permalink
remove #nullable disable, pass action instead of container to Dangero…
Browse files Browse the repository at this point in the history
…usActionDialog
  • Loading branch information
ILW8 committed Jul 20, 2023
1 parent 68495c9 commit fa480cc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class TournamentClearAllDialog : DangerousActionDialog
{
public TournamentClearAllDialog(IList storage)
{
HeaderText = @"Confirm clear all?";
HeaderText = @"Clear all?";
Icon = FontAwesome.Solid.Trash;
DangerousAction = storage.Clear;
}
Expand Down
8 changes: 6 additions & 2 deletions osu.Game.Tournament/Screens/Editors/LadderEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial class LadderEditorScreen : LadderScreen, IHasContextMenu

private WarningBox rightClickMessage;

[Resolved]
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }

Expand Down Expand Up @@ -80,7 +80,11 @@ public MenuItem[] ContextMenuItems
}),
new OsuMenuItem("Reset teams", MenuItemType.Destructive, () =>
{
dialogOverlay?.Push(new LadderResetTeamsDialog(MatchesContainer));
dialogOverlay?.Push(new LadderResetTeamsDialog(() =>
{
foreach (var p in MatchesContainer)
p.Match.Reset();
}));
})
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract partial class TournamentEditorScreen<TDrawable, TModel> : Tourna
{
protected abstract BindableList<TModel> Storage { get; }

[Resolved]
[Resolved(canBeNull: true)]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }

Expand Down

0 comments on commit fa480cc

Please sign in to comment.