mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge pull request #12437 from peppy/fix-editor-placement-commit-false
Fix placement blueprints not being correctly removed after a rolled back placement
This commit is contained in:
@ -82,7 +82,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.UpdateTimeAndPosition(result);
|
base.UpdateTimeAndPosition(result);
|
||||||
|
|
||||||
if (PlacementActive)
|
if (PlacementActive == PlacementState.Active)
|
||||||
{
|
{
|
||||||
if (result.Time is double endTime)
|
if (result.Time is double endTime)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.UpdateTimeAndPosition(result);
|
base.UpdateTimeAndPosition(result);
|
||||||
|
|
||||||
if (!PlacementActive)
|
if (PlacementActive == PlacementState.Waiting)
|
||||||
Column = result.Playfield as Column;
|
Column = result.Playfield as Column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
|
|
||||||
private PlacementState state;
|
private SliderPlacementState state;
|
||||||
private PathControlPoint segmentStart;
|
private PathControlPoint segmentStart;
|
||||||
private PathControlPoint cursor;
|
private PathControlPoint cursor;
|
||||||
private int currentSegmentLength;
|
private int currentSegmentLength;
|
||||||
@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
controlPointVisualiser = new PathControlPointVisualiser(HitObject, false)
|
controlPointVisualiser = new PathControlPointVisualiser(HitObject, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
setState(PlacementState.Initial);
|
setState(SliderPlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -73,12 +73,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Initial:
|
case SliderPlacementState.Initial:
|
||||||
BeginPlacement();
|
BeginPlacement();
|
||||||
HitObject.Position = ToLocalSpace(result.ScreenSpacePosition);
|
HitObject.Position = ToLocalSpace(result.ScreenSpacePosition);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlacementState.Body:
|
case SliderPlacementState.Body:
|
||||||
updateCursor();
|
updateCursor();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -91,11 +91,11 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Initial:
|
case SliderPlacementState.Initial:
|
||||||
beginCurve();
|
beginCurve();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlacementState.Body:
|
case SliderPlacementState.Body:
|
||||||
if (canPlaceNewControlPoint(out var lastPoint))
|
if (canPlaceNewControlPoint(out var lastPoint))
|
||||||
{
|
{
|
||||||
// Place a new point by detatching the current cursor.
|
// Place a new point by detatching the current cursor.
|
||||||
@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
|
|
||||||
protected override void OnMouseUp(MouseUpEvent e)
|
protected override void OnMouseUp(MouseUpEvent e)
|
||||||
{
|
{
|
||||||
if (state == PlacementState.Body && e.Button == MouseButton.Right)
|
if (state == SliderPlacementState.Body && e.Button == MouseButton.Right)
|
||||||
endCurve();
|
endCurve();
|
||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
private void beginCurve()
|
private void beginCurve()
|
||||||
{
|
{
|
||||||
BeginPlacement(commitStart: true);
|
BeginPlacement(commitStart: true);
|
||||||
setState(PlacementState.Body);
|
setState(SliderPlacementState.Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endCurve()
|
private void endCurve()
|
||||||
@ -219,12 +219,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
|||||||
tailCirclePiece.UpdateFrom(HitObject.TailCircle);
|
tailCirclePiece.UpdateFrom(HitObject.TailCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setState(PlacementState newState)
|
private void setState(SliderPlacementState newState)
|
||||||
{
|
{
|
||||||
state = newState;
|
state = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum PlacementState
|
private enum SliderPlacementState
|
||||||
{
|
{
|
||||||
Initial,
|
Initial,
|
||||||
Body,
|
Body,
|
||||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Edit.Blueprints
|
|||||||
{
|
{
|
||||||
base.UpdateTimeAndPosition(result);
|
base.UpdateTimeAndPosition(result);
|
||||||
|
|
||||||
if (PlacementActive)
|
if (PlacementActive == PlacementState.Active)
|
||||||
{
|
{
|
||||||
if (result.Time is double dragTime)
|
if (result.Time is double dragTime)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the <see cref="HitObject"/> is currently mid-placement, but has not necessarily finished being placed.
|
/// Whether the <see cref="HitObject"/> is currently mid-placement, but has not necessarily finished being placed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool PlacementActive { get; private set; }
|
public PlacementState PlacementActive { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="HitObject"/> that is being placed.
|
/// The <see cref="HitObject"/> that is being placed.
|
||||||
@ -72,7 +72,8 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
protected void BeginPlacement(bool commitStart = false)
|
protected void BeginPlacement(bool commitStart = false)
|
||||||
{
|
{
|
||||||
placementHandler.BeginPlacement(HitObject);
|
placementHandler.BeginPlacement(HitObject);
|
||||||
PlacementActive |= commitStart;
|
if (commitStart)
|
||||||
|
PlacementActive = PlacementState.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -82,10 +83,19 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <param name="commit">Whether the object should be committed.</param>
|
/// <param name="commit">Whether the object should be committed.</param>
|
||||||
public void EndPlacement(bool commit)
|
public void EndPlacement(bool commit)
|
||||||
{
|
{
|
||||||
if (!PlacementActive)
|
switch (PlacementActive)
|
||||||
BeginPlacement();
|
{
|
||||||
|
case PlacementState.Finished:
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PlacementState.Waiting:
|
||||||
|
// ensure placement was started before ending to make state handling simpler.
|
||||||
|
BeginPlacement();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
placementHandler.EndPlacement(HitObject, commit);
|
placementHandler.EndPlacement(HitObject, commit);
|
||||||
PlacementActive = false;
|
PlacementActive = PlacementState.Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -94,7 +104,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <param name="result">The snap result information.</param>
|
/// <param name="result">The snap result information.</param>
|
||||||
public virtual void UpdateTimeAndPosition(SnapResult result)
|
public virtual void UpdateTimeAndPosition(SnapResult result)
|
||||||
{
|
{
|
||||||
if (!PlacementActive)
|
if (PlacementActive == PlacementState.Waiting)
|
||||||
HitObject.StartTime = result.Time ?? EditorClock?.CurrentTime ?? Time.Current;
|
HitObject.StartTime = result.Time ?? EditorClock?.CurrentTime ?? Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,5 +135,12 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlacementState
|
||||||
|
{
|
||||||
|
Waiting,
|
||||||
|
Active,
|
||||||
|
Finished
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private void refreshTool()
|
private void refreshTool()
|
||||||
{
|
{
|
||||||
removePlacement();
|
removePlacement();
|
||||||
createPlacement();
|
ensurePlacementCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlacementPosition()
|
private void updatePlacementPosition()
|
||||||
@ -215,15 +215,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
if (Composer.CursorInPlacementArea)
|
|
||||||
createPlacement();
|
|
||||||
else if (currentPlacement?.PlacementActive == false)
|
|
||||||
removePlacement();
|
|
||||||
|
|
||||||
if (currentPlacement != null)
|
if (currentPlacement != null)
|
||||||
{
|
{
|
||||||
updatePlacementPosition();
|
switch (currentPlacement.PlacementActive)
|
||||||
|
{
|
||||||
|
case PlacementBlueprint.PlacementState.Waiting:
|
||||||
|
if (!Composer.CursorInPlacementArea)
|
||||||
|
removePlacement();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PlacementBlueprint.PlacementState.Finished:
|
||||||
|
removePlacement();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Composer.CursorInPlacementArea)
|
||||||
|
ensurePlacementCreated();
|
||||||
|
|
||||||
|
if (currentPlacement != null)
|
||||||
|
updatePlacementPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
protected sealed override SelectionBlueprint CreateBlueprintFor(HitObject hitObject)
|
||||||
@ -249,7 +260,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
NewCombo.Value = TernaryState.False;
|
NewCombo.Value = TernaryState.False;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPlacement()
|
private void ensurePlacementCreated()
|
||||||
{
|
{
|
||||||
if (currentPlacement != null) return;
|
if (currentPlacement != null) return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user