mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:52:56 +08:00
Don't replace identical playlist items
This commit is contained in:
parent
f732c44265
commit
2408011c81
@ -17,9 +17,19 @@ namespace osu.Game.Tests.Visual.Multiplayer.QueueingModes
|
||||
protected override QueueModes Mode => QueueModes.HostOnly;
|
||||
|
||||
[Test]
|
||||
public void TestItemStillSelectedAfterChange()
|
||||
public void TestItemStillSelectedAfterChangeToSameBeatmap()
|
||||
{
|
||||
selectNewItem(() => InitialBeatmap);
|
||||
|
||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value == Client.APIRoom?.Playlist[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestItemStillSelectedAfterChangeToOtherBeatmap()
|
||||
{
|
||||
selectNewItem(() => OtherBeatmap);
|
||||
|
||||
AddAssert("playlist item still selected", () => Client.CurrentMatchPlayingItem.Value == Client.APIRoom?.Playlist[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -57,9 +67,11 @@ namespace osu.Game.Tests.Visual.Multiplayer.QueueingModes
|
||||
|
||||
AddUntilStep("wait for song select", () => CurrentSubScreen is Screens.Select.SongSelect select && select.IsLoaded);
|
||||
|
||||
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(beatmap()));
|
||||
BeatmapInfo otherBeatmap = null;
|
||||
AddStep("select other beatmap", () => ((Screens.Select.SongSelect)CurrentSubScreen).FinaliseSelection(otherBeatmap = beatmap()));
|
||||
|
||||
AddUntilStep("wait for return to match", () => CurrentSubScreen is MultiplayerMatchSubScreen);
|
||||
AddUntilStep("selected item is new beatmap", () => Client.CurrentMatchPlayingItem.Value?.Beatmap.Value?.OnlineID == OtherBeatmap.OnlineID);
|
||||
AddUntilStep("selected item is new beatmap", () => Client.CurrentMatchPlayingItem.Value?.Beatmap.Value?.OnlineID == otherBeatmap.OnlineID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -623,11 +623,16 @@ namespace osu.Game.Online.Multiplayer
|
||||
Debug.Assert(APIRoom != null);
|
||||
|
||||
int index = APIRoom.Playlist.Select((i, index) => (i, index)).Single(kvp => kvp.i.ID == item.ID).index;
|
||||
var oldItem = APIRoom.Playlist[index];
|
||||
if (oldItem.Equals(playlistItem))
|
||||
return;
|
||||
|
||||
// Replace the item.
|
||||
APIRoom.Playlist.RemoveAt(index);
|
||||
APIRoom.Playlist.Insert(index, playlistItem);
|
||||
|
||||
// If the current item changed, update the selected playlist item.
|
||||
if (item.ID == Room.Settings.PlaylistItemId)
|
||||
// If the currently-selected item was the one that got replaced, update the selected item to the new one.
|
||||
if (CurrentMatchPlayingItem.Value == oldItem)
|
||||
CurrentMatchPlayingItem.Value = APIRoom.Playlist[index];
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user