mirror of
https://github.com/ppy/osu.git
synced 2024-12-17 02:12:56 +08:00
Fix placement blueprints not receiving latest mouse position with touch input
This commit is contained in:
parent
86b240d131
commit
f8c8184c5c
@ -295,8 +295,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
ensurePlacementCreated();
|
||||
}
|
||||
|
||||
private void updatePlacementPosition()
|
||||
private void updatePlacementTimeAndPosition()
|
||||
{
|
||||
if (CurrentPlacement == null)
|
||||
return;
|
||||
|
||||
var snapResult = Composer.FindSnappedPositionAndTime(InputManager.CurrentState.Mouse.Position, CurrentPlacement.SnapType);
|
||||
|
||||
// if no time was found from positional snapping, we should still quantize to the beat.
|
||||
@ -329,8 +332,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (Composer.CursorInPlacementArea)
|
||||
ensurePlacementCreated();
|
||||
|
||||
if (CurrentPlacement != null)
|
||||
updatePlacementPosition();
|
||||
// updates the placement with the latest editor clock time.
|
||||
updatePlacementTimeAndPosition();
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
// updates the placement with the latest mouse position.
|
||||
updatePlacementTimeAndPosition();
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected sealed override SelectionBlueprint<HitObject> CreateBlueprintFor(HitObject item)
|
||||
@ -367,7 +377,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
placementBlueprintContainer.Child = CurrentPlacement = blueprint;
|
||||
|
||||
// Fixes a 1-frame position discrepancy due to the first mouse move event happening in the next frame
|
||||
updatePlacementPosition();
|
||||
updatePlacementTimeAndPosition();
|
||||
|
||||
updatePlacementSamples();
|
||||
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -24,6 +26,10 @@ namespace osu.Game.Tests.Visual
|
||||
protected PlacementBlueprintTestScene()
|
||||
{
|
||||
base.Content.Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
|
||||
base.Content.Add(new MouseMovementInterceptor
|
||||
{
|
||||
MouseMoved = updatePlacementTimeAndPosition,
|
||||
});
|
||||
}
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
@ -83,10 +89,11 @@ namespace osu.Game.Tests.Visual
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
CurrentBlueprint.UpdateTimeAndPosition(SnapForBlueprint(CurrentBlueprint));
|
||||
updatePlacementTimeAndPosition();
|
||||
}
|
||||
|
||||
private void updatePlacementTimeAndPosition() => CurrentBlueprint.UpdateTimeAndPosition(SnapForBlueprint(CurrentBlueprint));
|
||||
|
||||
protected virtual SnapResult SnapForBlueprint(HitObjectPlacementBlueprint blueprint) =>
|
||||
new SnapResult(InputManager.CurrentState.Mouse.Position, null);
|
||||
|
||||
@ -107,5 +114,22 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected abstract DrawableHitObject CreateHitObject(HitObject hitObject);
|
||||
protected abstract HitObjectPlacementBlueprint CreateBlueprint();
|
||||
|
||||
private partial class MouseMovementInterceptor : Drawable
|
||||
{
|
||||
public Action MouseMoved;
|
||||
|
||||
public MouseMovementInterceptor()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
Depth = float.MinValue;
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
MouseMoved?.Invoke();
|
||||
return base.OnMouseMove(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user