From b79d1c7b81ef900087608be126f96b6e49e6bdf0 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 27 Jan 2021 22:33:03 +0900 Subject: [PATCH] Add mods to footer --- .../OnlinePlay/Multiplayer/FreeModSelectOverlay.cs | 5 +++++ .../Multiplayer/MultiplayerMatchSongSelect.cs | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/FreeModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/FreeModSelectOverlay.cs index 56e74a8460..10b68ec5a6 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/FreeModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/FreeModSelectOverlay.cs @@ -14,6 +14,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { public class FreeModSelectOverlay : ModSelectOverlay { + public FreeModSelectOverlay(Func isValidMod = null) + : base(isValidMod) + { + } + protected override ModSection CreateModSection(ModType type) => new FreeModSection(type); private class FreeModSection : ModSection diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs index 70d3d128dd..86b8f22d34 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs @@ -39,6 +39,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer [Resolved] private StatefulMultiplayerClient client { get; set; } + private readonly Bindable> freeMods = new Bindable>(Array.Empty()); + private readonly FreeModSelectOverlay freeModSelectOverlay; private LoadingLayer loadingLayer; @@ -52,7 +54,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; - freeModSelectOverlay = new FreeModSelectOverlay(); + freeModSelectOverlay = new FreeModSelectOverlay(isValidMod) { SelectedMods = { BindTarget = freeMods } }; } [BackgroundDependencyLoader] @@ -63,7 +65,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer initialRuleset = Ruleset.Value; initialMods = Mods.Value.ToList(); - freeModSelectOverlay.SelectedMods.Value = playlist.FirstOrDefault()?.AllowedMods.Select(m => m.CreateCopy()).ToArray() ?? Array.Empty(); + freeMods.Value = playlist.FirstOrDefault()?.AllowedMods.Select(m => m.CreateCopy()).ToArray() ?? Array.Empty(); + FooterPanels.Add(freeModSelectOverlay); } @@ -79,7 +82,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy())); item.AllowedMods.Clear(); - item.AllowedMods.AddRange(freeModSelectOverlay.SelectedMods.Value.Select(m => m.CreateCopy())); + item.AllowedMods.AddRange(freeMods.Value.Select(m => m.CreateCopy())); // If the client is already in a room, update via the client. // Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation. @@ -132,7 +135,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer protected override IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons() { var buttons = base.CreateFooterButtons().ToList(); - buttons.Insert(buttons.FindIndex(b => b.Item1 is FooterButtonMods) + 1, (new FooterButtonFreeMods(), freeModSelectOverlay)); + buttons.Insert(buttons.FindIndex(b => b.Item1 is FooterButtonMods) + 1, (new FooterButtonFreeMods { Current = freeMods }, freeModSelectOverlay)); return buttons; }