From b725ff2f00eaeb259cd7c5969b5d272895798b14 Mon Sep 17 00:00:00 2001 From: veroxzik <43590004+veroxzik@users.noreply.github.com> Date: Sat, 19 Nov 2022 18:38:17 -0500 Subject: [PATCH] fix: End of chart note behavior Notes cannot be placed after an 'end of chart' note. 'End of chart' notes cannot be placed before other notes or multiple times. --- BAKKA-Editor/MainForm.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/BAKKA-Editor/MainForm.cs b/BAKKA-Editor/MainForm.cs index 0b0f045..82fcedf 100644 --- a/BAKKA-Editor/MainForm.cs +++ b/BAKKA-Editor/MainForm.cs @@ -3,6 +3,7 @@ using System.Reflection; using IrrKlang; using BAKKA_Editor.Operations; using Tomlyn; +using System.Security.Cryptography.X509Certificates; namespace BAKKA_Editor { @@ -28,6 +29,7 @@ namespace BAKKA_Editor int selectedNoteIndex = -1; Note lastNote; Note? nextSelectedNote; // so that we know the last newly inserted note + Note? endOfChartNote; // Music ISoundEngine soundEngine = new ISoundEngine(); @@ -93,6 +95,7 @@ namespace BAKKA_Editor else if (selectedNoteIndex == -1 && chart.Notes.Count > 0) selectedNoteIndex = 0; UpdateNoteLabels(); + endOfChartNote = chart.Notes.FirstOrDefault(x => x.NoteType == NoteType.EndOfChart); if (selectedGimmickIndex >= chart.Gimmicks.Count) selectedGimmickIndex = chart.Gimmicks.Count - 1; else if (selectedGimmickIndex == -1 && chart.Gimmicks.Count > 0) @@ -596,6 +599,13 @@ namespace BAKKA_Editor else insertButton.Enabled = true; } + else if (endOfChartNote != null) + { + if (endOfChartNote.BeatInfo.MeasureDecimal <= circleView.CurrentMeasure) + insertButton.Enabled = false; + else + insertButton.Enabled = true; + } else if (currentSong != null && !currentSong.Paused) { insertButton.Enabled = false; @@ -1146,6 +1156,22 @@ namespace BAKKA_Editor else tempNote.MaskFill = MaskType.Center; break; + case NoteType.EndOfChart: + if (endOfChartNote != null) + { + MessageBox.Show("Cannot place more than one 'End of Chart' Note."); + return; + } + if (chart.Notes.Count > 0) + { + var finalNote = chart.Notes.Aggregate((agg, next) => next.BeatInfo.MeasureDecimal > agg.BeatInfo.MeasureDecimal ? next : agg); + if (finalNote != null && finalNote.BeatInfo.MeasureDecimal >= currentBeat.MeasureDecimal) + { + MessageBox.Show("Cannot place 'End of Chart' Note before another note."); + return; + } + } + break; default: break; }