package funkin.ui.debug.charting.commands; import funkin.data.song.SongData.SongEventData; import funkin.data.song.SongDataUtils; /** * Adds the given events to the current chart in the chart editor. */ @:nullSafety @:access(funkin.ui.debug.charting.ChartEditorState) class AddEventsCommand implements ChartEditorCommand { var events:Array; var appendToSelection:Bool; public function new(events:Array, appendToSelection:Bool = false) { this.events = events; this.appendToSelection = appendToSelection; } public function execute(state:ChartEditorState):Void { for (event in events) { state.currentSongChartEventData.push(event); } if (appendToSelection) { state.currentEventSelection = state.currentEventSelection.concat(events); } else { state.currentNoteSelection = []; state.currentEventSelection = events; } state.playSound(Paths.sound('chartingSounds/noteLay')); state.saveDataDirty = true; state.noteDisplayDirty = true; state.notePreviewDirty = true; state.sortChartData(); } public function undo(state:ChartEditorState):Void { state.currentSongChartEventData = SongDataUtils.subtractEvents(state.currentSongChartEventData, events); state.currentNoteSelection = []; state.currentEventSelection = []; state.saveDataDirty = true; state.noteDisplayDirty = true; state.notePreviewDirty = true; state.sortChartData(); } public function toString():String { var len:Int = events.length; return 'Add $len Events'; } }