diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlaySongSelect.cs b/osu.Game/Screens/OnlinePlay/OnlinePlaySongSelect.cs index d8474ef86a..659084addf 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlaySongSelect.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlaySongSelect.cs @@ -46,7 +46,6 @@ namespace osu.Game.Screens.OnlinePlay protected readonly Bindable> FreeMods = new Bindable>(Array.Empty()); - private readonly FreeModSelectOverlay freeModSelectOverlay; private readonly Room room; private WorkingBeatmap initialBeatmap; @@ -54,13 +53,16 @@ namespace osu.Game.Screens.OnlinePlay private IReadOnlyList initialMods; private bool itemSelected; + private FreeModSelectScreen freeModSelectOverlay; + private IDisposable freeModSelectOverlayRegistration; + protected OnlinePlaySongSelect(Room room) { this.room = room; Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; - freeModSelectOverlay = new FreeModSelectOverlay + freeModSelectOverlay = new FreeModSelectScreen { SelectedMods = { BindTarget = FreeMods }, IsValidMod = IsValidFreeMod, @@ -76,7 +78,7 @@ namespace osu.Game.Screens.OnlinePlay initialRuleset = Ruleset.Value; initialMods = Mods.Value.ToList(); - FooterPanels.Add(freeModSelectOverlay); + LoadComponent(freeModSelectOverlay); } protected override void LoadComplete() @@ -95,6 +97,8 @@ namespace osu.Game.Screens.OnlinePlay Mods.BindValueChanged(onModsChanged); Ruleset.BindValueChanged(onRulesetChanged); + + freeModSelectOverlayRegistration = Game?.RegisterBlockingOverlay(freeModSelectOverlay); } private void onModsChanged(ValueChangedEvent> mods) @@ -183,5 +187,12 @@ namespace osu.Game.Screens.OnlinePlay private bool checkCompatibleFreeMod(Mod mod) => Mods.Value.All(m => m.Acronym != mod.Acronym) // Mod must not be contained in the required mods. && ModUtils.CheckCompatibleSet(Mods.Value.Append(mod).ToArray()); // Mod must be compatible with all the required mods. + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + freeModSelectOverlayRegistration?.Dispose(); + } } } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 448e702b96..55d28ec8a4 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -124,7 +124,7 @@ namespace osu.Game.Screens.Select private MusicController music { get; set; } [Resolved(CanBeNull = true)] - private OsuGame game { get; set; } + protected new OsuGame Game { get; private set; } [BackgroundDependencyLoader(true)] private void load(AudioManager audio, IDialogOverlay dialog, OsuColour colours, ManageCollectionsDialog manageCollectionsDialog, DifficultyRecommender recommender) @@ -315,7 +315,7 @@ namespace osu.Game.Screens.Select { base.LoadComplete(); - modSelectOverlayRegistration = game?.RegisterBlockingOverlay(ModSelect); + modSelectOverlayRegistration = Game?.RegisterBlockingOverlay(ModSelect); } ///