2023-10-26 09:46:22 +00:00
|
|
|
package funkin.ui.debug.charting.commands;
|
|
|
|
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
|
|
|
import funkin.data.song.SongDataUtils;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes the given notes from the current chart in the chart editor.
|
|
|
|
* Use only when ONLY notes are being deleted.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class RemoveNotesCommand implements ChartEditorCommand
|
|
|
|
{
|
|
|
|
var notes:Array<SongNoteData>;
|
|
|
|
|
|
|
|
public function new(notes:Array<SongNoteData>)
|
|
|
|
{
|
|
|
|
this.notes = notes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(state:ChartEditorState):Void
|
|
|
|
{
|
2024-01-06 06:06:10 +00:00
|
|
|
if (notes.length == 0) return;
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
state.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, notes);
|
|
|
|
state.currentNoteSelection = [];
|
|
|
|
state.currentEventSelection = [];
|
|
|
|
|
|
|
|
state.playSound(Paths.sound('chartingSounds/noteErase'));
|
|
|
|
|
|
|
|
state.saveDataDirty = true;
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
state.notePreviewDirty = true;
|
|
|
|
|
|
|
|
state.sortChartData();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undo(state:ChartEditorState):Void
|
|
|
|
{
|
2024-01-06 06:06:10 +00:00
|
|
|
if (notes.length == 0) return;
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
for (note in notes)
|
|
|
|
{
|
|
|
|
state.currentSongChartNoteData.push(note);
|
|
|
|
}
|
|
|
|
state.currentNoteSelection = notes;
|
|
|
|
state.currentEventSelection = [];
|
|
|
|
state.playSound(Paths.sound('chartingSounds/undo'));
|
|
|
|
|
|
|
|
state.saveDataDirty = true;
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
state.notePreviewDirty = true;
|
|
|
|
|
|
|
|
state.sortChartData();
|
|
|
|
}
|
|
|
|
|
2024-01-04 13:20:34 +00:00
|
|
|
public function shouldAddToHistory(state:ChartEditorState):Bool
|
|
|
|
{
|
|
|
|
// This command is undoable. Add to the history if we actually performed an action.
|
|
|
|
return (notes.length > 0);
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public function toString():String
|
|
|
|
{
|
|
|
|
if (notes.length == 1 && notes[0] != null)
|
|
|
|
{
|
|
|
|
var dir:String = notes[0].getDirectionName();
|
|
|
|
return 'Remove $dir Note';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'Remove ${notes.length} Notes';
|
|
|
|
}
|
|
|
|
}
|