Skip to content

Commit

Permalink
add confirmation dialog for Clear All button in TournamentEditorScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
ILW8 committed Jul 20, 2023
1 parent 41638ff commit e3a7b69
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// 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.Allocation;
using osu.Game.Tournament.Screens.Editors;

namespace osu.Game.Tournament.Tests.Screens
{
public partial class TestSceneRoundEditorScreen : TournamentTestScene
{
public TestSceneRoundEditorScreen()
[BackgroundDependencyLoader]
private void load()
{
Add(new RoundEditorScreen
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public partial class TestSceneSeedingEditorScreen : TournamentTestScene
[Cached]
private readonly LadderInfo ladder = new LadderInfo();

public TestSceneSeedingEditorScreen()
[BackgroundDependencyLoader]
private void load()
{
var match = CreateSampleMatch();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// 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.Allocation;
using osu.Game.Tournament.Screens.Editors;

namespace osu.Game.Tournament.Tests.Screens
{
public partial class TestSceneTeamEditorScreen : TournamentTestScene
{
public TestSceneTeamEditorScreen()
[BackgroundDependencyLoader]
private void load()
{
Add(new TeamEditorScreen
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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 System.Collections;
using osu.Framework.Graphics.Sprites;
using osu.Game.Overlays.Dialog;

namespace osu.Game.Tournament.Screens.Editors.Components
{
public partial class TournamentClearAllDialog : DangerousActionDialog

{
public TournamentClearAllDialog(IList storage)
{
HeaderText = @"Confirm clear all?";
Icon = FontAwesome.Solid.Trash;
DangerousAction = storage.Clear;
}

// // 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 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)
// {
// HeaderText = @"Confirm reset teams?";
// Icon = FontAwesome.Solid.Undo;
// DangerousAction = () =>
// {
// foreach (var p in matchesContainer)
// p.Match.Reset();
// };
// }
// }
// }

}
}
36 changes: 36 additions & 0 deletions osu.Game.Tournament/Screens/Editors/RoundEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,56 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Logging;
using osu.Framework.Testing;
using osu.Game.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Editors.Components;
using osuTK;

namespace osu.Game.Tournament.Screens.Editors
{
public partial class RoundEditorScreen : TournamentEditorScreen<RoundEditorScreen.RoundRow, TournamentRound>
{
protected override BindableList<TournamentRound> Storage => LadderInfo.Rounds;
//
// [Resolved]
// private IDialogOverlay? dialogOverlay { get; set; }
//
// [BackgroundDependencyLoader]
// private void load()
// {
// // ControlPanel.Add(new TourneyButton
// // {
// // RelativeSizeAxes = Axes.X,
// // Text = "aaaaaa",
// // Action = () =>
// // {
// // Logger.Log("asdaf", LoggingTarget.Runtime, LogLevel.Important);
// // }
// // });
// // Logger.Log($"Current action is {.Action}", LoggingTarget.Runtime, LogLevel.Important);
//
// dialogOverlay?.Push(new TournamentClearAllDialog(Storage));
//
// var clearAllButton = ControlPanel.ChildrenOfType<DangerousSettingsButton>().FirstOrDefault();
//
// if (clearAllButton != null)
// {
// clearAllButton.Action = () =>
// {
// Logger.Log("doing the thing!", LoggingTarget.Runtime, LogLevel.Important);
// Logger.Log($"currently, dialogOverlay is {dialogOverlay}", LoggingTarget.Runtime, LogLevel.Important);
// dialogOverlay?.Push(new TournamentClearAllDialog(Storage));
// };
// }
// }

public partial class RoundRow : CompositeDrawable, IModelBacked<TournamentRound>
{
Expand Down
12 changes: 11 additions & 1 deletion osu.Game.Tournament/Screens/Editors/TournamentEditorScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
Expand All @@ -15,8 +16,10 @@
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Screens.Editors.Components;
using osuTK;

namespace osu.Game.Tournament.Screens.Editors
Expand All @@ -27,6 +30,10 @@ public abstract partial class TournamentEditorScreen<TDrawable, TModel> : Tourna
{
protected abstract BindableList<TModel> Storage { get; }

[Resolved]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }

private FillFlowContainer<TDrawable> flow;

[Resolved(canBeNull: true)]
Expand Down Expand Up @@ -79,7 +86,10 @@ private void load()
{
RelativeSizeAxes = Axes.X,
Text = "Clear all",
Action = Storage.Clear
Action = () =>
{
dialogOverlay?.Push(new TournamentClearAllDialog(Storage));
}
},
}
}
Expand Down

0 comments on commit e3a7b69

Please sign in to comment.