Change the way initial state saving works in EditorChangeHandler to be closer to first change

This commit is contained in:
Dean Herbert
2023-02-07 16:22:51 +09:00
parent dad348111d
commit e162fd56da
3 changed files with 16 additions and 4 deletions

View File

@ -26,9 +26,6 @@ namespace osu.Game.Screens.Edit
editorBeatmap.SaveStateTriggered += SaveState; editorBeatmap.SaveStateTriggered += SaveState;
patcher = new LegacyEditorBeatmapPatcher(editorBeatmap); patcher = new LegacyEditorBeatmapPatcher(editorBeatmap);
// Initial state.
SaveState();
} }
protected override void WriteCurrentStateToStream(MemoryStream stream) protected override void WriteCurrentStateToStream(MemoryStream stream)

View File

@ -31,6 +31,8 @@ namespace osu.Game.Screens.Edit
{ {
get get
{ {
ensureStateSaved();
using (var stream = new MemoryStream(savedStates[currentState])) using (var stream = new MemoryStream(savedStates[currentState]))
return stream.ComputeSHA2Hash(); return stream.ComputeSHA2Hash();
} }
@ -40,6 +42,19 @@ namespace osu.Game.Screens.Edit
public const int MAX_SAVED_STATES = 50; public const int MAX_SAVED_STATES = 50;
public override void BeginChange()
{
ensureStateSaved();
base.BeginChange();
}
private void ensureStateSaved()
{
if (savedStates.Count == 0)
SaveState();
}
protected override void UpdateState() protected override void UpdateState()
{ {
if (isRestoring) if (isRestoring)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit
/// <summary> /// <summary>
/// Signal the beginning of a change. /// Signal the beginning of a change.
/// </summary> /// </summary>
public void BeginChange() public virtual void BeginChange()
{ {
if (bulkChangesStarted++ == 0) if (bulkChangesStarted++ == 0)
TransactionBegan?.Invoke(); TransactionBegan?.Invoke();