mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 00:13:19 +08:00
Rectify selection keep-alive logic
This commit is contained in:
parent
246aacb216
commit
234ef6f923
@ -51,10 +51,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
Beatmap.HitObjectAdded += AddBlueprintFor;
|
Beatmap.HitObjectAdded += AddBlueprintFor;
|
||||||
Beatmap.HitObjectRemoved += RemoveBlueprintFor;
|
Beatmap.HitObjectRemoved += RemoveBlueprintFor;
|
||||||
|
Beatmap.SelectedHitObjects.CollectionChanged += updateSelectionLifetime;
|
||||||
// This makes sure HitObjects will have active Blueprints ready to display
|
|
||||||
// after clicking on an Editor Timestamp/Link
|
|
||||||
Beatmap.SelectedHitObjects.CollectionChanged += selectionChanged;
|
|
||||||
|
|
||||||
if (Composer != null)
|
if (Composer != null)
|
||||||
{
|
{
|
||||||
@ -149,13 +146,23 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
SelectedItems.AddRange(Beatmap.HitObjects.Except(SelectedItems).ToArray());
|
SelectedItems.AddRange(Beatmap.HitObjects.Except(SelectedItems).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
/// <summary>
|
||||||
|
/// Ensures that newly-selected hitobjects are kept alive
|
||||||
|
/// and drops that keep-alive from newly-deselected objects.
|
||||||
|
/// </summary>
|
||||||
|
private void updateSelectionLifetime(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e == null || e.Action != NotifyCollectionChangedAction.Add || e.NewItems == null)
|
if (e.NewItems != null)
|
||||||
return;
|
{
|
||||||
|
foreach (HitObject newSelection in e.NewItems)
|
||||||
|
Composer.Playfield.SetKeepAlive(newSelection, true);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (HitObject item in e.NewItems)
|
if (e.OldItems != null)
|
||||||
Composer.Playfield.SetKeepAlive(item, true);
|
{
|
||||||
|
foreach (HitObject oldSelection in e.OldItems)
|
||||||
|
Composer.Playfield.SetKeepAlive(oldSelection, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBlueprintSelected(SelectionBlueprint<HitObject> blueprint)
|
protected override void OnBlueprintSelected(SelectionBlueprint<HitObject> blueprint)
|
||||||
@ -180,7 +187,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
||||||
Beatmap.HitObjectRemoved -= RemoveBlueprintFor;
|
Beatmap.HitObjectRemoved -= RemoveBlueprintFor;
|
||||||
Beatmap.SelectedHitObjects.CollectionChanged -= selectionChanged;
|
Beatmap.SelectedHitObjects.CollectionChanged -= updateSelectionLifetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
usageEventBuffer?.Dispose();
|
usageEventBuffer?.Dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user