mirror of https://github.com/ppy/osu
Fix placement blueprints not being correctly removed after a rolled back placement
This commit is contained in:
parent
5c0ef55691
commit
119c9b4294
|
@ -82,7 +82,7 @@ public override void UpdateTimeAndPosition(SnapResult result)
|
|||
{
|
||||
base.UpdateTimeAndPosition(result);
|
||||
|
||||
if (PlacementActive)
|
||||
if (PlacementActive == PlacementState.Active)
|
||||
{
|
||||
if (result.Time is double endTime)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,7 @@ public override void UpdateTimeAndPosition(SnapResult result)
|
|||
{
|
||||
base.UpdateTimeAndPosition(result);
|
||||
|
||||
if (!PlacementActive)
|
||||
if (PlacementActive == PlacementState.Waiting)
|
||||
Column = result.Playfield as Column;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public override void UpdateTimeAndPosition(SnapResult result)
|
|||
{
|
||||
base.UpdateTimeAndPosition(result);
|
||||
|
||||
if (PlacementActive)
|
||||
if (PlacementActive == PlacementState.Active)
|
||||
{
|
||||
if (result.Time is double dragTime)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public abstract class PlacementBlueprint : CompositeDrawable
|
|||
/// <summary>
|
||||
/// Whether the <see cref="HitObject"/> is currently mid-placement, but has not necessarily finished being placed.
|
||||
/// </summary>
|
||||
public bool PlacementActive { get; private set; }
|
||||
public PlacementState PlacementActive { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HitObject"/> that is being placed.
|
||||
|
@ -72,7 +72,8 @@ private void load(IBindable<WorkingBeatmap> beatmap)
|
|||
protected void BeginPlacement(bool commitStart = false)
|
||||
{
|
||||
placementHandler.BeginPlacement(HitObject);
|
||||
PlacementActive |= commitStart;
|
||||
if (commitStart)
|
||||
PlacementActive = PlacementState.Active;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -82,10 +83,19 @@ protected void BeginPlacement(bool commitStart = false)
|
|||
/// <param name="commit">Whether the object should be committed.</param>
|
||||
public void EndPlacement(bool commit)
|
||||
{
|
||||
if (!PlacementActive)
|
||||
BeginPlacement();
|
||||
switch (PlacementActive)
|
||||
{
|
||||
case PlacementState.Finished:
|
||||
return;
|
||||
|
||||
case PlacementState.Waiting:
|
||||
// ensure placement was started before ending to make state handling simpler.
|
||||
BeginPlacement();
|
||||
break;
|
||||
}
|
||||
|
||||
placementHandler.EndPlacement(HitObject, commit);
|
||||
PlacementActive = false;
|
||||
PlacementActive = PlacementState.Finished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -94,7 +104,7 @@ public void EndPlacement(bool commit)
|
|||
/// <param name="result">The snap result information.</param>
|
||||
public virtual void UpdateTimeAndPosition(SnapResult result)
|
||||
{
|
||||
if (!PlacementActive)
|
||||
if (PlacementActive == PlacementState.Waiting)
|
||||
HitObject.StartTime = result.Time ?? EditorClock?.CurrentTime ?? Time.Current;
|
||||
}
|
||||
|
||||
|
@ -125,5 +135,12 @@ protected override bool Handle(UIEvent e)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PlacementState
|
||||
{
|
||||
Waiting,
|
||||
Active,
|
||||
Finished
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ private Drawable getIconForSample(string sampleName)
|
|||
private void refreshTool()
|
||||
{
|
||||
removePlacement();
|
||||
createPlacement();
|
||||
ensurePlacementCreated();
|
||||
}
|
||||
|
||||
private void updatePlacementPosition()
|
||||
|
@ -215,15 +215,26 @@ protected override void Update()
|
|||
{
|
||||
base.Update();
|
||||
|
||||
if (Composer.CursorInPlacementArea)
|
||||
createPlacement();
|
||||
else if (currentPlacement?.PlacementActive == false)
|
||||
removePlacement();
|
||||
|
||||
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)
|
||||
|
@ -249,7 +260,7 @@ protected override void OnBlueprintAdded(HitObject hitObject)
|
|||
NewCombo.Value = TernaryState.False;
|
||||
}
|
||||
|
||||
private void createPlacement()
|
||||
private void ensurePlacementCreated()
|
||||
{
|
||||
if (currentPlacement != null) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue