import { } from '../../common/global' ; import GroupFilter from './GroupFilter' ; import { HotkeyConfig } from './HotkeyConfig' ; import { _Hotkeys } from './Hotkeys' ; import { KeyMap , HotkeySetting } from './Hotkeys' ; export const Hotkeys = _Hotkeys ; { window . Hotkeys = Hotkeys ; Hotkeys . _init ( ) ; Hotkeys . showConfig = async function ( title , filters ) { if ( ! title || title === '' ) throw new Error ( 'You must provide a title for the config menu' ) ; if ( ! filters || filters . length === 0 ) throw new Error ( 'You must provide at least one filter' ) ; const config = new HotkeyConfig ( title , filters ) ; await config . render ( true ) ; } ; Hotkeys . createConfig = function ( title , filters ) { if ( ! title || title === '' ) throw new Error ( 'You must provide a title for the config menu' ) ; if ( ! filters || filters . length === 0 ) throw new Error ( 'You must provide at least one filter' ) ; return class Sepcialized extends HotkeyConfig { constructor ( ) { super ( title , filters ) ; } } ; } ; } import SETTINGS from "../../common/Settings" ; SETTINGS . init ( 'lib-df-hotkeys' ) ; Hooks . once ( 'init' , function ( ) { HotkeyConfig . init ( ) ; const PREF_SELECT = 'select' ; SETTINGS . register ( PREF_SELECT , { scope : 'world' , config : false , default : { key : Hotkeys . keys . KeyS , alt : false , ctrl : false , shift : false } , type : SETTINGS . typeOf < KeyMap > ( ) } ) ; Hotkeys . registerShortcut ( { name : `${ SETTINGS . MOD_NAME }.${ PREF_SELECT }` , label : 'DF_HOTKEYS.SelectTool' , get : ( ) => SETTINGS . get ( PREF_SELECT ) , set : async ( value ) => SETTINGS . set ( PREF_SELECT , value ) , default : ( ) => SETTINGS . default ( PREF_SELECT ) , onKeyDown : ( _ ) => ( < any > ui . controls ) . _onClickTool ( { preventDefault : ( ) => { } , currentTarget : { dataset : { tool : PREF_SELECT } } } ) , } ) ; } ) ;