Ejemplo n.º 1
0
 internal static Hotkey AddOrFind(HotkeyFunction hotkeyFunction)
 {
     var hkey = Program.settings.Hotkey.ToList().Find(x => x.Function == hotkeyFunction);
     if (hkey == null)
         Program.settings.Hotkey.Add(hkey = new Hotkey { Function = hotkeyFunction });
     return hkey;
 }
Ejemplo n.º 2
0
        public bool TryRegisterHotkey(string functionName, System.Action action, KeyCombo keyCombo)
        {
            // Toss out anything where the main key is a toggle key (not using the system correctly).
            foreach (var toggleKey in ToggleKey.GetAll())
            {
                if (toggleKey.Keys.Contains(keyCombo.MainKey))
                {
                    Game.Log(Logging.Category.SONG_DATA, $"Unable to register hotkey: Main key (Keycode.{keyCombo.MainKey}) is a reserved toggle key.",
                             Logging.Level.LOG_WARNING);
                    return(false);
                }
            }

            if (_hotKeyRegistry.Exists(kvp => kvp.Key.Equals(keyCombo)))
            {
                // Keycode already registered.
                var existingHotkeyRegistryItem = _hotKeyRegistry.Find(kvp => kvp.Key.Equals(keyCombo));
                Game.LogFormat(Logging.Category.SONG_DATA,
                               "Unable to register hotkey: This key combo ({0}) is already reserved for the function: \"{1}\".",
                               Logging.Level.LOG_WARNING,
                               existingHotkeyRegistryItem.Key.GetSequenceString(),
                               existingHotkeyRegistryItem.Value.FunctionName);
                return(false);
            }
            else
            {
                // Successful registration.
                var newHotkeyFunction = new HotkeyFunction(functionName, action);
                _hotKeyRegistry.Add(new KeyValuePair <KeyCombo, HotkeyFunction>(keyCombo, newHotkeyFunction));
            }
            return(true);
        }
Ejemplo n.º 3
0
        public Hotkey(HotkeyFunction function, ModifierKeys modifier, Key key)
        {
            this.Function = function;
            this.Key = key;
            this.ModifierKey = modifier;

            SetDefaultParameterValues();
        }
Ejemplo n.º 4
0
        internal static Hotkey AddOrFind(HotkeyFunction hotkeyFunction)
        {
            var hkey = Program.settings.Hotkey.ToList().Find(x => x.Function == hotkeyFunction);

            if (hkey == null)
            {
                Program.settings.Hotkey.Add(hkey = new Hotkey {
                    Function = hotkeyFunction
                });
            }
            return(hkey);
        }
Ejemplo n.º 5
0
 public FunctionHotkey GetFunctionHotkey(HotkeyFunction function)
 {
     return(inputMan.GetFunctionHotkey(function));
 }
Ejemplo n.º 6
0
 public FunctionHotkey(ScanCode hkScan, Modifiers mods, HotkeyFunction function) : base(hkScan, mods)
 {
     Function = function;
 }