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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command to set the current selection in the chart editor (rather than appending it).
|
|
|
|
* Deselects any notes that are not in the new selection.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class SetItemSelectionCommand implements ChartEditorCommand
|
|
|
|
{
|
|
|
|
var notes:Array<SongNoteData>;
|
|
|
|
var events:Array<SongEventData>;
|
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(notes:Array<SongNoteData>, events:Array<SongEventData>)
|
2023-10-26 05:46:22 -04:00
|
|
|
{
|
|
|
|
this.notes = notes;
|
|
|
|
this.events = events;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 = notes;
|
|
|
|
state.currentEventSelection = events;
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
// Add to the history if we actually performed an action.
|
|
|
|
return (state.currentNoteSelection != previousNoteSelection && state.currentEventSelection != previousEventSelection);
|
|
|
|
}
|
|
|
|
|
2023-10-26 05:46:22 -04:00
|
|
|
public function toString():String
|
|
|
|
{
|
2024-01-04 08:20:34 -05:00
|
|
|
return 'Select ${notes.length + events.length} Items';
|
2023-10-26 05:46:22 -04:00
|
|
|
}
|
|
|
|
}
|