Files
Funkin/source/funkin/ui/debug/charting/contextmenus/ChartEditorSelectionContextMenu.hx
T

108 lines
3.9 KiB
Haxe

package funkin.ui.debug.charting.contextmenus;
#if FEATURE_CHART_EDITOR
import haxe.ui.containers.menus.MenuItem;
import haxe.ui.containers.menus.MenuCheckBox;
import funkin.ui.debug.charting.commands.CutItemsCommand;
import funkin.ui.debug.charting.commands.RemoveEventsCommand;
import funkin.ui.debug.charting.commands.RemoveItemsCommand;
import funkin.ui.debug.charting.commands.RemoveNotesCommand;
import funkin.ui.debug.charting.commands.FlipNotesCommand;
import funkin.ui.debug.charting.commands.MirrorNotesCommand;
import funkin.ui.debug.charting.commands.SelectAllItemsCommand;
import funkin.ui.debug.charting.commands.InvertSelectedItemsCommand;
import funkin.ui.debug.charting.commands.DeselectAllItemsCommand;
@:access(funkin.ui.debug.charting.ChartEditorState)
@:build(haxe.ui.ComponentBuilder.build("assets/exclude/data/ui/chart-editor/context-menus/selection.xml"))
class ChartEditorSelectionContextMenu extends ChartEditorBaseContextMenu
{
var contextmenuCut:MenuItem;
var contextmenuCopy:MenuItem;
var contextmenuPaste:MenuItem;
var contextmenuDelete:MenuItem;
var contextmenuFlip:MenuItem;
var contextmenuMirrorX:MenuItem;
var contextmenuMirrorY:MenuItem;
var contextmenuMirrorXY:MenuItem;
var contextmenuMirrorFlipWithinStrumline:MenuCheckBox;
var contextmenuSelectAll:MenuItem;
var contextmenuSelectInverse:MenuItem;
var contextmenuSelectNone:MenuItem;
public function new(chartEditorState2:ChartEditorState, xPos2:Float = 0, yPos2:Float = 0)
{
super(chartEditorState2, xPos2, yPos2);
initialize();
}
public function initialize():Void
{
contextmenuCut.onClick = (_) ->
{
chartEditorState.performCommand(new CutItemsCommand(chartEditorState.currentNoteSelection, chartEditorState.currentEventSelection));
};
contextmenuCopy.onClick = (_) ->
{
chartEditorState.copySelection();
};
contextmenuDelete.onClick = (_) ->
{
if (chartEditorState.currentNoteSelection.length > 0 && chartEditorState.currentEventSelection.length > 0)
{
chartEditorState.performCommand(new RemoveItemsCommand(chartEditorState.currentNoteSelection, chartEditorState.currentEventSelection));
}
else if (chartEditorState.currentNoteSelection.length > 0)
{
chartEditorState.performCommand(new RemoveNotesCommand(chartEditorState.currentNoteSelection));
}
else if (chartEditorState.currentEventSelection.length > 0)
{
chartEditorState.performCommand(new RemoveEventsCommand(chartEditorState.currentEventSelection));
}
else
{
// Do nothing???
}
};
contextmenuFlip.onClick = function(_)
{
chartEditorState.performCommand(new FlipNotesCommand(chartEditorState.currentNoteSelection));
}
contextmenuMirrorX.onClick = function(_)
{
chartEditorState.performCommand(new MirrorNotesCommand(chartEditorState.currentNoteSelection, contextmenuMirrorFlipWithinStrumline.selected,
!contextmenuMirrorFlipWithinStrumline.selected, true, false));
}
contextmenuMirrorY.onClick = function(_)
{
chartEditorState.performCommand(new MirrorNotesCommand(chartEditorState.currentNoteSelection, contextmenuMirrorFlipWithinStrumline.selected,
!contextmenuMirrorFlipWithinStrumline.selected, false, true));
}
contextmenuMirrorXY.onClick = function(_)
{
chartEditorState.performCommand(new MirrorNotesCommand(chartEditorState.currentNoteSelection, contextmenuMirrorFlipWithinStrumline.selected,
!contextmenuMirrorFlipWithinStrumline.selected, true, true));
}
contextmenuSelectAll.onClick = function(_)
{
chartEditorState.performCommand(new SelectAllItemsCommand(true, false));
}
contextmenuSelectInverse.onClick = function(_)
{
chartEditorState.performCommand(new InvertSelectedItemsCommand());
}
contextmenuSelectNone.onClick = function(_)
{
chartEditorState.performCommand(new DeselectAllItemsCommand());
}
}
}
#end