mirror of
https://github.com/ppy/osu.git
synced 2025-02-03 14:22:55 +08:00
Fix tests
This commit is contained in:
parent
32d341a468
commit
269ade178e
@ -12,7 +12,6 @@ using osu.Framework.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -71,11 +70,11 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
|
||||
contentContainer.Playfield.HitObjectContainer.Add(hitObject);
|
||||
}
|
||||
|
||||
protected override SnapResult SnapForBlueprint(HitObjectPlacementBlueprint blueprint)
|
||||
protected override void UpdatePlacementTimeAndPosition()
|
||||
{
|
||||
var result = base.SnapForBlueprint(blueprint);
|
||||
result.Time = Math.Round(HitObjectContainer.TimeAtScreenSpacePosition(result.ScreenSpacePosition) / TIME_SNAP) * TIME_SNAP;
|
||||
return result;
|
||||
var position = InputManager.CurrentState.Mouse.Position;
|
||||
double time = Math.Round(HitObjectContainer.TimeAtScreenSpacePosition(position) / TIME_SNAP) * TIME_SNAP;
|
||||
CurrentBlueprint.UpdateTimeAndPosition(position, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
@ -47,12 +46,11 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
});
|
||||
}
|
||||
|
||||
protected override SnapResult SnapForBlueprint(HitObjectPlacementBlueprint blueprint)
|
||||
protected override void UpdatePlacementTimeAndPosition()
|
||||
{
|
||||
double time = column.TimeAtScreenSpacePosition(InputManager.CurrentState.Mouse.Position);
|
||||
var pos = column.ScreenSpacePositionAtTime(time);
|
||||
|
||||
return new SnapResult(pos, time, column);
|
||||
CurrentBlueprint.UpdateTimeAndPosition(pos, time);
|
||||
}
|
||||
|
||||
protected override Container CreateHitObjectContainer() => new ScrollingTestContainer(ScrollingDirection.Down) { RelativeSizeAxes = Axes.Both };
|
||||
|
@ -95,12 +95,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints
|
||||
base.OnDragEnd(e);
|
||||
}
|
||||
|
||||
public override SnapResult UpdateTimeAndPosition(Vector2 screenSpacePosition, double referenceTime)
|
||||
public override SnapResult UpdateTimeAndPosition(Vector2 screenSpacePosition, double fallbackTime)
|
||||
{
|
||||
if (State.Value == Visibility.Hidden)
|
||||
return new SnapResult(screenSpacePosition, referenceTime);
|
||||
return new SnapResult(screenSpacePosition, fallbackTime);
|
||||
|
||||
var result = hitObjectComposer?.TrySnapToNearbyObjects(screenSpacePosition) ?? new SnapResult(screenSpacePosition, referenceTime);
|
||||
var result = hitObjectComposer?.TrySnapToNearbyObjects(screenSpacePosition) ?? new SnapResult(screenSpacePosition, fallbackTime);
|
||||
|
||||
var pos = ToLocalSpace(result.ScreenSpacePosition);
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
|
||||
|
||||
public override SnapResult UpdateTimeAndPosition(Vector2 screenSpacePosition, double fallbackTime)
|
||||
{
|
||||
var result = composer?.TrySnapToNearbyObjects(screenSpacePosition)
|
||||
var result = composer?.TrySnapToNearbyObjects(screenSpacePosition, fallbackTime)
|
||||
?? composer?.TrySnapToDistanceGrid(screenSpacePosition)
|
||||
?? composer?.TrySnapToPositionGrid(screenSpacePosition)
|
||||
?? new SnapResult(screenSpacePosition, fallbackTime);
|
||||
|
@ -433,7 +433,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
||||
{
|
||||
// Special handling for selections containing head control point - the position of the hit object changes which means the snapped position and time have to be taken into account
|
||||
Vector2 newHeadPosition = Parent!.ToScreenSpace(e.MousePosition + (dragStartPositions[0] - dragStartPositions[draggedControlPointIndex]));
|
||||
SnapResult result = positionSnapProvider?.TrySnapToNearbyObjects(newHeadPosition)
|
||||
SnapResult result = positionSnapProvider?.TrySnapToNearbyObjects(newHeadPosition, oldStartTime)
|
||||
?? positionSnapProvider?.TrySnapToDistanceGrid(newHeadPosition)
|
||||
?? positionSnapProvider?.TrySnapToPositionGrid(newHeadPosition);
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
|
||||
public override SnapResult UpdateTimeAndPosition(Vector2 screenSpacePosition, double fallbackTime)
|
||||
{
|
||||
var result = composer?.TrySnapToNearbyObjects(screenSpacePosition)
|
||||
var result = composer?.TrySnapToNearbyObjects(screenSpacePosition, fallbackTime)
|
||||
?? composer?.TrySnapToDistanceGrid(screenSpacePosition)
|
||||
?? composer?.TrySnapToPositionGrid(screenSpacePosition)
|
||||
?? new SnapResult(screenSpacePosition, fallbackTime);
|
||||
|
@ -225,11 +225,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public SnapResult TrySnapToNearbyObjects(Vector2 screenSpacePosition)
|
||||
public SnapResult TrySnapToNearbyObjects(Vector2 screenSpacePosition, double? fallbackTime = null)
|
||||
{
|
||||
if (!snapToVisibleBlueprints(screenSpacePosition, out var snapResult))
|
||||
return null;
|
||||
|
||||
snapResult.Time ??= fallbackTime;
|
||||
|
||||
if (DistanceSnapProvider.DistanceSnapToggle.Value != TernaryState.True || distanceSnapGrid == null)
|
||||
return snapResult;
|
||||
|
||||
|
@ -113,7 +113,12 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
|
||||
protected override bool TryMoveBlueprints(DragEvent e, IList<(SelectionBlueprint<ISerialisableDrawable> blueprint, Vector2[] originalSnapPositions)> blueprints)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
Vector2 distanceTravelled = e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
||||
|
||||
// The final movement position, relative to movementBlueprintOriginalPosition.
|
||||
var referenceBlueprint = blueprints.First().blueprint;
|
||||
Vector2 movePosition = blueprints.First().originalSnapPositions.First() + distanceTravelled;
|
||||
return SelectionHandler.HandleMovement(new MoveSelectionEvent<ISerialisableDrawable>(referenceBlueprint, movePosition - referenceBlueprint.ScreenSpaceSelectionPoint));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// Updates the time and position of this <see cref="PlacementBlueprint"/> based on the provided snap information.
|
||||
/// </summary>
|
||||
/// <param name="result">The snap result information.</param>
|
||||
public void UpdateTimeAndPosition(SnapResult result)
|
||||
protected void UpdateTimeAndPosition(SnapResult result)
|
||||
{
|
||||
if (PlacementActive == PlacementState.Waiting)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Tests.Visual
|
||||
base.Content.Add(HitObjectContainer = CreateHitObjectContainer().With(c => c.Clock = new FramedClock(new StopwatchClock())));
|
||||
base.Content.Add(new MouseMovementInterceptor
|
||||
{
|
||||
MouseMoved = updatePlacementTimeAndPosition,
|
||||
MouseMoved = UpdatePlacementTimeAndPosition,
|
||||
});
|
||||
}
|
||||
|
||||
@ -93,13 +93,10 @@ namespace osu.Game.Tests.Visual
|
||||
if (CurrentBlueprint.PlacementActive == PlacementBlueprint.PlacementState.Finished)
|
||||
ResetPlacement();
|
||||
|
||||
updatePlacementTimeAndPosition();
|
||||
UpdatePlacementTimeAndPosition();
|
||||
}
|
||||
|
||||
private void updatePlacementTimeAndPosition() => CurrentBlueprint.UpdateTimeAndPosition(SnapForBlueprint(CurrentBlueprint));
|
||||
|
||||
protected virtual SnapResult SnapForBlueprint(HitObjectPlacementBlueprint blueprint) =>
|
||||
new SnapResult(InputManager.CurrentState.Mouse.Position, null);
|
||||
protected virtual void UpdatePlacementTimeAndPosition() => CurrentBlueprint.UpdateTimeAndPosition(InputManager.CurrentState.Mouse.Position, 0);
|
||||
|
||||
public override void Add(Drawable drawable)
|
||||
{
|
||||
@ -108,7 +105,7 @@ namespace osu.Game.Tests.Visual
|
||||
if (drawable is HitObjectPlacementBlueprint blueprint)
|
||||
{
|
||||
blueprint.Show();
|
||||
blueprint.UpdateTimeAndPosition(SnapForBlueprint(blueprint));
|
||||
UpdatePlacementTimeAndPosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user