mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-12 08:25:13 +00:00
70 lines
1.8 KiB
Haxe
70 lines
1.8 KiB
Haxe
|
package funkin.ui.debug.charting.commands;
|
||
|
|
||
|
import funkin.data.song.SongData.SongNoteData;
|
||
|
import funkin.data.song.SongData.SongEventData;
|
||
|
import funkin.data.song.SongDataUtils;
|
||
|
|
||
|
/**
|
||
|
* Deletes the given notes and events from the current chart in the chart editor.
|
||
|
* Use only when BOTH notes and events are being deleted.
|
||
|
*/
|
||
|
@:nullSafety
|
||
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
||
|
class RemoveItemsCommand 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.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, notes);
|
||
|
state.currentSongChartEventData = SongDataUtils.subtractEvents(state.currentSongChartEventData, events);
|
||
|
|
||
|
state.currentNoteSelection = [];
|
||
|
state.currentEventSelection = [];
|
||
|
|
||
|
state.playSound(Paths.sound('chartingSounds/noteErase'));
|
||
|
|
||
|
state.saveDataDirty = true;
|
||
|
state.noteDisplayDirty = true;
|
||
|
state.notePreviewDirty = true;
|
||
|
|
||
|
state.sortChartData();
|
||
|
}
|
||
|
|
||
|
public function undo(state:ChartEditorState):Void
|
||
|
{
|
||
|
for (note in notes)
|
||
|
{
|
||
|
state.currentSongChartNoteData.push(note);
|
||
|
}
|
||
|
|
||
|
for (event in events)
|
||
|
{
|
||
|
state.currentSongChartEventData.push(event);
|
||
|
}
|
||
|
|
||
|
state.currentNoteSelection = notes;
|
||
|
state.currentEventSelection = events;
|
||
|
|
||
|
state.playSound(Paths.sound('chartingSounds/undo'));
|
||
|
|
||
|
state.saveDataDirty = true;
|
||
|
state.noteDisplayDirty = true;
|
||
|
state.notePreviewDirty = true;
|
||
|
|
||
|
state.sortChartData();
|
||
|
}
|
||
|
|
||
|
public function toString():String
|
||
|
{
|
||
|
return 'Remove ${notes.length + events.length} Items';
|
||
|
}
|
||
|
}
|