diff --git a/osu.Android.props b/osu.Android.props
index 1a76a24496..2d3bfaf7ce 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,6 +52,6 @@
-
+
diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs
index 5ba55f6d45..692175603c 100644
--- a/osu.Game/Overlays/ChatOverlay.cs
+++ b/osu.Game/Overlays/ChatOverlay.cs
@@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Linq;
using osuTK;
using osuTK.Graphics;
@@ -218,14 +219,13 @@ namespace osu.Game.Overlays
Schedule(() =>
{
// TODO: consider scheduling bindable callbacks to not perform when overlay is not present.
- channelManager.JoinedChannels.ItemsAdded += onChannelAddedToJoinedChannels;
- channelManager.JoinedChannels.ItemsRemoved += onChannelRemovedFromJoinedChannels;
+ channelManager.JoinedChannels.CollectionChanged += joinedChannelsChanged;
+
foreach (Channel channel in channelManager.JoinedChannels)
ChannelTabControl.AddChannel(channel);
- channelManager.AvailableChannels.ItemsAdded += availableChannelsChanged;
- channelManager.AvailableChannels.ItemsRemoved += availableChannelsChanged;
- ChannelSelectionOverlay.UpdateAvailableChannels(channelManager.AvailableChannels);
+ channelManager.AvailableChannels.CollectionChanged += availableChannelsChanged;
+ availableChannelsChanged(null, null);
currentChannel = channelManager.CurrentChannel.GetBoundCopy();
currentChannel.BindValueChanged(currentChannelChanged, true);
@@ -384,34 +384,41 @@ namespace osu.Game.Overlays
base.PopOut();
}
- private void onChannelAddedToJoinedChannels(IEnumerable channels)
+ private void joinedChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
{
- foreach (Channel channel in channels)
- ChannelTabControl.AddChannel(channel);
- }
-
- private void onChannelRemovedFromJoinedChannels(IEnumerable channels)
- {
- foreach (Channel channel in channels)
+ switch (args.Action)
{
- ChannelTabControl.RemoveChannel(channel);
+ case NotifyCollectionChangedAction.Add:
+ foreach (Channel channel in args.NewItems.Cast())
+ ChannelTabControl.AddChannel(channel);
+ break;
- var loaded = loadedChannels.Find(c => c.Channel == channel);
+ case NotifyCollectionChangedAction.Remove:
+ foreach (Channel channel in args.OldItems.Cast())
+ {
+ ChannelTabControl.RemoveChannel(channel);
- if (loaded != null)
- {
- loadedChannels.Remove(loaded);
+ var loaded = loadedChannels.Find(c => c.Channel == channel);
- // Because the container is only cleared in the async load callback of a new channel, it is forcefully cleared
- // to ensure that the previous channel doesn't get updated after it's disposed
- currentChannelContainer.Remove(loaded);
- loaded.Dispose();
- }
+ if (loaded != null)
+ {
+ loadedChannels.Remove(loaded);
+
+ // Because the container is only cleared in the async load callback of a new channel, it is forcefully cleared
+ // to ensure that the previous channel doesn't get updated after it's disposed
+ currentChannelContainer.Remove(loaded);
+ loaded.Dispose();
+ }
+ }
+
+ break;
}
}
- private void availableChannelsChanged(IEnumerable channels)
- => ChannelSelectionOverlay.UpdateAvailableChannels(channelManager.AvailableChannels);
+ private void availableChannelsChanged(object sender, NotifyCollectionChangedEventArgs args)
+ {
+ ChannelSelectionOverlay.UpdateAvailableChannels(channelManager.AvailableChannels);
+ }
protected override void Dispose(bool isDisposing)
{
@@ -420,10 +427,8 @@ namespace osu.Game.Overlays
if (channelManager != null)
{
channelManager.CurrentChannel.ValueChanged -= currentChannelChanged;
- channelManager.JoinedChannels.ItemsAdded -= onChannelAddedToJoinedChannels;
- channelManager.JoinedChannels.ItemsRemoved -= onChannelRemovedFromJoinedChannels;
- channelManager.AvailableChannels.ItemsAdded -= availableChannelsChanged;
- channelManager.AvailableChannels.ItemsRemoved -= availableChannelsChanged;
+ channelManager.JoinedChannels.CollectionChanged -= joinedChannelsChanged;
+ channelManager.AvailableChannels.CollectionChanged -= availableChannelsChanged;
}
}
diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs
index 00b7643332..4312b319c0 100644
--- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs
+++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs
@@ -163,8 +163,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
scalingSettings.ForEach(s => s.TransferValueOnCommit = mode.NewValue == ScalingMode.Everything);
}, true);
- windowModes.ItemsAdded += _ => windowModesChanged();
- windowModes.ItemsRemoved += _ => windowModesChanged();
+ windowModes.CollectionChanged += (sender, args) => windowModesChanged();
windowModesChanged();
}
diff --git a/osu.Game/Screens/Edit/Timing/ControlPointTable.cs b/osu.Game/Screens/Edit/Timing/ControlPointTable.cs
index 5c59cfbfe8..c0c0bcead2 100644
--- a/osu.Game/Screens/Edit/Timing/ControlPointTable.cs
+++ b/osu.Game/Screens/Edit/Timing/ControlPointTable.cs
@@ -112,8 +112,7 @@ namespace osu.Game.Screens.Edit.Timing
};
controlPoints = group.ControlPoints.GetBoundCopy();
- controlPoints.ItemsAdded += _ => createChildren();
- controlPoints.ItemsRemoved += _ => createChildren();
+ controlPoints.CollectionChanged += (_, __) => createChildren();
createChildren();
}
diff --git a/osu.Game/Screens/Edit/Timing/TimingScreen.cs b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
index a08a660e7e..8c40c8e721 100644
--- a/osu.Game/Screens/Edit/Timing/TimingScreen.cs
+++ b/osu.Game/Screens/Edit/Timing/TimingScreen.cs
@@ -124,8 +124,7 @@ namespace osu.Game.Screens.Edit.Timing
selectedGroup.BindValueChanged(selected => { deleteButton.Enabled.Value = selected.NewValue != null; }, true);
controlGroups = Beatmap.Value.Beatmap.ControlPointInfo.Groups.GetBoundCopy();
- controlGroups.ItemsAdded += _ => createContent();
- controlGroups.ItemsRemoved += _ => createContent();
+ controlGroups.CollectionChanged += (sender, args) => createContent();
createContent();
}
diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs
index 447c99039a..321d7b0a19 100644
--- a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs
+++ b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@@ -53,8 +54,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
protected override void LoadComplete()
{
- rooms.ItemsAdded += addRooms;
- rooms.ItemsRemoved += removeRooms;
+ rooms.CollectionChanged += roomsChanged;
roomManager.RoomsUpdated += updateSorting;
rooms.BindTo(roomManager.Rooms);
@@ -82,6 +82,20 @@ namespace osu.Game.Screens.Multi.Lounge.Components
});
}
+ private void roomsChanged(object sender, NotifyCollectionChangedEventArgs args)
+ {
+ switch (args.Action)
+ {
+ case NotifyCollectionChangedAction.Add:
+ addRooms(args.NewItems.Cast());
+ break;
+
+ case NotifyCollectionChangedAction.Remove:
+ removeRooms(args.OldItems.Cast());
+ break;
+ }
+ }
+
private void addRooms(IEnumerable rooms)
{
foreach (var room in rooms)
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index c021770d7b..166910b165 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 9b25eaab41..51f8141bac 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -70,7 +70,7 @@
-
+
@@ -80,7 +80,7 @@
-
+