1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

add dialogoverlay to tournament client, confirmation dialog for resetting bracket teams

This commit is contained in:
Dao Heng Liu 2023-07-16 22:35:20 +01:00
parent c77d3cd6bd
commit 2833497e5b
4 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,34 @@
// 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.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
{
public partial class BracketResetTeamsDialog : DangerousActionDialog
{
private readonly Container<DrawableTournamentMatch> matchesContainer;
public BracketResetTeamsDialog(Container<DrawableTournamentMatch> matchesContainer)
{
this.matchesContainer = matchesContainer;
BodyText = @"";
HeaderText = @"Confirm reset teams?";
Icon = FontAwesome.Solid.Undo;
}
[BackgroundDependencyLoader]
private void load()
{
DangerousAction = () =>
{
foreach (var p in matchesContainer)
p.Match.Reset();
};
}
}
}

View File

@ -6,6 +6,7 @@
using System;
using System.Drawing;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -13,8 +14,10 @@ using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Framework.Logging;
using osu.Game.Graphics.UserInterface;
using osu.Game.Tournament.Components;
using osu.Game.Overlays;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Ladder;
using osu.Game.Tournament.Screens.Ladder.Components;
@ -31,6 +34,10 @@ namespace osu.Game.Tournament.Screens.Editors
private WarningBox rightClickMessage;
[Resolved]
[CanBeNull]
private IDialogOverlay dialogOverlay { get; set; }
protected override bool DrawLoserPaths => true;
[BackgroundDependencyLoader]
@ -73,8 +80,7 @@ namespace osu.Game.Tournament.Screens.Editors
}),
new OsuMenuItem("Reset teams", MenuItemType.Destructive, () =>
{
foreach (var p in MatchesContainer)
p.Match.Reset();
dialogOverlay?.Push(new BracketResetTeamsDialog(MatchesContainer));
})
};
}

View File

@ -6,12 +6,14 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Caching;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Game.Overlays;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Editors;

View File

@ -11,12 +11,14 @@ using osu.Framework.Configuration;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Handlers.Mouse;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Tournament.Models;
using osuTK.Graphics;
@ -39,6 +41,13 @@ namespace osu.Game.Tournament
private Bindable<WindowMode> windowMode;
private LoadingSpinner loadingSpinner;
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private DependencyContainer dependencies;
private Container topMostOverlayContent;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig, GameHost host)
{
@ -52,6 +61,8 @@ namespace osu.Game.Tournament
Margin = new MarginPadding(40),
});
dependencies.CacheAs<IDialogOverlay>(dialogOverlay);
// in order to have the OS mouse cursor visible, relative mode needs to be disabled.
// can potentially be removed when https://github.com/ppy/osu-framework/issues/4309 is resolved.
var mouseHandler = host.AvailableInputHandlers.OfType<MouseHandler>().FirstOrDefault();
@ -90,12 +101,14 @@ namespace osu.Game.Tournament
{
RelativeSizeAxes = Axes.Both,
Child = new TournamentSceneManager()
}
},
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both }
}, drawables =>
{
loadingSpinner.Hide();
loadingSpinner.Expire();
topMostOverlayContent.Add(dialogOverlay);
AddRange(drawables);
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>