1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 03:03:05 +08:00

Add PlacementStarted event, rename placement methods

This commit is contained in:
smoogipoo 2018-10-17 14:37:39 +09:00
parent f384c7228e
commit 08e3fe1def
2 changed files with 27 additions and 3 deletions

View File

@ -33,7 +33,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
{ {
HitObject.StartTime = EditorClock.CurrentTime; HitObject.StartTime = EditorClock.CurrentTime;
HitObject.Position = e.MousePosition; HitObject.Position = e.MousePosition;
Finish();
EndPlacement();
return true; return true;
} }

View File

@ -15,6 +15,11 @@ namespace osu.Game.Rulesets.Edit
{ {
public class PlacementMask : CompositeDrawable, IRequireHighFrequencyMousePosition public class PlacementMask : CompositeDrawable, IRequireHighFrequencyMousePosition
{ {
/// <summary>
/// Invoked when the placement of <see cref="HitObject"/> has started.
/// </summary>
public event Action<HitObject> PlacementStarted;
/// <summary> /// <summary>
/// Invoked when the placement of <see cref="HitObject"/> has finished. /// Invoked when the placement of <see cref="HitObject"/> has finished.
/// </summary> /// </summary>
@ -40,10 +45,27 @@ namespace osu.Game.Rulesets.Edit
HitObject.ApplyDefaults(workingBeatmap.Value.Beatmap.ControlPointInfo, workingBeatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty); HitObject.ApplyDefaults(workingBeatmap.Value.Beatmap.ControlPointInfo, workingBeatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty);
} }
private bool placementBegun;
/// <summary> /// <summary>
/// Finishes the placement of <see cref="HitObject"/>. /// Signals that the placement of <see cref="HitObject"/> has started.
/// </summary> /// </summary>
public void Finish() => PlacementFinished?.Invoke(HitObject); protected void BeginPlacement()
{
PlacementStarted?.Invoke(HitObject);
placementBegun = true;
}
/// <summary>
/// Signals that the placement of <see cref="HitObject"/> has finished.
/// This will destroy this <see cref="PlacementMask"/>, and add the <see cref="HitObject"/> to the <see cref="Beatmap"/>.
/// </summary>
protected void EndPlacement()
{
if (!placementBegun)
BeginPlacement();
PlacementFinished?.Invoke(HitObject);
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false;
@ -64,6 +86,7 @@ namespace osu.Game.Rulesets.Edit
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);
PlacementStarted = null;
PlacementFinished = null; PlacementFinished = null;
} }
} }