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;
|
|
|
|
import funkin.data.song.SongDataUtils;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command to deselect a specific set of notes and events in the chart editor.
|
|
|
|
*/
|
|
|
|
@:nullSafety
|
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class DeselectItemsCommand implements ChartEditorCommand
|
|
|
|
{
|
|
|
|
var notes:Array<SongNoteData>;
|
|
|
|
var events:Array<SongEventData>;
|
|
|
|
|
|
|
|
public function new(notes:Array<SongNoteData>, events:Array<SongEventData>)
|
|
|
|
{
|
|
|
|
this.notes = notes;
|
|
|
|
this.events = events;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
state.currentNoteSelection = SongDataUtils.subtractNotes(state.currentNoteSelection, this.notes);
|
|
|
|
state.currentEventSelection = SongDataUtils.subtractEvents(state.currentEventSelection, this.events);
|
|
|
|
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
state.notePreviewDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undo(state:ChartEditorState):Void
|
|
|
|
{
|
|
|
|
for (note in this.notes)
|
|
|
|
{
|
|
|
|
state.currentNoteSelection.push(note);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (event in this.events)
|
|
|
|
{
|
|
|
|
state.currentEventSelection.push(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
state.noteDisplayDirty = true;
|
|
|
|
state.notePreviewDirty = 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 (notes.length > 0 || events.length > 0);
|
|
|
|
}
|
|
|
|
|
2023-10-26 09:46:22 +00:00
|
|
|
public function toString():String
|
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
var isPlural = (notes.length + events.length) > 1;
|
|
|
|
var notesOnly = (notes.length > 0 && events.length == 0);
|
|
|
|
var eventsOnly = (notes.length == 0 && events.length > 0);
|
2023-10-26 09:46:22 +00:00
|
|
|
|
2024-01-04 13:20:34 +00:00
|
|
|
if (notesOnly)
|
|
|
|
{
|
|
|
|
return 'Deselect ${notes.length} ${isPlural ? 'Notes' : 'Note'}';
|
|
|
|
}
|
|
|
|
else if (eventsOnly)
|
2023-10-26 09:46:22 +00:00
|
|
|
{
|
2024-01-04 13:20:34 +00:00
|
|
|
return 'Deselect ${events.length} ${isPlural ? 'Events' : 'Event'}';
|
2023-10-26 09:46:22 +00:00
|
|
|
}
|
|
|
|
|
2024-01-04 13:20:34 +00:00
|
|
|
return 'Deselect ${notes.length + events.length} Items';
|
2023-10-26 09:46:22 +00:00
|
|
|
}
|
|
|
|
}
|