mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:42:55 +08:00
Add placement display to timeline
This commit is contained in:
parent
e08437c5dc
commit
56a091674b
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
protected DragBox DragBox { get; private set; }
|
protected DragBox DragBox { get; private set; }
|
||||||
|
|
||||||
private Container<SelectionBlueprint> selectionBlueprints;
|
protected Container<SelectionBlueprint> SelectionBlueprints;
|
||||||
|
|
||||||
private SelectionHandler selectionHandler;
|
private SelectionHandler selectionHandler;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
DragBox = CreateDragBox(select),
|
DragBox = CreateDragBox(select),
|
||||||
selectionHandler,
|
selectionHandler,
|
||||||
selectionBlueprints = CreateSelectionBlueprintContainer(),
|
SelectionBlueprints = CreateSelectionBlueprintContainer(),
|
||||||
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
|
DragBox.CreateProxy().With(p => p.Depth = float.MinValue)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectedHitObjects.ItemsAdded += objects =>
|
selectedHitObjects.ItemsAdded += objects =>
|
||||||
{
|
{
|
||||||
foreach (var o in objects)
|
foreach (var o in objects)
|
||||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
SelectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
||||||
|
|
||||||
SelectionChanged?.Invoke(selectedHitObjects);
|
SelectionChanged?.Invoke(selectedHitObjects);
|
||||||
};
|
};
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectedHitObjects.ItemsRemoved += objects =>
|
selectedHitObjects.ItemsRemoved += objects =>
|
||||||
{
|
{
|
||||||
foreach (var o in objects)
|
foreach (var o in objects)
|
||||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
SelectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||||
|
|
||||||
SelectionChanged?.Invoke(selectedHitObjects);
|
SelectionChanged?.Invoke(selectedHitObjects);
|
||||||
};
|
};
|
||||||
@ -230,7 +230,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void removeBlueprintFor(HitObject hitObject)
|
private void removeBlueprintFor(HitObject hitObject)
|
||||||
{
|
{
|
||||||
var blueprint = selectionBlueprints.SingleOrDefault(m => m.HitObject == hitObject);
|
var blueprint = SelectionBlueprints.SingleOrDefault(m => m.HitObject == hitObject);
|
||||||
if (blueprint == null)
|
if (blueprint == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
blueprint.Selected -= onBlueprintSelected;
|
blueprint.Selected -= onBlueprintSelected;
|
||||||
blueprint.Deselected -= onBlueprintDeselected;
|
blueprint.Deselected -= onBlueprintDeselected;
|
||||||
|
|
||||||
selectionBlueprints.Remove(blueprint);
|
SelectionBlueprints.Remove(blueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void AddBlueprintFor(HitObject hitObject)
|
protected virtual void AddBlueprintFor(HitObject hitObject)
|
||||||
@ -251,7 +251,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
blueprint.Selected += onBlueprintSelected;
|
blueprint.Selected += onBlueprintSelected;
|
||||||
blueprint.Deselected += onBlueprintDeselected;
|
blueprint.Deselected += onBlueprintDeselected;
|
||||||
|
|
||||||
selectionBlueprints.Add(blueprint);
|
SelectionBlueprints.Add(blueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -278,7 +278,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (!allowDeselection && selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
|
if (!allowDeselection && selectionHandler.SelectedBlueprints.Any(s => s.IsHovered))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (SelectionBlueprint blueprint in selectionBlueprints.AliveChildren)
|
foreach (SelectionBlueprint blueprint in SelectionBlueprints.AliveChildren)
|
||||||
{
|
{
|
||||||
if (blueprint.IsHovered)
|
if (blueprint.IsHovered)
|
||||||
{
|
{
|
||||||
@ -308,7 +308,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
|
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
|
||||||
private void select(RectangleF rect)
|
private void select(RectangleF rect)
|
||||||
{
|
{
|
||||||
foreach (var blueprint in selectionBlueprints)
|
foreach (var blueprint in SelectionBlueprints)
|
||||||
{
|
{
|
||||||
if (blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.SelectionPoint))
|
if (blueprint.IsAlive && blueprint.IsPresent && rect.Contains(blueprint.SelectionPoint))
|
||||||
blueprint.Select();
|
blueprint.Select();
|
||||||
@ -322,7 +322,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void selectAll()
|
private void selectAll()
|
||||||
{
|
{
|
||||||
selectionBlueprints.ToList().ForEach(m => m.Select());
|
SelectionBlueprints.ToList().ForEach(m => m.Select());
|
||||||
selectionHandler.UpdateVisibility();
|
selectionHandler.UpdateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,14 +334,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private void onBlueprintSelected(SelectionBlueprint blueprint)
|
private void onBlueprintSelected(SelectionBlueprint blueprint)
|
||||||
{
|
{
|
||||||
selectionHandler.HandleSelected(blueprint);
|
selectionHandler.HandleSelected(blueprint);
|
||||||
selectionBlueprints.ChangeChildDepth(blueprint, 1);
|
SelectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||||
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
|
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);
|
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
@ -21,8 +22,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private Timeline timeline { get; set; }
|
private Timeline timeline { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorBeatmap beatmap { get; set; }
|
||||||
|
|
||||||
private DragEvent lastDragEvent;
|
private DragEvent lastDragEvent;
|
||||||
|
|
||||||
|
private Bindable<HitObject> placement;
|
||||||
|
|
||||||
|
private SelectionBlueprint placementBlueprint;
|
||||||
|
|
||||||
public TimelineBlueprintContainer()
|
public TimelineBlueprintContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -43,6 +51,29 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
DragBox.Alpha = 0;
|
DragBox.Alpha = 0;
|
||||||
|
|
||||||
|
placement = beatmap.PlacementObject.GetBoundCopy();
|
||||||
|
placement.ValueChanged += placementChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void placementChanged(ValueChangedEvent<HitObject> obj)
|
||||||
|
{
|
||||||
|
if (obj.NewValue == null)
|
||||||
|
{
|
||||||
|
if (placementBlueprint != null)
|
||||||
|
{
|
||||||
|
SelectionBlueprints.Remove(placementBlueprint);
|
||||||
|
placementBlueprint = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
placementBlueprint = CreateBlueprintFor(obj.NewValue);
|
||||||
|
|
||||||
|
placementBlueprint.Colour = Color4.MediumPurple;
|
||||||
|
|
||||||
|
SelectionBlueprints.Add(placementBlueprint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Container<SelectionBlueprint> CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
|
protected override Container<SelectionBlueprint> CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
|
||||||
|
Loading…
Reference in New Issue
Block a user