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 to set the selection to all notes and events in the chart editor.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class SelectAllItemsCommand implements ChartEditorCommand
|
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
var shouldSelectNotes:Bool;
|
|
|
|
var shouldSelectEvents:Bool;
|
2023-10-26 09:46:22 +00:00
|
|
|
|
2024-01-04 13:20:34 +00:00
|
|
|
var previousNoteSelection:Array<SongNoteData> = [];
|
|
|
|
var previousEventSelection:Array<SongEventData> = [];
|
|
|
|
|
|
|
|
public function new(shouldSelectNotes:Bool, shouldSelectEvents:Bool)
|
2023-10-26 09:46:22 +00:00
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
this.shouldSelectNotes = shouldSelectNotes;
|
|
|
|
this.shouldSelectEvents = shouldSelectEvents;
|
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;
|
|
|
|
|
|
|
|
state.currentNoteSelection = shouldSelectNotes ? state.currentSongChartNoteData : [];
|
|
|
|
state.currentEventSelection = shouldSelectEvents ? state.currentSongChartEventData : [];
|
2023-10-26 09:46:22 +00:00
|
|
|
|
|
|
|
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 (state.currentNoteSelection.length > 0 || state.currentEventSelection.length > 0);
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public function toString():String
|
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
if (shouldSelectNotes && !shouldSelectEvents)
|
|
|
|
{
|
|
|
|
return 'Select All Notes';
|
|
|
|
}
|
|
|
|
else if (shouldSelectEvents && !shouldSelectNotes)
|
|
|
|
{
|
|
|
|
return 'Select All Events';
|
|
|
|
}
|
|
|
|
else if (shouldSelectNotes && shouldSelectEvents)
|
|
|
|
{
|
|
|
|
return 'Select All Notes and Events';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 'Select Nothing (Huh?)';
|
|
|
|
}
|
2023-10-26 09:46:22 +00:00
|
|
|
}
|
|
|
|
}
|