1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Make use of ValueChanged.OldValue

This commit is contained in:
Dean Herbert 2019-05-20 14:47:46 +09:00
parent f81c66db63
commit d8ed402779

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation;
@ -146,10 +145,15 @@ namespace osu.Game.Tournament.Components
private void matchChanged(ValueChangedEvent<MatchPairing> pairing)
{
if (pairing.OldValue != null)
pairing.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged;
pairing.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged;
updateState();
}
private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
=> updateState();
private BeatmapChoice choice;
private void updateState()
@ -197,19 +201,5 @@ namespace osu.Game.Tournament.Components
Alpha = 1;
}
}
private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
var list = (ObservableCollection<BeatmapChoice>)sender;
if (sender != currentMatch.Value.PicksBans)
{
// todo: we need a last attribute in bindable valuechanged events badly.
list.CollectionChanged -= picksBansOnCollectionChanged;
return;
}
updateState();
}
}
}