mirror of
https://github.com/ppy/osu
synced 2024-12-11 01:19:26 +00:00
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 class FreeModSelectOverlay : ModSelectOverlay
|
||||||
{
|
{
|
||||||
|
public FreeModSelectOverlay(Func<Mod, bool> isValidMod = null)
|
||||||
|
: base(isValidMod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override ModSection CreateModSection(ModType type) => new FreeModSection(type);
|
protected override ModSection CreateModSection(ModType type) => new FreeModSection(type);
|
||||||
|
|
||||||
private class FreeModSection : ModSection
|
private class FreeModSection : ModSection
|
||||||
|
@ -39,6 +39,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private StatefulMultiplayerClient client { get; set; }
|
private StatefulMultiplayerClient client { get; set; }
|
||||||
|
|
||||||
|
private readonly Bindable<IReadOnlyList<Mod>> freeMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
private readonly FreeModSelectOverlay freeModSelectOverlay;
|
private readonly FreeModSelectOverlay freeModSelectOverlay;
|
||||||
private LoadingLayer loadingLayer;
|
private LoadingLayer loadingLayer;
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
||||||
|
|
||||||
freeModSelectOverlay = new FreeModSelectOverlay();
|
freeModSelectOverlay = new FreeModSelectOverlay(isValidMod) { SelectedMods = { BindTarget = freeMods } };
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -63,7 +65,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
initialRuleset = Ruleset.Value;
|
initialRuleset = Ruleset.Value;
|
||||||
initialMods = Mods.Value.ToList();
|
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);
|
FooterPanels.Add(freeModSelectOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
item.RequiredMods.AddRange(Mods.Value.Select(m => m.CreateCopy()));
|
||||||
|
|
||||||
item.AllowedMods.Clear();
|
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.
|
// 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.
|
// 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()
|
protected override IEnumerable<(FooterButton, OverlayContainer)> CreateFooterButtons()
|
||||||
{
|
{
|
||||||
var buttons = base.CreateFooterButtons().ToList();
|
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;
|
return buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user