From 7c2ffb18269cfbb1d03724c9936935d09b1791a0 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Fri, 22 Feb 2019 11:26:06 +0000 Subject: [PATCH 1/7] Fix MatchSongSelect not handling beatmapset deletions --- .../Screens/Multi/Match/Components/ReadyButton.cs | 10 ++++++++++ osu.Game/Screens/Select/MatchSongSelect.cs | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs index 3e4694e232..b299e70962 100644 --- a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -39,6 +39,7 @@ namespace osu.Game.Screens.Multi.Match.Components private void load() { beatmaps.ItemAdded += beatmapAdded; + beatmaps.ItemRemoved += beatmapRemoved; Beatmap.BindValueChanged(b => updateBeatmap(b.NewValue), true); } @@ -62,6 +63,15 @@ namespace osu.Game.Screens.Multi.Match.Components Schedule(() => hasBeatmap = true); } + private void beatmapRemoved(BeatmapSetInfo model) + { + if (Beatmap.Value == null) + return; + + if (model.OnlineBeatmapSetID == Beatmap.Value.BeatmapSet.OnlineBeatmapSetID) + Schedule(() => hasBeatmap = false); + } + protected override void Update() { base.Update(); diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index cfeaa1785e..f54add6a36 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -3,8 +3,11 @@ using System; using Humanizer; +using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Screens; +using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi; @@ -17,6 +20,12 @@ namespace osu.Game.Screens.Select public string ShortTitle => "song selection"; public override string Title => ShortTitle.Humanize(); + [Resolved(typeof(Room))] + protected Bindable CurrentItem { get; private set; } + + [Resolved] + private BeatmapManager beatmaps { get; set; } + public MatchSongSelect() { Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING }; @@ -43,10 +52,14 @@ namespace osu.Game.Screens.Select public override bool OnExiting(IScreen next) { + if (base.OnExiting(next)) + return true; + + Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value?.Beatmap); Beatmap.Disabled = true; Ruleset.Disabled = true; - return base.OnExiting(next); + return false; } public override void OnEntering(IScreen last) From a3f71d69a904ac57c451ee32cec3efcd775c5397 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Wed, 27 Feb 2019 16:16:13 +0900 Subject: [PATCH 2/7] Ensure ruleset and mods are set correctly when leaving MatchSongSelect --- osu.Game/Screens/Select/MatchSongSelect.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index f54add6a36..bdff35e345 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -56,6 +56,10 @@ namespace osu.Game.Screens.Select return true; Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value?.Beatmap); + Ruleset.Value = CurrentItem.Value?.Ruleset; + CurrentItem.Value?.RequiredMods.Clear(); + CurrentItem.Value?.RequiredMods.AddRange(SelectedMods.Value); + Beatmap.Disabled = true; Ruleset.Disabled = true; From c59d84fd21c0b6d33986709435f453786306d46e Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Wed, 27 Feb 2019 16:17:04 +0900 Subject: [PATCH 3/7] Add sanity check to prevent TimeshiftPlayer from starting with incorrect beatmap/ruleset/mods --- .../Screens/Multi/Play/TimeshiftPlayer.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index d127bdc0ea..7d35276442 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Diagnostics; using System.Threading; using osu.Framework.Allocation; @@ -11,6 +12,8 @@ using osu.Framework.Screens; using osu.Game.Online.API; using osu.Game.Online.API.Requests; using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens.Multi.Ranking; using osu.Game.Screens.Play; @@ -30,6 +33,12 @@ namespace osu.Game.Screens.Multi.Play [Resolved] private APIAccess api { get; set; } + [Resolved] + private IBindable ruleset { get; set; } + + [Resolved] + protected Bindable> CurrentMods { get; private set; } + public TimeshiftPlayer(PlaylistItem playlistItem) { this.playlistItem = playlistItem; @@ -44,6 +53,16 @@ namespace osu.Game.Screens.Multi.Play bool failed = false; + // Sanity checks to ensure that TimeshiftPlayer matches the settings for the current PlaylistItem + if (Beatmap.Value.BeatmapInfo.OnlineBeatmapID != playlistItem.Beatmap.OnlineBeatmapID) + throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap"); + + if (ruleset.Value.ID != playlistItem.Ruleset.ID) + throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset"); + + if (!CurrentMods.Value.Equals(playlistItem.RequiredMods)) + throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods"); + var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID); req.Success += r => token = r.ID; req.Failure += e => From cf2feec7df7c2f19ef8e035b2187729e71ff89dd Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 28 Feb 2019 14:58:44 +0900 Subject: [PATCH 4/7] Fix multiplayer enabled mods check --- osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index 7d35276442..374aad5681 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -60,7 +61,7 @@ namespace osu.Game.Screens.Multi.Play if (ruleset.Value.ID != playlistItem.Ruleset.ID) throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset"); - if (!CurrentMods.Value.Equals(playlistItem.RequiredMods)) + if (!playlistItem.RequiredMods.All(m => CurrentMods.Value.Contains(m))) throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods"); var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID); From 6e821a426d4bcc234788a7703110ed9fc7ad5185 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 28 Feb 2019 15:01:32 +0900 Subject: [PATCH 5/7] Fix restoration of enabled mods when cancelling song select --- osu.Game/Screens/Select/MatchSongSelect.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index bdff35e345..ec4a39206b 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using Humanizer; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -9,6 +10,7 @@ using osu.Framework.Graphics; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi; namespace osu.Game.Screens.Select @@ -23,6 +25,9 @@ namespace osu.Game.Screens.Select [Resolved(typeof(Room))] protected Bindable CurrentItem { get; private set; } + [Resolved] + protected Bindable> CurrentMods { get; private set; } + [Resolved] private BeatmapManager beatmaps { get; set; } @@ -56,9 +61,8 @@ namespace osu.Game.Screens.Select return true; Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value?.Beatmap); + Beatmap.Value.Mods.Value = CurrentMods.Value = CurrentItem.Value?.RequiredMods; Ruleset.Value = CurrentItem.Value?.Ruleset; - CurrentItem.Value?.RequiredMods.Clear(); - CurrentItem.Value?.RequiredMods.AddRange(SelectedMods.Value); Beatmap.Disabled = true; Ruleset.Disabled = true; From 4c8aa65200aed962bffbc3a48d2112d18930a7c5 Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 28 Feb 2019 17:02:45 +0900 Subject: [PATCH 6/7] private + renaming --- osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs | 4 ++-- osu.Game/Screens/Select/MatchSongSelect.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index 374aad5681..2e758d34c5 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Multi.Play private IBindable ruleset { get; set; } [Resolved] - protected Bindable> CurrentMods { get; private set; } + private Bindable> currentMods { get; set; } public TimeshiftPlayer(PlaylistItem playlistItem) { @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Multi.Play if (ruleset.Value.ID != playlistItem.Ruleset.ID) throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset"); - if (!playlistItem.RequiredMods.All(m => CurrentMods.Value.Contains(m))) + if (!playlistItem.RequiredMods.All(m => currentMods.Value.Contains(m))) throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods"); var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID); diff --git a/osu.Game/Screens/Select/MatchSongSelect.cs b/osu.Game/Screens/Select/MatchSongSelect.cs index ec4a39206b..f6d758df29 100644 --- a/osu.Game/Screens/Select/MatchSongSelect.cs +++ b/osu.Game/Screens/Select/MatchSongSelect.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Select protected Bindable CurrentItem { get; private set; } [Resolved] - protected Bindable> CurrentMods { get; private set; } + private Bindable> selectedMods { get; set; } [Resolved] private BeatmapManager beatmaps { get; set; } @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select return true; Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value?.Beatmap); - Beatmap.Value.Mods.Value = CurrentMods.Value = CurrentItem.Value?.RequiredMods; + Beatmap.Value.Mods.Value = selectedMods.Value = CurrentItem.Value?.RequiredMods; Ruleset.Value = CurrentItem.Value?.Ruleset; Beatmap.Disabled = true; From 921346d303e9266b5b91e0a7060d82701a498c89 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 28 Feb 2019 17:27:28 +0900 Subject: [PATCH 7/7] Rename a few more members --- osu.Game/Screens/Multi/Match/MatchSubScreen.cs | 6 +++--- osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs index c3f7cea43e..229b9bde6a 100644 --- a/osu.Game/Screens/Multi/Match/MatchSubScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchSubScreen.cs @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Multi.Match protected Bindable CurrentItem { get; private set; } [Resolved] - protected Bindable> CurrentMods { get; private set; } + protected Bindable> SelectedMods { get; private set; } [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -194,7 +194,7 @@ namespace osu.Game.Screens.Multi.Match var localBeatmap = e.NewValue?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == e.NewValue.Beatmap.OnlineBeatmapID); Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap); - CurrentMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty(); + SelectedMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty(); if (e.NewValue?.Ruleset != null) Ruleset.Value = e.NewValue.Ruleset; } @@ -222,7 +222,7 @@ namespace osu.Game.Screens.Multi.Match private void onStart() { - Beatmap.Value.Mods.Value = CurrentMods.Value.ToArray(); + Beatmap.Value.Mods.Value = SelectedMods.Value.ToArray(); switch (type.Value) { diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs index 2e758d34c5..6b88403b9e 100644 --- a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -38,7 +38,7 @@ namespace osu.Game.Screens.Multi.Play private IBindable ruleset { get; set; } [Resolved] - private Bindable> currentMods { get; set; } + private Bindable> selectedMods { get; set; } public TimeshiftPlayer(PlaylistItem playlistItem) { @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Multi.Play if (ruleset.Value.ID != playlistItem.Ruleset.ID) throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset"); - if (!playlistItem.RequiredMods.All(m => currentMods.Value.Contains(m))) + if (!playlistItem.RequiredMods.All(m => selectedMods.Value.Contains(m))) throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods"); var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);