mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-10 08:44:47 +00:00
60 lines
1.7 KiB
Haxe
60 lines
1.7 KiB
Haxe
package funkin.ui.debug.charting.commands;
|
|
|
|
import funkin.data.song.SongData.SongNoteData;
|
|
import funkin.data.song.SongDataUtils;
|
|
|
|
/**
|
|
* Command that flips a given array of notes from the player's side of the chart editor to the opponent's side, or vice versa.
|
|
*/
|
|
@:nullSafety
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
class FlipNotesCommand implements ChartEditorCommand
|
|
{
|
|
var notes:Array<SongNoteData> = [];
|
|
var flippedNotes:Array<SongNoteData> = [];
|
|
|
|
public function new(notes:Array<SongNoteData>)
|
|
{
|
|
this.notes = notes;
|
|
this.flippedNotes = SongDataUtils.flipNotes(notes);
|
|
}
|
|
|
|
public function execute(state:ChartEditorState):Void
|
|
{
|
|
// Delete the notes.
|
|
state.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, notes);
|
|
|
|
// Add the flipped notes.
|
|
state.currentSongChartNoteData = state.currentSongChartNoteData.concat(flippedNotes);
|
|
|
|
state.currentNoteSelection = flippedNotes;
|
|
state.currentEventSelection = [];
|
|
|
|
state.saveDataDirty = true;
|
|
state.noteDisplayDirty = true;
|
|
state.notePreviewDirty = true;
|
|
state.sortChartData();
|
|
}
|
|
|
|
public function undo(state:ChartEditorState):Void
|
|
{
|
|
state.currentSongChartNoteData = SongDataUtils.subtractNotes(state.currentSongChartNoteData, flippedNotes);
|
|
state.currentSongChartNoteData = state.currentSongChartNoteData.concat(notes);
|
|
|
|
state.currentNoteSelection = notes;
|
|
state.currentEventSelection = [];
|
|
|
|
state.saveDataDirty = true;
|
|
state.noteDisplayDirty = true;
|
|
state.notePreviewDirty = true;
|
|
|
|
state.sortChartData();
|
|
}
|
|
|
|
public function toString():String
|
|
{
|
|
var len:Int = notes.length;
|
|
return 'Flip $len Notes';
|
|
}
|
|
}
|