mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 16:12:57 +08:00
Merge branch 'master' into editor-show-selected-count
This commit is contained in:
commit
288c0402ee
@ -175,13 +175,13 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("Time = 50", () => Clock.CurrentTime == 50);
|
||||
AddStep("Seek(49.999)", () => Clock.Seek(49.999));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddAssert("Time = 50", () => Clock.CurrentTime == 50);
|
||||
AddAssert("Time = 100", () => Clock.CurrentTime == 100);
|
||||
AddStep("Seek(99)", () => Clock.Seek(99));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddAssert("Time = 100", () => Clock.CurrentTime == 100);
|
||||
AddStep("Seek(99.999)", () => Clock.Seek(99.999));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddAssert("Time = 100", () => Clock.CurrentTime == 100);
|
||||
AddAssert("Time = 100", () => Clock.CurrentTime == 150);
|
||||
AddStep("Seek(174)", () => Clock.Seek(174));
|
||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
||||
AddAssert("Time = 175", () => Clock.CurrentTime == 175);
|
||||
|
@ -122,14 +122,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return e.Button == MouseButton.Left;
|
||||
}
|
||||
|
||||
private SelectionBlueprint clickedBlueprint;
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (e.Button == MouseButton.Right)
|
||||
return false;
|
||||
|
||||
// store for double-click handling
|
||||
clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
|
||||
|
||||
// Deselection should only occur if no selected blueprints are hovered
|
||||
// A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection
|
||||
if (endClickSelection() || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
|
||||
if (endClickSelection() || clickedBlueprint != null)
|
||||
return true;
|
||||
|
||||
deselectAll();
|
||||
@ -141,9 +146,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (e.Button == MouseButton.Right)
|
||||
return false;
|
||||
|
||||
SelectionBlueprint clickedBlueprint = selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered);
|
||||
|
||||
if (clickedBlueprint == null)
|
||||
// ensure the blueprint which was hovered for the first click is still the hovered blueprint.
|
||||
if (clickedBlueprint == null || selectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint)
|
||||
return false;
|
||||
|
||||
editorClock?.SeekTo(clickedBlueprint.HitObject.StartTime);
|
||||
|
@ -275,11 +275,22 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
scrollAccumulation += (e.ScrollDelta.X + e.ScrollDelta.Y) * (e.IsPrecise ? 0.1 : 1);
|
||||
const double precision = 1;
|
||||
|
||||
const int precision = 1;
|
||||
double scrollComponent = e.ScrollDelta.X + e.ScrollDelta.Y;
|
||||
|
||||
while (Math.Abs(scrollAccumulation) > precision)
|
||||
double scrollDirection = Math.Sign(scrollComponent);
|
||||
|
||||
// this is a special case to handle the "pivot" scenario.
|
||||
// if we are precise scrolling in one direction then change our mind and scroll backwards,
|
||||
// the existing accumulation should be applied in the inverse direction to maintain responsiveness.
|
||||
if (Math.Sign(scrollAccumulation) != scrollDirection)
|
||||
scrollAccumulation = scrollDirection * (precision - Math.Abs(scrollAccumulation));
|
||||
|
||||
scrollAccumulation += scrollComponent * (e.IsPrecise ? 0.1 : 1);
|
||||
|
||||
// because we are doing snapped seeking, we need to add up precise scrolls until they accumulate to an arbitrary cut-off.
|
||||
while (Math.Abs(scrollAccumulation) >= precision)
|
||||
{
|
||||
if (scrollAccumulation > 0)
|
||||
seek(e, -1);
|
||||
|
@ -118,9 +118,14 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
seekTime = timingPoint.Time + closestBeat * seekAmount;
|
||||
|
||||
// limit forward seeking to only up to the next timing point's start time.
|
||||
var nextTimingPoint = ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time);
|
||||
if (seekTime > nextTimingPoint?.Time)
|
||||
seekTime = nextTimingPoint.Time;
|
||||
|
||||
// Due to the rounding above, we may end up on the current beat. This will effectively cause 0 seeking to happen, but we don't want this.
|
||||
// Instead, we'll go to the next beat in the direction when this is the case
|
||||
if (Precision.AlmostEquals(current, seekTime))
|
||||
if (Precision.AlmostEquals(current, seekTime, 0.5f))
|
||||
{
|
||||
closestBeat += direction > 0 ? 1 : -1;
|
||||
seekTime = timingPoint.Time + closestBeat * seekAmount;
|
||||
@ -129,10 +134,6 @@ namespace osu.Game.Screens.Edit
|
||||
if (seekTime < timingPoint.Time && timingPoint != ControlPointInfo.TimingPoints.First())
|
||||
seekTime = timingPoint.Time;
|
||||
|
||||
var nextTimingPoint = ControlPointInfo.TimingPoints.FirstOrDefault(t => t.Time > timingPoint.Time);
|
||||
if (seekTime > nextTimingPoint?.Time)
|
||||
seekTime = nextTimingPoint.Time;
|
||||
|
||||
// Ensure the sought point is within the boundaries
|
||||
seekTime = Math.Clamp(seekTime, 0, TrackLength);
|
||||
SeekTo(seekTime);
|
||||
|
Loading…
Reference in New Issue
Block a user