2023-10-28 19:56:34 -04:00
|
|
|
package funkin.ui.debug.charting.handlers;
|
|
|
|
|
|
|
|
import funkin.util.PlatformUtil;
|
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
/**
|
|
|
|
* Handles modifying the shortcut text of menu items based on the current platform.
|
|
|
|
* On MacOS, `Ctrl`, `Alt`, and `Shift` are replaced with `⌘` (or `^`), `⌥`, and `⇧`, respectively.
|
|
|
|
*/
|
2023-10-28 19:56:34 -04:00
|
|
|
@:access(funkin.ui.debug.charting.ChartEditorState)
|
|
|
|
class ChartEditorShortcutHandler
|
|
|
|
{
|
|
|
|
public static function applyPlatformShortcutText(state:ChartEditorState):Void
|
|
|
|
{
|
2023-11-24 00:42:07 -05:00
|
|
|
state.menubarItemNewChart.shortcutText = ctrlOrCmd('N');
|
|
|
|
state.menubarItemOpenChart.shortcutText = ctrlOrCmd('O');
|
|
|
|
state.menubarItemSaveChartAs.shortcutText = ctrlOrCmd(shift('S'));
|
|
|
|
state.menubarItemExit.shortcutText = ctrlOrCmd('Q');
|
|
|
|
|
|
|
|
state.menubarItemUndo.shortcutText = ctrlOrCmd('Z');
|
|
|
|
state.menubarItemRedo.shortcutText = ctrlOrCmd('Y');
|
|
|
|
state.menubarItemCut.shortcutText = ctrlOrCmd('X');
|
|
|
|
state.menubarItemCopy.shortcutText = ctrlOrCmd('C');
|
|
|
|
state.menubarItemPaste.shortcutText = ctrlOrCmd('V');
|
|
|
|
|
2024-01-04 08:20:34 -05:00
|
|
|
state.menubarItemSelectAllNotes.shortcutText = ctrlOrCmd('A');
|
|
|
|
state.menubarItemSelectAllEvents.shortcutText = ctrlOrCmd(alt('A'));
|
2023-11-24 00:42:07 -05:00
|
|
|
state.menubarItemSelectInverse.shortcutText = ctrlOrCmd('I');
|
|
|
|
state.menubarItemSelectNone.shortcutText = ctrlOrCmd('D');
|
|
|
|
state.menubarItemSelectBeforeCursor.shortcutText = shift('Home');
|
|
|
|
state.menubarItemSelectAfterCursor.shortcutText = shift('End');
|
|
|
|
|
|
|
|
state.menubarItemDifficultyDown.shortcutText = ctrlOrCmd('←');
|
|
|
|
state.menubarItemDifficultyUp.shortcutText = ctrlOrCmd('→');
|
|
|
|
|
|
|
|
state.menubarItemPlaytestFull.shortcutText = 'Enter';
|
|
|
|
state.menubarItemPlaytestMinimal.shortcutText = shift('Enter');
|
2023-10-28 19:56:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display `Ctrl` on Windows and `⌘` (Command) on macOS.
|
|
|
|
* @param input
|
|
|
|
*/
|
|
|
|
static inline function ctrlOrCmd(input:String)
|
|
|
|
{
|
|
|
|
return (PlatformUtil.isMacOS()) ? '⌘+${input}' : 'Ctrl+${input}';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display `Ctrl` on Windows and `^` (Control) on macOS.
|
|
|
|
* @param input
|
|
|
|
*/
|
|
|
|
static inline function ctrl(input:String)
|
|
|
|
{
|
|
|
|
return (PlatformUtil.isMacOS()) ? '^+${input}' : 'Ctrl+${input}';
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline function alt(input:String)
|
|
|
|
{
|
|
|
|
return (PlatformUtil.isMacOS()) ? '⌥+${input}' : 'Alt+${input}';
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline function shift(input:String)
|
|
|
|
{
|
|
|
|
return (PlatformUtil.isMacOS()) ? '⇧+${input}' : 'Shift+${input}';
|
|
|
|
}
|
|
|
|
}
|