Add commit status to EndPlacement; call BeginPlacement on initial movement

This commit is contained in:
Dean Herbert 2020-02-07 18:02:48 +09:00
parent 66f5ad4adb
commit e31d69c749
9 changed files with 22 additions and 12 deletions

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
protected override void OnMouseUp(MouseUpEvent e) protected override void OnMouseUp(MouseUpEvent e)
{ {
EndPlacement(); EndPlacement(true);
base.OnMouseUp(e); base.OnMouseUp(e);
} }

View File

@ -30,12 +30,13 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
EndPlacement(); EndPlacement(true);
return true; return true;
} }
public override void UpdatePosition(Vector2 screenSpacePosition) public override void UpdatePosition(Vector2 screenSpacePosition)
{ {
BeginPlacement();
HitObject.Position = ToLocalSpace(screenSpacePosition); HitObject.Position = ToLocalSpace(screenSpacePosition);
} }
} }

View File

@ -68,6 +68,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
switch (state) switch (state)
{ {
case PlacementState.Initial: case PlacementState.Initial:
BeginPlacement();
HitObject.Position = ToLocalSpace(screenSpacePosition); HitObject.Position = ToLocalSpace(screenSpacePosition);
break; break;
@ -132,7 +133,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private void endCurve() private void endCurve()
{ {
updateSlider(); updateSlider();
EndPlacement(); EndPlacement(true);
} }
protected override void Update() protected override void Update()

View File

@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners
if (isPlacingEnd) if (isPlacingEnd)
{ {
HitObject.EndTime = EditorClock.CurrentTime; HitObject.EndTime = EditorClock.CurrentTime;
EndPlacement(); EndPlacement(true);
} }
else else
{ {

View File

@ -254,11 +254,14 @@ namespace osu.Game.Rulesets.Edit
hitObject.StartTime = GetSnappedPosition(distanceSnapGrid.ToLocalSpace(inputManager.CurrentState.Mouse.Position), hitObject.StartTime).time; hitObject.StartTime = GetSnappedPosition(distanceSnapGrid.ToLocalSpace(inputManager.CurrentState.Mouse.Position), hitObject.StartTime).time;
} }
public void EndPlacement(HitObject hitObject) public void EndPlacement(HitObject hitObject, bool commit)
{ {
EditorBeatmap.Add(hitObject); if (commit)
{
EditorBeatmap.Add(hitObject);
adjustableClock.Seek(hitObject.StartTime); adjustableClock.Seek(hitObject.StartTime);
}
showGridFor(Enumerable.Empty<HitObject>()); showGridFor(Enumerable.Empty<HitObject>());
} }

View File

@ -103,11 +103,12 @@ namespace osu.Game.Rulesets.Edit
/// Signals that the placement of <see cref="HitObject"/> has finished. /// Signals that the placement of <see cref="HitObject"/> has finished.
/// This will destroy this <see cref="PlacementBlueprint"/>, and add the <see cref="HitObject"/> to the <see cref="Beatmap"/>. /// This will destroy this <see cref="PlacementBlueprint"/>, and add the <see cref="HitObject"/> to the <see cref="Beatmap"/>.
/// </summary> /// </summary>
protected void EndPlacement() /// <param name="commit">Whether the object should be committed.</param>
public void EndPlacement(bool commit)
{ {
if (!PlacementBegun) if (!PlacementBegun)
BeginPlacement(); BeginPlacement();
placementHandler.EndPlacement(HitObject); placementHandler.EndPlacement(HitObject, commit);
} }
/// <summary> /// <summary>

View File

@ -63,6 +63,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void refreshTool() private void refreshTool()
{ {
placementBlueprintContainer.Clear(); placementBlueprintContainer.Clear();
currentPlacement?.EndPlacement(false);
currentPlacement = null; currentPlacement = null;
var blueprint = CurrentTool?.CreatePlacementBlueprint(); var blueprint = CurrentTool?.CreatePlacementBlueprint();

View File

@ -17,7 +17,8 @@ namespace osu.Game.Screens.Edit.Compose
/// Notifies that a placement has finished. /// Notifies that a placement has finished.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> that has been placed.</param> /// <param name="hitObject">The <see cref="HitObject"/> that has been placed.</param>
void EndPlacement(HitObject hitObject); /// <param name="commit">Whether the object should be committed.</param>
void EndPlacement(HitObject hitObject, bool commit);
/// <summary> /// <summary>
/// Deletes a <see cref="HitObject"/>. /// Deletes a <see cref="HitObject"/>.

View File

@ -53,9 +53,10 @@ namespace osu.Game.Tests.Visual
{ {
} }
public void EndPlacement(HitObject hitObject) public void EndPlacement(HitObject hitObject, bool commit)
{ {
AddHitObject(CreateHitObject(hitObject)); if (commit)
AddHitObject(CreateHitObject(hitObject));
Remove(currentBlueprint); Remove(currentBlueprint);
Add(currentBlueprint = CreateBlueprint()); Add(currentBlueprint = CreateBlueprint());