Update with framework-side bindable list changes

This commit is contained in:
smoogipoo
2020-02-17 15:06:14 +09:00
parent 6fd5667ff4
commit 958c891d15
15 changed files with 127 additions and 77 deletions

View File

@ -1,6 +1,8 @@
// 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.
using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
@ -71,8 +73,19 @@ namespace osu.Game.Tournament.Screens.Editors
}
});
Storage.ItemsAdded += items => items.ForEach(i => flow.Add(CreateDrawable(i)));
Storage.ItemsRemoved += items => items.ForEach(i => flow.RemoveAll(d => d.Model == i));
Storage.CollectionChanged += (_, args) =>
{
switch (args.Action)
{
case NotifyCollectionChangedAction.Add:
args.NewItems.Cast<TModel>().ForEach(i => flow.Add(CreateDrawable(i)));
break;
case NotifyCollectionChangedAction.Remove:
args.OldItems.Cast<TModel>().ForEach(i => flow.RemoveAll(d => d.Model == i));
break;
}
};
foreach (var model in Storage)
flow.Add(CreateDrawable(model));