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.
This commit is contained in:
veroxzik
2022-11-19 18:38:17 -05:00
parent 230b77fb4a
commit b725ff2f00
+26
View File
@@ -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;
}