mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Add initial UI for selecting extra mods
This commit is contained in:
parent
e02e3cf19a
commit
4ae10b1e1c
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
@ -29,6 +30,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
[Resolved(typeof(Room), nameof(Room.Playlist))]
|
||||||
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
protected BindableList<PlaylistItem> Playlist { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Any mods applied by/to the local user.
|
||||||
|
/// </summary>
|
||||||
|
protected readonly Bindable<IReadOnlyList<Mod>> ExtraMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController music { get; set; }
|
private MusicController music { get; set; }
|
||||||
|
|
||||||
@ -55,6 +61,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
|
|
||||||
managerUpdated = beatmapManager.ItemUpdated.GetBoundCopy();
|
managerUpdated = beatmapManager.ItemUpdated.GetBoundCopy();
|
||||||
managerUpdated.BindValueChanged(beatmapUpdated);
|
managerUpdated.BindValueChanged(beatmapUpdated);
|
||||||
|
|
||||||
|
ExtraMods.BindValueChanged(_ => updateMods());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
@ -95,12 +103,17 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
{
|
{
|
||||||
updateWorkingBeatmap();
|
updateWorkingBeatmap();
|
||||||
|
|
||||||
var item = SelectedItem.Value;
|
if (SelectedItem.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
Mods.Value = item?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
// Remove any extra mods that are no longer allowed.
|
||||||
|
ExtraMods.Value = ExtraMods.Value
|
||||||
|
.Where(m => SelectedItem.Value.AllowedMods.Any(a => m.GetType() == a.GetType()))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
if (item?.Ruleset != null)
|
updateMods();
|
||||||
Ruleset.Value = item.Ruleset.Value;
|
|
||||||
|
Ruleset.Value = SelectedItem.Value.Ruleset.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet) => Schedule(updateWorkingBeatmap);
|
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet) => Schedule(updateWorkingBeatmap);
|
||||||
@ -115,6 +128,14 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateMods()
|
||||||
|
{
|
||||||
|
if (SelectedItem.Value == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Mods.Value = ExtraMods.Value.Concat(SelectedItem.Value.RequiredMods).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
private void beginHandlingTrack()
|
private void beginHandlingTrack()
|
||||||
{
|
{
|
||||||
Beatmap.BindValueChanged(applyLoopingToTrack, true);
|
Beatmap.BindValueChanged(applyLoopingToTrack, true);
|
||||||
|
@ -14,12 +14,15 @@ using osu.Framework.Screens;
|
|||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Screens.OnlinePlay.Components;
|
using osu.Game.Screens.OnlinePlay.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Match;
|
using osu.Game.Screens.OnlinePlay.Match;
|
||||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Participants;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
using ParticipantsList = osu.Game.Screens.OnlinePlay.Multiplayer.Participants.ParticipantsList;
|
using ParticipantsList = osu.Game.Screens.OnlinePlay.Multiplayer.Participants.ParticipantsList;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||||
@ -37,7 +40,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
private OngoingOperationTracker ongoingOperationTracker { get; set; }
|
||||||
|
|
||||||
|
private ModSelectOverlay extraModSelectOverlay;
|
||||||
private MultiplayerMatchSettingsOverlay settingsOverlay;
|
private MultiplayerMatchSettingsOverlay settingsOverlay;
|
||||||
|
private Drawable extraModsSection;
|
||||||
|
|
||||||
private IBindable<bool> isConnected;
|
private IBindable<bool> isConnected;
|
||||||
|
|
||||||
@ -129,10 +134,39 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding { Horizontal = 5 },
|
Padding = new MarginPadding { Horizontal = 5 },
|
||||||
Children = new Drawable[]
|
Spacing = new Vector2(0, 10),
|
||||||
|
Children = new[]
|
||||||
{
|
{
|
||||||
new OverlinedHeader("Beatmap"),
|
new FillFlowContainer
|
||||||
new BeatmapSelectionControl { RelativeSizeAxes = Axes.X }
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OverlinedHeader("Beatmap"),
|
||||||
|
new BeatmapSelectionControl { RelativeSizeAxes = Axes.X }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
extraModsSection = new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OverlinedHeader("Extra mods"),
|
||||||
|
new ModDisplay
|
||||||
|
{
|
||||||
|
DisplayUnrankedText = false,
|
||||||
|
Current = ExtraMods
|
||||||
|
},
|
||||||
|
new PurpleTriangleButton
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Text = "Select",
|
||||||
|
Action = () => extraModSelectOverlay.Show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,6 +208,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
new Dimension(GridSizeMode.AutoSize),
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
extraModSelectOverlay = new SoloModSelectOverlay
|
||||||
|
{
|
||||||
|
SelectedMods = { BindTarget = ExtraMods },
|
||||||
|
Stacked = false,
|
||||||
|
IsValidMod = _ => false
|
||||||
|
},
|
||||||
settingsOverlay = new MultiplayerMatchSettingsOverlay
|
settingsOverlay = new MultiplayerMatchSettingsOverlay
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -219,10 +259,31 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extraModSelectOverlay.State.Value == Visibility.Visible)
|
||||||
|
{
|
||||||
|
extraModSelectOverlay.Hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return base.OnBackButton();
|
return base.OnBackButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e) => SelectedItem.Value = Playlist.FirstOrDefault();
|
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
SelectedItem.Value = Playlist.FirstOrDefault();
|
||||||
|
|
||||||
|
if (SelectedItem.Value?.AllowedMods.Any() != true)
|
||||||
|
{
|
||||||
|
extraModsSection.Hide();
|
||||||
|
extraModSelectOverlay.Hide();
|
||||||
|
extraModSelectOverlay.IsValidMod = _ => false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
extraModsSection.Show();
|
||||||
|
extraModSelectOverlay.IsValidMod = m => SelectedItem.Value.AllowedMods.Any(a => a.GetType() == m.GetType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void onReadyClick()
|
private void onReadyClick()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user