Exemplo n.º 1
0
        public KeyBinding(KeyBindingType type, string text)
        {
            Type = type;
            textRepresentation = "";

            string[] keyBindings = text.Split('+');
            foreach (string keyBinding in keyBindings)
            {
                if (TryParseEnum <KeyCode>(keyBinding, out KeyCode keyCode))
                {
                    if (keyCode != KeyCode.None)
                    {
                        keyCodes.Add(keyCode);
                        textRepresentation += keyCode + "+";
                    }
                }
            }

            if (keyCodes.Count == 0)
            {
                textRepresentation = "NONE";
            }

            else
            {
                textRepresentation = textRepresentation.TrimEnd('+');
            }
        }
Exemplo n.º 2
0
 public ScriptedKeyBinding(Keys key, KeyBindingType type, string text, bool save)
 {
     base.Key    = key;
     BindingType = type;
     m_text      = text;
     m_save      = save;
 }
Exemplo n.º 3
0
        public MouseButtonBinding(String button, KeyBindingType bindingType)
        {
            this.button      = button;
            this.bindingType = bindingType;

            buttonProperty = typeof(MouseState).GetProperty(button);
            if (buttonProperty == null || buttonProperty.PropertyType != typeof(ButtonState))
            {
                throw new InvalidProgramException("Could not find button " + button);
            }
        }
Exemplo n.º 4
0
 public void AddAction(String Action, KeyBindingType BindingType)
 {
     if (InputActions.ContainsKey(Action))
     {
         return;                                  // throw new InvalidOperationException();
     }
     InputActions.Add(Action, new InputAction
     {
         Type = BindingType
     });
 }
Exemplo n.º 5
0
            public KeyBinding(BoundKeyFunction function,
                              KeyBindingType bindingType,
                              Keyboard.Key baseKey,
                              Keyboard.Key mod1 = Keyboard.Key.Unknown,
                              Keyboard.Key mod2 = Keyboard.Key.Unknown,
                              Keyboard.Key mod3 = Keyboard.Key.Unknown)
            {
                Function    = function;
                BindingType = bindingType;

                PackedKeyCombo = PackKeyCombo(baseKey, mod1, mod2, mod3);
            }
Exemplo n.º 6
0
            public KeyBinding(BoundKeyFunction function,
                              KeyBindingType bindingType,
                              Keyboard.Key baseKey,
                              bool canFocus, bool canRepeat,
                              Keyboard.Key mod1 = Keyboard.Key.Unknown,
                              Keyboard.Key mod2 = Keyboard.Key.Unknown,
                              Keyboard.Key mod3 = Keyboard.Key.Unknown)
            {
                Function    = function;
                BindingType = bindingType;
                CanFocus    = canFocus;
                CanRepeat   = canRepeat;

                PackedKeyCombo = PackKeyCombo(baseKey, mod1, mod2, mod3);
            }
Exemplo n.º 7
0
            public KeyBinding(InputManager inputManager, BoundKeyFunction function,
                              KeyBindingType bindingType,
                              Key baseKey,
                              bool canFocus, bool canRepeat, int priority, Key mod1 = Key.Unknown,
                              Key mod2 = Key.Unknown,
                              Key mod3 = Key.Unknown)
            {
                Function      = function;
                BindingType   = bindingType;
                CanFocus      = canFocus;
                CanRepeat     = canRepeat;
                Priority      = priority;
                _inputManager = inputManager;

                PackedKeyCombo = new PackedKeyCombo(baseKey, mod1, mod2, mod3);
            }
Exemplo n.º 8
0
        private void listView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count == 0)
            {
                keyTextBox.Clear();
                m_currentKey = Keys.None;
                styleRadioButton1.Checked = false;
                actionTextBox.Clear();
                return;
            }

            ListViewItem item = listView.SelectedItems[0];

            if (item.Tag is ScriptedKeyBinding)
            {
                ScriptedKeyBinding binding = (ScriptedKeyBinding)item.Tag;

                KeyBindingType type = binding.BindingType;
                if (type == KeyBindingType.Send)
                {
                    styleRadioButton1.Checked = true;
                }
                else if (type == KeyBindingType.Script)
                {
                    styleRadioButton2.Checked = true;
                }

                keyTextBox.Text    = KeyCodeToString(binding.Key);
                m_currentKey       = binding.Key;
                actionTextBox.Text = binding.Text;

                assignButton.Enabled = true;
            }
            else
            {
                keyTextBox.Clear();
                m_currentKey = Keys.None;
                actionTextBox.Clear();

                assignButton.Enabled = false;
            }
        }
Exemplo n.º 9
0
        public KeyBinding(KeyBindingType type, params KeyCode[] keyCodes)
        {
            Type = type;
            textRepresentation = "";

            foreach (KeyCode keyCode in keyCodes)
            {
                if (keyCode != KeyCode.None)
                {
                    this.keyCodes.Add(keyCode);
                    textRepresentation += keyCode + "+";
                }
            }

            if (this.keyCodes.Count == 0)
            {
                textRepresentation = "NONE";
            }

            else
            {
                textRepresentation = textRepresentation.TrimEnd('+');
            }
        }
Exemplo n.º 10
0
 public KeyboardBinding(Keys key, KeyBindingType bindingType)
 {
     this.key = key;
     this.bindingType = bindingType;
 }
Exemplo n.º 11
0
 public KeyboardBinding(Keys key, KeyBindingType bindingType)
 {
     this.key         = key;
     this.bindingType = bindingType;
 }
Exemplo n.º 12
0
 public GamepadButtonBinding(Buttons button, KeyBindingType bindingType)
 {
     this.button      = button;
     this.bindingType = bindingType;
 }
Exemplo n.º 13
0
 public void AddAndBindAction(Keys Key, String Action, KeyBindingType BindingType, Action Handler)
 {
     AddAction(Action, BindingType);
     BindKey(Action, Key);
     BindHandler(Action, Handler);
 }
Exemplo n.º 14
0
 public Keys this[KeyBindingType type]
 {
     get { return _bindings[type]; }
     set { _bindings[type] = value; }
 }
Exemplo n.º 15
0
 public GamepadButtonBinding(Buttons button, KeyBindingType bindingType)
 {
     this.button = button;
     this.bindingType = bindingType;
 }
Exemplo n.º 16
0
        public MouseButtonBinding(String button, KeyBindingType bindingType)
        {
            this.button = button;
            this.bindingType = bindingType;

            buttonProperty = typeof(MouseState).GetProperty(button);
            if (buttonProperty == null || buttonProperty.PropertyType != typeof(ButtonState))
                throw new InvalidProgramException("Could not find button " + button);
        }
Exemplo n.º 17
0
 public KeyBinding(KeyCode keyCode, KeyBindingType type)
 {
     KeyCode = keyCode;
     Type    = type;
 }