mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:02:55 +08:00
Merge pull request #4341 from nekodex/better-mp-songselect-deletion-handling
Better beatmap deletion handling while in multiplayer song select
This commit is contained in:
commit
bfe3d5708d
@ -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();
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Multi.Match
|
||||
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected Bindable<IEnumerable<Mod>> CurrentMods { get; private set; }
|
||||
protected Bindable<IEnumerable<Mod>> 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<Mod>();
|
||||
SelectedMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty<Mod>();
|
||||
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)
|
||||
{
|
||||
|
@ -2,7 +2,9 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -11,6 +13,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 +34,12 @@ namespace osu.Game.Screens.Multi.Play
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IEnumerable<Mod>> selectedMods { get; set; }
|
||||
|
||||
public TimeshiftPlayer(PlaylistItem playlistItem)
|
||||
{
|
||||
this.playlistItem = playlistItem;
|
||||
@ -44,6 +54,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 (!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);
|
||||
req.Success += r => token = r.ID;
|
||||
req.Failure += e =>
|
||||
|
@ -2,10 +2,15 @@
|
||||
// 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;
|
||||
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
|
||||
@ -17,6 +22,15 @@ namespace osu.Game.Screens.Select
|
||||
public string ShortTitle => "song selection";
|
||||
public override string Title => ShortTitle.Humanize();
|
||||
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<PlaylistItem> CurrentItem { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IEnumerable<Mod>> selectedMods { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
public MatchSongSelect()
|
||||
{
|
||||
Padding = new MarginPadding { Horizontal = HORIZONTAL_OVERFLOW_PADDING };
|
||||
@ -43,10 +57,17 @@ 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.Value.Mods.Value = selectedMods.Value = CurrentItem.Value?.RequiredMods;
|
||||
Ruleset.Value = CurrentItem.Value?.Ruleset;
|
||||
|
||||
Beatmap.Disabled = true;
|
||||
Ruleset.Disabled = true;
|
||||
|
||||
return base.OnExiting(next);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnEntering(IScreen last)
|
||||
|
Loading…
Reference in New Issue
Block a user