Fix editor selected hitobjects containing the selection up to five times

This commit is contained in:
Dean Herbert 2020-09-11 20:13:54 +09:00
parent 73dd21c8fc
commit 22e6df02b6
2 changed files with 14 additions and 8 deletions

View File

@ -367,14 +367,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
selectionHandler.HandleSelected(blueprint); selectionHandler.HandleSelected(blueprint);
SelectionBlueprints.ChangeChildDepth(blueprint, 1); SelectionBlueprints.ChangeChildDepth(blueprint, 1);
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
} }
private void onBlueprintDeselected(SelectionBlueprint blueprint) private void onBlueprintDeselected(SelectionBlueprint blueprint)
{ {
selectionHandler.HandleDeselected(blueprint); selectionHandler.HandleDeselected(blueprint);
SelectionBlueprints.ChangeChildDepth(blueprint, 0); SelectionBlueprints.ChangeChildDepth(blueprint, 0);
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
} }
#endregion #endregion

View File

@ -144,12 +144,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
/// <param name="blueprint">The blueprint.</param> /// <param name="blueprint">The blueprint.</param>
internal void HandleSelected(SelectionBlueprint blueprint) internal void HandleSelected(SelectionBlueprint blueprint)
{
if (!selectedBlueprints.Contains(blueprint))
{ {
selectedBlueprints.Add(blueprint); selectedBlueprints.Add(blueprint);
// need to check this as well, as there are potentially multiple SelectionHandlers and the above check is not enough.
if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject))
EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject); EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
UpdateVisibility(); UpdateVisibility();
} }
}
/// <summary> /// <summary>
/// Handle a blueprint becoming deselected. /// Handle a blueprint becoming deselected.
@ -157,11 +163,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <param name="blueprint">The blueprint.</param> /// <param name="blueprint">The blueprint.</param>
internal void HandleDeselected(SelectionBlueprint blueprint) internal void HandleDeselected(SelectionBlueprint blueprint)
{ {
selectedBlueprints.Remove(blueprint); if (selectedBlueprints.Remove(blueprint))
{
EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject); EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
UpdateVisibility(); UpdateVisibility();
} }
}
/// <summary> /// <summary>
/// Handle a blueprint requesting selection. /// Handle a blueprint requesting selection.