mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Add timeline visible range adjustment
This commit is contained in:
parent
3957697c48
commit
0219aff7bc
@ -35,6 +35,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
protected SelectionHandler SelectionHandler { get; private set; }
|
||||
|
||||
protected readonly HitObjectComposer Composer;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IEditorChangeHandler changeHandler { get; set; }
|
||||
|
||||
@ -45,7 +47,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
protected EditorBeatmap Beatmap { get; private set; }
|
||||
|
||||
private readonly BindableList<HitObject> selectedHitObjects = new BindableList<HitObject>();
|
||||
private readonly HitObjectComposer composer;
|
||||
private readonly Dictionary<HitObject, SelectionBlueprint> blueprintMap = new Dictionary<HitObject, SelectionBlueprint>();
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
@ -53,7 +54,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
protected BlueprintContainer(HitObjectComposer composer)
|
||||
{
|
||||
this.composer = composer;
|
||||
Composer = composer;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
@ -74,9 +75,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
});
|
||||
|
||||
// For non-pooled rulesets, hitobjects are already present in the playfield which allows the blueprints to be loaded in the async context.
|
||||
if (composer != null)
|
||||
if (Composer != null)
|
||||
{
|
||||
foreach (var obj in composer.HitObjects)
|
||||
foreach (var obj in Composer.HitObjects)
|
||||
addBlueprintFor(obj.HitObject);
|
||||
}
|
||||
|
||||
@ -106,14 +107,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
Beatmap.HitObjectAdded += addBlueprintFor;
|
||||
Beatmap.HitObjectRemoved += removeBlueprintFor;
|
||||
|
||||
if (composer != null)
|
||||
if (Composer != null)
|
||||
{
|
||||
// For pooled rulesets, blueprints must be added for hitobjects already "current" as they would've not been "current" during the async load addition process above.
|
||||
foreach (var obj in composer.HitObjects)
|
||||
foreach (var obj in Composer.HitObjects)
|
||||
addBlueprintFor(obj.HitObject);
|
||||
|
||||
composer.Playfield.HitObjectUsageBegan += addBlueprintFor;
|
||||
composer.Playfield.HitObjectUsageFinished += removeBlueprintFor;
|
||||
Composer.Playfield.HitObjectUsageBegan += addBlueprintFor;
|
||||
Composer.Playfield.HitObjectUsageFinished += removeBlueprintFor;
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,7 +394,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
private void selectAll()
|
||||
{
|
||||
composer.Playfield.KeepAllAlive();
|
||||
Composer.Playfield.KeepAllAlive();
|
||||
|
||||
// Scheduled to allow the change in lifetime to take place.
|
||||
Schedule(() => SelectionBlueprints.ToList().ForEach(m => m.Select()));
|
||||
@ -409,7 +410,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
SelectionHandler.HandleSelected(blueprint);
|
||||
SelectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||
|
||||
composer.Playfield.SetKeepAlive(blueprint.HitObject, true);
|
||||
Composer.Playfield.SetKeepAlive(blueprint.HitObject, true);
|
||||
}
|
||||
|
||||
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
||||
@ -417,7 +418,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
SelectionHandler.HandleDeselected(blueprint);
|
||||
SelectionBlueprints.ChangeChildDepth(blueprint, 0);
|
||||
|
||||
composer.Playfield.SetKeepAlive(blueprint.HitObject, false);
|
||||
Composer.Playfield.SetKeepAlive(blueprint.HitObject, false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -512,10 +513,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
Beatmap.HitObjectRemoved -= removeBlueprintFor;
|
||||
}
|
||||
|
||||
if (composer != null)
|
||||
if (Composer != null)
|
||||
{
|
||||
composer.Playfield.HitObjectUsageBegan -= addBlueprintFor;
|
||||
composer.Playfield.HitObjectUsageFinished -= removeBlueprintFor;
|
||||
Composer.Playfield.HitObjectUsageBegan -= addBlueprintFor;
|
||||
Composer.Playfield.HitObjectUsageFinished -= removeBlueprintFor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
private readonly HitObjectComposer composer;
|
||||
private readonly Container<PlacementBlueprint> placementBlueprintContainer;
|
||||
|
||||
private PlacementBlueprint currentPlacement;
|
||||
@ -38,8 +37,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
public ComposeBlueprintContainer(HitObjectComposer composer)
|
||||
: base(composer)
|
||||
{
|
||||
this.composer = composer;
|
||||
|
||||
placementBlueprintContainer = new Container<PlacementBlueprint>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
@ -158,7 +155,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private void updatePlacementPosition()
|
||||
{
|
||||
var snapResult = composer.SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position);
|
||||
var snapResult = Composer.SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position);
|
||||
|
||||
currentPlacement.UpdatePosition(snapResult);
|
||||
}
|
||||
@ -169,7 +166,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (composer.CursorInPlacementArea)
|
||||
if (Composer.CursorInPlacementArea)
|
||||
createPlacement();
|
||||
else if (currentPlacement?.PlacementActive == false)
|
||||
removePlacement();
|
||||
@ -182,7 +179,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
||||
{
|
||||
var drawable = composer.HitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
||||
var drawable = Composer.HitObjects.FirstOrDefault(d => d.HitObject == hitObject);
|
||||
|
||||
if (drawable == null)
|
||||
return null;
|
||||
|
@ -219,6 +219,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[Resolved]
|
||||
private IBeatSnapProvider beatSnapProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total amount of time visible on the timeline.
|
||||
/// </summary>
|
||||
public double VisibleRange => track.Length / Zoom;
|
||||
|
||||
public SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) =>
|
||||
new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(getTimeFromPosition(Content.ToLocalSpace(screenSpacePosition))));
|
||||
|
||||
|
@ -26,9 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
private DragEvent lastDragEvent;
|
||||
|
||||
private Bindable<HitObject> placement;
|
||||
|
||||
private SelectionBlueprint placementBlueprint;
|
||||
|
||||
public TimelineBlueprintContainer(HitObjectComposer composer)
|
||||
@ -98,6 +96,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
if (lastDragEvent != null)
|
||||
OnDrag(lastDragEvent);
|
||||
|
||||
if (Composer != null)
|
||||
{
|
||||
Composer.Playfield.PastLifetimeExtension = timeline.VisibleRange / 2;
|
||||
Composer.Playfield.FutureLifetimeExtension = timeline.VisibleRange / 2;
|
||||
}
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user