2020-04-09 20:22:07 +08:00
// 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.
2020-10-02 14:44:32 +08:00
using System ;
2023-02-03 17:53:22 +08:00
using osu.Framework.Allocation ;
2020-04-09 20:22:07 +08:00
using osu.Game.Rulesets.Objects ;
namespace osu.Game.Screens.Edit
{
/// <summary>
/// Interface for a component that manages changes in the <see cref="Editor"/>.
/// </summary>
2023-02-03 17:53:22 +08:00
[Cached]
2020-04-09 20:22:07 +08:00
public interface IEditorChangeHandler
{
2020-10-02 14:44:32 +08:00
/// <summary>
/// Fired whenever a state change occurs.
/// </summary>
2023-02-03 17:53:22 +08:00
event Action ? OnStateChange ;
2020-10-02 14:44:32 +08:00
2020-04-09 20:22:07 +08:00
/// <summary>
/// Begins a bulk state change event. <see cref="EndChange"/> should be invoked soon after.
/// </summary>
/// <remarks>
/// This should be invoked when multiple changes to the <see cref="Editor"/> should be bundled together into one state change event.
/// When nested invocations are involved, a state change will not occur until an equal number of invocations of <see cref="EndChange"/> are received.
/// </remarks>
/// <example>
/// When a group of <see cref="HitObject"/>s are deleted, a single undo and redo state change should update the state of all <see cref="HitObject"/>.
/// </example>
void BeginChange ( ) ;
/// <summary>
/// Ends a bulk state change event.
/// </summary>
/// <remarks>
/// This should be invoked as soon as possible after <see cref="BeginChange"/> to cause a state change.
/// </remarks>
void EndChange ( ) ;
2020-10-02 16:15:28 +08:00
/// <summary>
/// Immediately saves the current <see cref="Editor"/> state.
/// Note that this will be a no-op if there is a change in progress via <see cref="BeginChange"/>.
/// </summary>
void SaveState ( ) ;
2024-06-11 17:31:30 +08:00
/// <summary>
/// Restores an older or newer state.
/// </summary>
/// <param name="direction">The direction to restore in. If less than 0, an older state will be used. If greater than 0, a newer state will be used.</param>
void RestoreState ( int direction ) ;
2020-04-09 20:22:07 +08:00
}
}