Clean up selection handling

This commit is contained in:
smoogipoo
2020-02-14 16:55:05 +09:00
parent 6a466ea2f5
commit aceba8791c
3 changed files with 40 additions and 43 deletions

View File

@ -28,15 +28,7 @@ namespace osu.Game.Screens.Multi
{
base.LoadComplete();
SelectedItem.BindValueChanged(item =>
{
if (item.OldValue != null && ItemMap.TryGetValue(item.OldValue, out var oldItem))
((DrawableRoomPlaylistItem)oldItem).Deselect();
if (item.NewValue != null && ItemMap.TryGetValue(item.NewValue, out var newItem))
((DrawableRoomPlaylistItem)newItem).Select();
}, true);
// Scheduled since items are removed and re-added upon rearrangement
Items.ItemsRemoved += items => Schedule(() =>
{
if (!Items.Contains(SelectedItem.Value))
@ -58,7 +50,7 @@ namespace osu.Game.Screens.Multi
protected override OsuRearrangeableListItem<PlaylistItem> CreateOsuDrawable(PlaylistItem item) => new DrawableRoomPlaylistItem(item, allowEdit, allowSelection)
{
RequestSelection = requestSelection,
SelectedItem = { BindTarget = SelectedItem },
RequestDeletion = requestDeletion
};