public static void PerformPreChartInsertCorrections(Note note, Chart chart, IList <BaseAction> subActions, bool extendedSustainsEnabled) { int index, length; SongObjectHelper.GetRange(chart.chartObjects, note.tick, note.tick, out index, out length); // Account for when adding an exact note as what's already in if (length > 0) { for (int i = index + length - 1; i >= index; --i) { Note overwriteNote = chart.chartObjects[i] as Note; if (overwriteNote == null) { continue; } bool sameFret = note.guitarFret == overwriteNote.guitarFret; bool isOverwritableOpenNote = (note.IsOpenNote() || overwriteNote.IsOpenNote()) && !Globals.drumMode; if (isOverwritableOpenNote || sameFret) { SongEditCommand.AddAndInvokeSubAction(new DeleteAction(overwriteNote), subActions); } } } }
// Deprecated: Handled by SongEditCommand.GenerateForcedFlagFixupCommands static void AutoForcedCheck(Chart chart, Note note, IList <BaseAction> subActions) { Note next = note.nextSeperateNote; if (next != null && (next.flags & Note.Flags.Forced) == Note.Flags.Forced && next.cannotBeForced) { Note.Flags flags = next.flags; flags &= ~Note.Flags.Forced; // Apply flags to chord foreach (Note chordNote in next.chord) { // Overwrite note flags Note.Flags flagsToPreserve = chordNote.flags & Note.PER_NOTE_FLAGS; if (!CompareChordFlags(chordNote.flags, flags)) { Note.Flags newFlags = CopyChordFlags(chordNote.flags, flags); Note newChordNote = new Note(chordNote.tick, chordNote.rawNote, chordNote.length, newFlags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(chordNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newChordNote), subActions); } } } }
public static void PerformPostChartInsertCorrections(Note note, IList <BaseAction> subActions, bool extendedSustainsEnabled) { Debug.Assert(note.chart != null, "Note has not been inserted into a chart"); Debug.Assert(note.song != null, "Note has not been inserted into a song"); Chart chart = note.chart; Song song = note.song; Note.Flags flags = note.flags; if (note.IsOpenNote()) { flags &= ~Note.Flags.Tap; } // Handled by SongEditCommand.GenerateForcedFlagFixupCommands //if (note.cannotBeForced) // flags &= ~Note.Flags.Forced; if (!AllowedToBeCymbal(note)) { flags &= ~Note.Flags.ProDrums_Cymbal; } if (!AllowedToBeDoubleKickIgnoreDifficulty(note)) { flags &= ~Note.Flags.DoubleKick; } flags &= ~Note.GetBannedFlagsForGameMode(chart.gameMode); // This may happen when copying and pasting notes between instruments etc if (flags != note.flags) { Note newNote = new Note(note.tick, note.rawNote, note.length, flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(note), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } // Apply flags to chord foreach (Note chordNote in note.chord) { // Overwrite note flags if (!CompareChordFlags(chordNote.flags, flags)) { Note.Flags newFlags = CopyChordFlags(chordNote.flags, flags); Note newChordNote = new Note(chordNote.tick, chordNote.rawNote, chordNote.length, newFlags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(chordNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newChordNote), subActions); } } CapNoteCheck(chart, note, subActions, song, extendedSustainsEnabled); ForwardCap(chart, note, subActions, song); // Handled by SongEditCommand.GenerateForcedFlagFixupCommands //AutoForcedCheck(chart, note, subActions); }
static void CapNoteCheck(Chart chart, Note noteToAdd, IList <BaseAction> subActions, Song song, bool extendedSustainsEnabled) { Note[] previousNotes = NoteFunctions.GetPreviousOfSustains(noteToAdd, extendedSustainsEnabled); if (!Globals.gameSettings.extendedSustainsEnabled) { // Cap all the notes foreach (Note prevNote in previousNotes) { uint newLength = prevNote.GetCappedLength(noteToAdd, song); if (prevNote.length != newLength) { Note newNote = new Note(prevNote.tick, prevNote.rawNote, newLength, prevNote.flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(prevNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } } foreach (Note chordNote in noteToAdd.chord) { uint newLength = noteToAdd.length; if (chordNote.length != newLength) { Note newNote = new Note(chordNote.tick, chordNote.rawNote, newLength, chordNote.flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(chordNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } } } else { // Cap only the sustain of the same fret type and open notes foreach (Note prevNote in previousNotes) { if ( #if OPEN_NOTES_BLOCK_EXTENDED_SUSTAINS noteToAdd.IsOpenNote() || #endif prevNote.guitarFret == noteToAdd.guitarFret ) { uint newLength = prevNote.GetCappedLength(noteToAdd, song); if (prevNote.length != newLength) { Note newNote = new Note(prevNote.tick, prevNote.rawNote, newLength, prevNote.flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(prevNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } } } } }
public static void PerformPostChartInsertCorrections(Note note, IList <BaseAction> subActions, bool extendedSustainsEnabled) { Debug.Assert(note.chart != null, "Note has not been inserted into a chart"); Debug.Assert(note.song != null, "Note has not been inserted into a song"); Chart chart = note.chart; Song song = note.song; Note.Flags flags = note.flags; if (note.IsOpenNote()) { flags &= ~Note.Flags.Tap; } if (note.cannotBeForced) { flags &= ~Note.Flags.Forced; } if (!AllowedToBeCymbal(note)) { flags &= ~Note.Flags.ProDrums_Cymbal; } if (flags != note.flags) { Note newNote = new Note(note.tick, note.rawNote, note.length, flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(note), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } // Apply flags to chord foreach (Note chordNote in note.chord) { // Overwrite note flags if (!CompareChordFlags(chordNote.flags, note.flags)) { Note.Flags newFlags = CopyChordFlags(chordNote.flags, note.flags); Note newChordNote = new Note(chordNote.tick, chordNote.rawNote, chordNote.length, newFlags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(chordNote), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newChordNote), subActions); } } CapNoteCheck(chart, note, subActions, song, extendedSustainsEnabled); ForwardCap(chart, note, subActions, song); AutoForcedCheck(chart, note, subActions); }
static void ForwardCap(Chart chart, Note note, IList <BaseAction> subActions, Song song) { Note next; next = note.nextSeperateNote; if (!GameSettings.extendedSustainsEnabled) { // Get chord next = note.nextSeperateNote; if (next != null) { foreach (Note noteToCap in note.chord) { uint newLength = noteToCap.GetCappedLength(next, song); if (noteToCap.length != newLength) { Note newNote = new Note(noteToCap.tick, noteToCap.rawNote, newLength, noteToCap.flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(noteToCap), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } } } } else { // Find the next note of the same fret type or open next = note.next; while (next != null && next.guitarFret != note.guitarFret && !next.IsOpenNote()) { next = next.next; } // If it's an open note it won't be capped if (next != null) { uint newLength = note.GetCappedLength(next, song); if (note.length != newLength) { Note newNote = new Note(note.tick, note.rawNote, newLength, note.flags); SongEditCommand.AddAndInvokeSubAction(new DeleteAction(note), subActions); SongEditCommand.AddAndInvokeSubAction(new AddAction(newNote), subActions); } } } }
public void Delete() { if (selectedObjectsManager.currentSelectedObjects.Count > 0) { SongEditCommand[] commands = new SongEditCommand[] { new SongEditDelete(selectedObjectsManager.currentSelectedObjects), }; BatchedSongEditCommand commandBatch = new BatchedSongEditCommand(commands); commandStack.Push(commandBatch); selectedObjectsManager.currentSelectedObject = null; groupSelect.reset(); } }