mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Update with framework-side bindable list changes
This commit is contained in:
@ -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));
|
||||
|
Reference in New Issue
Block a user