mirror of
https://github.com/osukey/osukey.git
synced 2025-05-18 03:57:32 +09:00
Prevent reloads when playlist item order changes
This commit is contained in:
parent
37dea0ff21
commit
16d4544ff9
@ -11,6 +11,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Online.Rooms
|
namespace osu.Game.Online.Rooms
|
||||||
{
|
{
|
||||||
@ -101,13 +102,13 @@ namespace osu.Game.Online.Rooms
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public PlaylistItem With(IBeatmapInfo beatmap) => new PlaylistItem(beatmap)
|
public PlaylistItem With(Optional<IBeatmapInfo> beatmap = default, Optional<ushort?> playlistOrder = default) => new PlaylistItem(beatmap.GetOr(Beatmap))
|
||||||
{
|
{
|
||||||
ID = ID,
|
ID = ID,
|
||||||
OwnerID = OwnerID,
|
OwnerID = OwnerID,
|
||||||
RulesetID = RulesetID,
|
RulesetID = RulesetID,
|
||||||
Expired = Expired,
|
Expired = Expired,
|
||||||
PlaylistOrder = PlaylistOrder,
|
PlaylistOrder = playlistOrder.GetOr(PlaylistOrder),
|
||||||
PlayedAt = PlayedAt,
|
PlayedAt = PlayedAt,
|
||||||
AllowedMods = AllowedMods,
|
AllowedMods = AllowedMods,
|
||||||
RequiredMods = RequiredMods,
|
RequiredMods = RequiredMods,
|
||||||
@ -119,6 +120,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
&& Beatmap.OnlineID == other.Beatmap.OnlineID
|
&& Beatmap.OnlineID == other.Beatmap.OnlineID
|
||||||
&& RulesetID == other.RulesetID
|
&& RulesetID == other.RulesetID
|
||||||
&& Expired == other.Expired
|
&& Expired == other.Expired
|
||||||
|
&& PlaylistOrder == other.PlaylistOrder
|
||||||
&& AllowedMods.SequenceEqual(other.AllowedMods)
|
&& AllowedMods.SequenceEqual(other.AllowedMods)
|
||||||
&& RequiredMods.SequenceEqual(other.RequiredMods);
|
&& RequiredMods.SequenceEqual(other.RequiredMods);
|
||||||
}
|
}
|
||||||
|
@ -117,8 +117,24 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
|||||||
{
|
{
|
||||||
base.PlaylistItemChanged(item);
|
base.PlaylistItemChanged(item);
|
||||||
|
|
||||||
removeItemFromLists(item.ID);
|
var newApiItem = Playlist.SingleOrDefault(i => i.ID == item.ID);
|
||||||
addItemToLists(item);
|
var existingApiItemInQueue = queueList.Items.SingleOrDefault(i => i.ID == item.ID);
|
||||||
|
|
||||||
|
// Test if the only change between the two playlist items is the order.
|
||||||
|
if (newApiItem != null && existingApiItemInQueue != null && existingApiItemInQueue.With(playlistOrder: newApiItem.PlaylistOrder).Equals(newApiItem))
|
||||||
|
{
|
||||||
|
// Set the new playlist order directly without refreshing the DrawablePlaylistItem.
|
||||||
|
existingApiItemInQueue.PlaylistOrder = newApiItem.PlaylistOrder;
|
||||||
|
|
||||||
|
// The following isn't really required, but is here for safety and explicitness.
|
||||||
|
// MultiplayerQueueList internally binds to changes in Playlist to invalidate its own layout, which is mutated on every playlist operation.
|
||||||
|
queueList.Invalidate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeItemFromLists(item.ID);
|
||||||
|
addItemToLists(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItemToLists(MultiplayerPlaylistItem item)
|
private void addItemToLists(MultiplayerPlaylistItem item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user