mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Ensure OsuScreen level leases are taken out synchronously
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using osu.Framework.Allocation;
|
||||
@ -95,15 +96,30 @@ namespace osu.Game.Screens
|
||||
|
||||
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }
|
||||
|
||||
private OsuScreenDependencies screenDependencies;
|
||||
|
||||
internal void CreateLeasedDependencies(IReadOnlyDependencyContainer dependencies) => createDependencies(dependencies);
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
var screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, parent);
|
||||
if (screenDependencies == null)
|
||||
{
|
||||
if (DisallowExternalBeatmapRulesetChanges)
|
||||
throw new InvalidOperationException($"Screens that specify {nameof(DisallowExternalBeatmapRulesetChanges)} must be pushed immediately.");
|
||||
|
||||
createDependencies(parent);
|
||||
}
|
||||
|
||||
return base.CreateChildDependencies(screenDependencies);
|
||||
}
|
||||
|
||||
private void createDependencies(IReadOnlyDependencyContainer dependencies)
|
||||
{
|
||||
screenDependencies = new OsuScreenDependencies(DisallowExternalBeatmapRulesetChanges, dependencies);
|
||||
|
||||
Beatmap = screenDependencies.Beatmap;
|
||||
Ruleset = screenDependencies.Ruleset;
|
||||
Mods = screenDependencies.Mods;
|
||||
|
||||
return base.CreateChildDependencies(screenDependencies);
|
||||
}
|
||||
|
||||
protected BackgroundScreen Background => backgroundStack?.CurrentScreen as BackgroundScreen;
|
||||
|
Reference in New Issue
Block a user