mirror of https://github.com/ppy/osu
Change the way initial state saving works in `EditorChangeHandler` to be closer to first change
This commit is contained in:
parent
dad348111d
commit
e162fd56da
|
@ -26,9 +26,6 @@ public BeatmapEditorChangeHandler(EditorBeatmap editorBeatmap)
|
|||
editorBeatmap.SaveStateTriggered += SaveState;
|
||||
|
||||
patcher = new LegacyEditorBeatmapPatcher(editorBeatmap);
|
||||
|
||||
// Initial state.
|
||||
SaveState();
|
||||
}
|
||||
|
||||
protected override void WriteCurrentStateToStream(MemoryStream stream)
|
||||
|
|
|
@ -31,6 +31,8 @@ public string CurrentStateHash
|
|||
{
|
||||
get
|
||||
{
|
||||
ensureStateSaved();
|
||||
|
||||
using (var stream = new MemoryStream(savedStates[currentState]))
|
||||
return stream.ComputeSHA2Hash();
|
||||
}
|
||||
|
@ -40,6 +42,19 @@ public string CurrentStateHash
|
|||
|
||||
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()
|
||||
{
|
||||
if (isRestoring)
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract partial class TransactionalCommitComponent : Component
|
|||
/// <summary>
|
||||
/// Signal the beginning of a change.
|
||||
/// </summary>
|
||||
public void BeginChange()
|
||||
public virtual void BeginChange()
|
||||
{
|
||||
if (bulkChangesStarted++ == 0)
|
||||
TransactionBegan?.Invoke();
|
||||
|
|
Loading…
Reference in New Issue