2023-10-26 05:46:22 -04:00
|
|
|
package funkin.ui.debug.charting.commands;
|
|
|
|
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
|
|
|
import funkin.data.song.SongData.SongEventData;
|
|
|
|
import funkin.data.song.SongDataUtils;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command to deselect all items that are currently selected in the chart editor,
|
|
|
|
* then select all the items that were previously unselected.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class InvertSelectedItemsCommand implements ChartEditorCommand
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
var previousNoteSelection:Array<SongNoteData> = [];
|
|
|
|
var previousEventSelection:Array<SongEventData> = [];
|
2023-10-26 05:46:22 -04:00
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
public function new() {}
|
2023-10-26 05:46:22 -04:00
|
|
|
|
|
|
|
public function execute(state:ChartEditorState):Void
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
this.previousNoteSelection = state.currentNoteSelection;
|
|
|
|
this.previousEventSelection = state.currentEventSelection;
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
state.currentNoteSelection = SongDataUtils.subtractNotes(state.currentSongChartNoteData, previousNoteSelection);
|
|
|
|
state.currentEventSelection = SongDataUtils.subtractEvents(state.currentSongChartEventData, previousEventSelection);
|
2024-01-04 08:20:34 -05:00
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undo(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
state.currentNoteSelection = previousNoteSelection;
|
|
|
|
state.currentEventSelection = previousEventSelection;
|
|
|
|
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
}
|
|
|
|
|
2024-01-04 08:20:34 -05: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 05:46:22 -04:00
|
|
|
public function toString():String
|
|
|
|
{
|
|
|
|
return 'Invert Selected Items';
|
|
|
|
}
|
|
|
|
}
|