Prevent playlist mangling selection if not allowed

This commit is contained in:
Dan Balasescu 2021-11-16 00:09:49 +09:00
parent 8e014ca17a
commit b9e38269e3

View File

@ -1,7 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -37,7 +39,7 @@ namespace osu.Game.Screens.OnlinePlay
switch (args.Action) switch (args.Action)
{ {
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:
if (args.OldItems.Contains(SelectedItem)) if (allowSelection && args.OldItems.Contains(SelectedItem))
SelectedItem.Value = null; SelectedItem.Value = null;
break; break;
} }
@ -62,7 +64,7 @@ namespace osu.Game.Screens.OnlinePlay
private void requestDeletion(PlaylistItem item) private void requestDeletion(PlaylistItem item)
{ {
if (SelectedItem.Value == item) if (allowSelection && SelectedItem.Value == item)
{ {
if (Items.Count == 1) if (Items.Count == 1)
SelectedItem.Value = null; SelectedItem.Value = null;