diff --git a/osu.Game/Screens/Multi/Match/MatchScreen.cs b/osu.Game/Screens/Multi/Match/MatchScreen.cs index ca3f1eeb54..1d713dd0b1 100644 --- a/osu.Game/Screens/Multi/Match/MatchScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchScreen.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Online.API; using osu.Game.Online.Multiplayer; -using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi.Match.Components; using osu.Game.Screens.Multi.Play; using osu.Game.Screens.Play; @@ -40,9 +39,6 @@ namespace osu.Game.Screens.Multi.Match private readonly Components.Header header; private readonly Info info; - [Cached] - private readonly Bindable> mods = new Bindable>(Enumerable.Empty()); - [Cached] private readonly Room room; @@ -96,7 +92,7 @@ namespace osu.Game.Screens.Multi.Match }, }; - header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect()); + header.OnRequestSelectBeatmap = () => Push(new MatchSongSelect { Selected = addPlaylistItem }); header.Tabs.Current.ValueChanged += t => { @@ -110,38 +106,27 @@ namespace osu.Game.Screens.Multi.Match info.Status.BindTo(statusBind); info.Availability.BindTo(availabilityBind); info.Type.BindTo(typeBind); - info.Mods.BindTo(mods); participants.Users.BindTo(participantsBind); participants.MaxParticipants.BindTo(maxParticipantsBind); - playlistBind.ItemsAdded += _ => updatePlaylist(); - playlistBind.ItemsRemoved += _ => updatePlaylist(); + playlistBind.ItemsAdded += _ => setFromPlaylist(); + playlistBind.ItemsRemoved += _ => setFromPlaylist(); } [BackgroundDependencyLoader] private void load() { - Beatmap.BindValueChanged(b => - { - playlistBind.Clear(); - - var newItem = new PlaylistItem - { - Beatmap = b.BeatmapInfo, - Ruleset = Ruleset.Value - }; - - newItem.RequiredMods.Clear(); - newItem.RequiredMods.AddRange(b.Mods.Value); - - playlistBind.Add(newItem); - }); - playlistBind.BindTo(room.Playlist); } - private void updatePlaylist() + private void addPlaylistItem(PlaylistItem item) + { + playlistBind.Clear(); + playlistBind.Add(item); + } + + private void setFromPlaylist() { if (playlistBind.Count == 0) return; @@ -151,12 +136,9 @@ namespace osu.Game.Screens.Multi.Match header.Beatmap.Value = item.Beatmap; info.Beatmap.Value = item.Beatmap; + info.Mods.Value = item.RequiredMods; - if (Beatmap.Value?.BeatmapInfo != item.Beatmap) - { - Beatmap.Value = beatmapManager.GetWorkingBeatmap(item.Beatmap); - Beatmap.Value.Mods.Value = item.RequiredMods.ToArray(); - } + Beatmap.Value = beatmapManager.GetWorkingBeatmap(item.Beatmap); } private void onStart() diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index 94ac951159..10f29d929d 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -1,17 +1,33 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi; namespace osu.Game.Screens.Select { public class MatchSongSelect : SongSelect, IMultiplayerScreen { + public Action Selected; + public string ShortTitle => "song selection"; protected override bool OnStart() { - if (IsCurrentScreen) Exit(); + var item = new PlaylistItem + { + Beatmap = Beatmap.Value.BeatmapInfo, + Ruleset = Ruleset.Value, + }; + + item.RequiredMods.AddRange(SelectedMods.Value); + + Selected?.Invoke(item); + + if (IsCurrentScreen) + Exit(); + return true; } }