Skip to content

Commit

Permalink
Replicate fix in PlacementBlueprintTestScene
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Aug 24, 2024
1 parent d5606d0 commit 04bcc71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void load()

AddInternal(new PlacementBlueprintPositionUpdater
{
UpdatePosition = updatePlacementPosition,
UpdatePosition = updatePlacementTimeAndPosition,
});
}

Expand Down Expand Up @@ -298,7 +298,7 @@ private void refreshTool()
ensurePlacementCreated();
}

private void updatePlacementPosition()
private void updatePlacementTimeAndPosition()
{
if (CurrentPlacement == null)
return;
Expand Down Expand Up @@ -336,7 +336,7 @@ protected override void Update()
ensurePlacementCreated();

if (CurrentPlacement != null)
updatePlacementPosition();
updatePlacementTimeAndPosition();
}

protected sealed override SelectionBlueprint<HitObject> CreateBlueprintFor(HitObject item)
Expand Down Expand Up @@ -373,7 +373,7 @@ private void ensurePlacementCreated()
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();

Expand Down Expand Up @@ -422,7 +422,7 @@ public HitObjectCompositionTool CurrentTool
/// This is necessary for touch input to work with editor, as tapping on the compose area issues both a mouse-move and mouse-down event in a single frame,
/// therefore requiring <see cref="SnapResult"/> to be updated before the blueprint handles the mouse-down event to finalise a placement (or begin a placement in the slider case).
/// </remarks>
private partial class PlacementBlueprintPositionUpdater : Drawable
public partial class PlacementBlueprintPositionUpdater : Drawable
{
public Action UpdatePosition;

Expand Down
14 changes: 12 additions & 2 deletions osu.Game/Tests/Visual/PlacementBlueprintTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Compose.Components;

namespace osu.Game.Tests.Visual
{
Expand Down Expand Up @@ -95,7 +96,14 @@ public TestPlacementHandler(Container contentContainer)
this.contentContainer = contentContainer;

RelativeSizeAxes = Axes.Both;
InternalChild = contentContainer;
InternalChildren = new Drawable[]
{
contentContainer,
new ComposeBlueprintContainer.PlacementBlueprintPositionUpdater
{
UpdatePosition = updatePlacementTimeAndPosition
}
};
}

public void BeginPlacement(HitObject hitObject)
Expand All @@ -120,7 +128,7 @@ public void ResetPlacement()
protected override void Update()
{
base.Update();
CurrentBlueprint.UpdateTimeAndPosition(SnapForBlueprint(CurrentBlueprint));
updatePlacementTimeAndPosition();
}

public void Delete(HitObject hitObject)
Expand All @@ -137,6 +145,8 @@ protected override void AddInternal(Drawable drawable)
blueprint.UpdateTimeAndPosition(SnapForBlueprint(blueprint));
}
}

private void updatePlacementTimeAndPosition() => CurrentBlueprint.UpdateTimeAndPosition(SnapForBlueprint(CurrentBlueprint));
}
}
}

0 comments on commit 04bcc71

Please sign in to comment.