Skip to content

Commit

Permalink
Cache IDialogOverlay in a simpler way
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 25, 2023
1 parent 2c5a329 commit 0130c35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 3 additions & 4 deletions osu.Game.Tournament.Tests/TournamentTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ namespace osu.Game.Tournament.Tests
{
public abstract partial class TournamentTestScene : OsuManualInputManagerTestScene
{
protected DialogOverlay DialogOverlay = null!;
[Cached(typeof(IDialogOverlay))]
protected readonly DialogOverlay DialogOverlay = new DialogOverlay { Depth = float.MinValue };

[Cached]
protected LadderInfo Ladder { get; private set; } = new LadderInfo();
Expand Down Expand Up @@ -47,9 +48,7 @@ private void load(TournamentStorage storage)
Ruleset.BindTo(Ladder.Ruleset);
Dependencies.CacheAs(new StableInfo(storage));

Add(DialogOverlay = new DialogOverlay { Depth = -1 });

Dependencies.CacheAs<IDialogOverlay>(DialogOverlay);
Add(DialogOverlay);
}

[SetUpSteps]
Expand Down
7 changes: 1 addition & 6 deletions osu.Game.Tournament/TournamentGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ public partial class TournamentGame : TournamentGameBase

private LoadingSpinner loadingSpinner;

[Cached(typeof(IDialogOverlay))]
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
private DependencyContainer dependencies;

protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));

[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig, GameHost host)
Expand All @@ -64,8 +61,6 @@ private void load(FrameworkConfigManager frameworkConfig, GameHost host)
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();
Expand Down

0 comments on commit 0130c35

Please sign in to comment.