mirror of https://github.com/ppy/osu
Add mods to footer
This commit is contained in:
parent
ff8ee379fb
commit
b79d1c7b81
|
@ -14,6 +14,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||
{
|
||||
public class FreeModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public FreeModSelectOverlay(Func<Mod, bool> isValidMod = null)
|
||||
: base(isValidMod)
|
||||
{
|
||||
}
|
||||
|
||||
protected override ModSection CreateModSection(ModType type) => new FreeModSection(type);
|
||||
|
||||
private class FreeModSection : ModSection
|
||||
|
|
|
@ -39,6 +39,8 @@ public class MultiplayerMatchSongSelect : SongSelect, IOnlinePlaySubScreen
|
|||
[Resolved]
|
||||
private StatefulMultiplayerClient client { get; set; }
|
||||
|
||||
private readonly Bindable<IReadOnlyList<Mod>> freeMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
private readonly FreeModSelectOverlay freeModSelectOverlay;
|
||||
private LoadingLayer loadingLayer;
|
||||
|
||||
|
@ -52,7 +54,7 @@ public MultiplayerMatchSongSelect()
|
|||
{
|
||||
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
||||
|
||||
freeModSelectOverlay = new FreeModSelectOverlay();
|
||||
freeModSelectOverlay = new FreeModSelectOverlay(isValidMod) { SelectedMods = { BindTarget = freeMods } };
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -63,7 +65,8 @@ private void load()
|
|||
initialRuleset = Ruleset.Value;
|
||||
initialMods = Mods.Value.ToList();
|
||||
|
||||
freeModSelectOverlay.SelectedMods.Value = playlist.FirstOrDefault()?.AllowedMods.Select(m => m.CreateCopy()).ToArray() ?? Array.Empty<Mod>();
|
||||
freeMods.Value = playlist.FirstOrDefault()?.AllowedMods.Select(m => m.CreateCopy()).ToArray() ?? Array.Empty<Mod>();
|
||||
|
||||
FooterPanels.Add(freeModSelectOverlay);
|
||||
}
|
||||
|
||||
|
@ -79,7 +82,7 @@ protected override bool OnStart()
|
|||
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 @@ public override bool OnExiting(IScreen next)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue