From 84a1248234c7cee2cd30fb0edd11d80a6ab82d4f Mon Sep 17 00:00:00 2001 From: Goatgarien Date: Sun, 5 Feb 2023 23:15:48 -0800 Subject: [PATCH] Fixed issues around deleting the final 2 segments of a hold. --- BAKKA-Editor/MainForm.cs | 30 ++++++++++++++++++++++++ BAKKA-Editor/Operations/NoteOperation.cs | 21 +++++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/BAKKA-Editor/MainForm.cs b/BAKKA-Editor/MainForm.cs index 6ecffdf..d72ec30 100644 --- a/BAKKA-Editor/MainForm.cs +++ b/BAKKA-Editor/MainForm.cs @@ -1732,7 +1732,26 @@ namespace BAKKA_Editor int delIndex = selectedNoteIndex; NoteOperation op = chart.Notes[selectedNoteIndex].IsHold ? new RemoveHoldNote(chart, chart.Notes[selectedNoteIndex]) : new RemoveNote(chart, chart.Notes[selectedNoteIndex]); + NoteOperation op2 = null; + if (chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldStartBonusFlair || chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldStartNoBonus) + { + if(chart.Notes[selectedNoteIndex].NextNote.NoteType == NoteType.HoldEnd) + { + op2 = new RemoveHoldNote(chart, chart.Notes[selectedNoteIndex].NextNote); + } + } + if (chart.Notes[selectedNoteIndex].NoteType == NoteType.HoldEnd) + { + if (chart.Notes[selectedNoteIndex].PrevNote.NoteType == NoteType.HoldStartBonusFlair || chart.Notes[selectedNoteIndex].PrevNote.NoteType == NoteType.HoldStartNoBonus) + { + op2 = new RemoveHoldNote(chart, chart.Notes[selectedNoteIndex].PrevNote); + } + } opManager.InvokeAndPush(op); + if (op2 != null) + { + opManager.InvokeAndPush(op2); + } UpdateControlsFromOperation(op, OperationDirection.Redo); if (selectedNoteIndex == delIndex) { @@ -1853,6 +1872,17 @@ namespace BAKKA_Editor if (op != null) { UpdateControlsFromOperation(op, OperationDirection.Undo); + if (op.GetType() == typeof(RemoveHoldNote)) + { + foreach (var note in chart.Notes) + { + if (note.IsHold && note.NextNote == null && note.PrevNote == null) + { + undoToolStripMenuItem_Click(sender, e); + return; + } + } + } } } } diff --git a/BAKKA-Editor/Operations/NoteOperation.cs b/BAKKA-Editor/Operations/NoteOperation.cs index 154a73a..af9c72e 100644 --- a/BAKKA-Editor/Operations/NoteOperation.cs +++ b/BAKKA-Editor/Operations/NoteOperation.cs @@ -148,7 +148,8 @@ namespace BAKKA_Editor.Operations if (nextNote != null) { nextNote.PrevNote = null; - nextNote.NoteType = Note.NoteType; + if (nextNote.NoteType == NoteType.HoldJoint) + nextNote.NoteType = Note.NoteType; } break; case NoteType.HoldJoint: @@ -157,8 +158,11 @@ namespace BAKKA_Editor.Operations nextNote.PrevNote = prevNote; break; case NoteType.HoldEnd: - prevNote.NextNote = null; - prevNote.NoteType = NoteType.HoldEnd; + if (prevNote != null) + { + prevNote.NextNote = null; + prevNote.NoteType = NoteType.HoldEnd; + } break; default: break; @@ -184,13 +188,20 @@ namespace BAKKA_Editor.Operations nextNote.PrevNote = Note; break; case NoteType.HoldEnd: - prevNote.NextNote = Note; - prevNote.NoteType = prevNoteType; + if (prevNote != null) + { + prevNote.NextNote = Note; + prevNote.NoteType = prevNoteType; + } break; default: break; } Chart.Notes.Add(Note); + if (nextNote == null && prevNote == null) + { + //popAgain = true; + } } } }