2023-10-26 09:46:22 +00:00
|
|
|
package funkin.ui.debug.charting.commands;
|
|
|
|
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command that deselects all selected notes and events in the chart editor.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class DeselectAllItemsCommand implements ChartEditorCommand
|
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
var previousNoteSelection:Array<SongNoteData> = [];
|
|
|
|
var previousEventSelection:Array<SongEventData> = [];
|
2023-10-26 09:46:22 +00:00
|
|
|
|
2024-01-04 13:20:34 +00:00
|
|
|
public function new() {}
|
2023-10-26 09:46:22 +00:00
|
|
|
|
|
|
|
public function execute(state:ChartEditorState):Void
|
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
this.previousNoteSelection = state.currentNoteSelection;
|
|
|
|
this.previousEventSelection = state.currentEventSelection;
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
state.currentNoteSelection = [];
|
|
|
|
state.currentEventSelection = [];
|
|
|
|
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undo(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
state.currentNoteSelection = previousNoteSelection;
|
|
|
|
state.currentEventSelection = previousEventSelection;
|
|
|
|
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
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 (previousNoteSelection.length > 0 || previousEventSelection.length > 0);
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public function toString():String
|
|
|
|
{
|
|
|
|
return 'Deselect All Items';
|
|
|
|
}
|
|
|
|
}
|