mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:03:08 +08:00
Share selected hitobjects across multiple blueprint containers
This commit is contained in:
parent
1ce78afa98
commit
c88bdbd4a0
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
@ -41,6 +42,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private IDistanceSnapProvider snapProvider { get; set; }
|
||||
|
||||
@ -65,6 +68,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
foreach (var obj in beatmap.HitObjects)
|
||||
AddBlueprintFor(obj);
|
||||
|
||||
selectedHitObjects.BindTo(beatmap.SelectedHitObjects);
|
||||
selectedHitObjects.ItemsAdded += objects =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
||||
};
|
||||
|
||||
selectedHitObjects.ItemsRemoved += objects =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
|
||||
@ -315,6 +331,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
selectionHandler.HandleSelected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
@ -323,6 +340,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
selectionHandler.HandleDeselected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 0);
|
||||
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
|
@ -102,7 +102,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// Handle a blueprint becoming selected.
|
||||
/// </summary>
|
||||
/// <param name="blueprint">The blueprint.</param>
|
||||
internal void HandleSelected(SelectionBlueprint blueprint) => selectedBlueprints.Add(blueprint);
|
||||
internal void HandleSelected(SelectionBlueprint blueprint)
|
||||
{
|
||||
selectedBlueprints.Add(blueprint);
|
||||
editorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle a blueprint becoming deselected.
|
||||
@ -111,6 +115,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
internal void HandleDeselected(SelectionBlueprint blueprint)
|
||||
{
|
||||
selectedBlueprints.Remove(blueprint);
|
||||
editorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
|
||||
|
||||
// We don't want to update visibility if > 0, since we may be deselecting blueprints during drag-selection
|
||||
if (selectedBlueprints.Count == 0)
|
||||
|
@ -29,6 +29,8 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public event Action<HitObject> StartTimeChanged;
|
||||
|
||||
public BindableList<HitObject> SelectedHitObjects { get; } = new BindableList<HitObject>();
|
||||
|
||||
public readonly IBeatmap PlayableBeatmap;
|
||||
|
||||
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();
|
||||
|
Loading…
Reference in New Issue
Block a user