mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 23:03:21 +08:00
Add AddHitObjectCommand
and RemoveHitObjectCommand
This commit is contained in:
parent
867e986240
commit
fe9e84b47d
@ -27,6 +27,7 @@ using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Commands;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osu.Game.Screens.Edit.Components.TernaryButtons;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
@ -483,20 +484,23 @@ namespace osu.Game.Rulesets.Edit
|
||||
EditorBeatmap.PlacementObject.Value = hitObject;
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private EditorCommandHandler commandHandler { get; set; }
|
||||
|
||||
public void EndPlacement(HitObject hitObject, bool commit)
|
||||
{
|
||||
EditorBeatmap.PlacementObject.Value = null;
|
||||
|
||||
if (commit)
|
||||
{
|
||||
EditorBeatmap.Add(hitObject);
|
||||
commandHandler.SafeSubmit(new AddHitObjectCommand(EditorBeatmap, hitObject), true);
|
||||
|
||||
if (autoSeekOnPlacement.Value && EditorClock.CurrentTime < hitObject.StartTime)
|
||||
EditorClock.SeekSmoothlyTo(hitObject.StartTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
||||
public void Delete(HitObject hitObject) => commandHandler.SafeSubmit(new RemoveHitObjectCommand(EditorBeatmap, hitObject));
|
||||
|
||||
#endregion
|
||||
|
||||
|
24
osu.Game/Screens/Edit/Commands/AddHitObjectCommand.cs
Normal file
24
osu.Game/Screens/Edit/Commands/AddHitObjectCommand.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Commands
|
||||
{
|
||||
public class AddHitObjectCommand : IEditorCommand
|
||||
{
|
||||
public EditorBeatmap Beatmap;
|
||||
|
||||
public HitObject HitObject;
|
||||
|
||||
public AddHitObjectCommand(EditorBeatmap beatmap, HitObject hitObject)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
public void Apply() => Beatmap.Add(HitObject);
|
||||
|
||||
public IEditorCommand CreateUndo() => new RemoveHitObjectCommand(Beatmap, HitObject);
|
||||
}
|
||||
}
|
24
osu.Game/Screens/Edit/Commands/RemoveHitObjectCommand.cs
Normal file
24
osu.Game/Screens/Edit/Commands/RemoveHitObjectCommand.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Commands
|
||||
{
|
||||
public class RemoveHitObjectCommand : IEditorCommand
|
||||
{
|
||||
public EditorBeatmap Beatmap;
|
||||
|
||||
public HitObject HitObject;
|
||||
|
||||
public RemoveHitObjectCommand(EditorBeatmap beatmap, HitObject hitObject)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
public void Apply() => Beatmap.Remove(HitObject);
|
||||
|
||||
public IEditorCommand CreateUndo() => new AddHitObjectCommand(Beatmap, HitObject);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user