示例#1
0
        /// <summary>
        /// Sets up this data row
        /// </summary>
        public void SetupItem(string axis, KBMInputMap.AxisMapping mapping, MouseAxisChangedDelegate mouseAxisChanged, MouseInvertChangedDelegate mouseInvertChanged, AxisKeyRemapStartedDelegate keyMappingStarted)
        {
            Axis               = axis;
            MouseAxisChanged   = mouseAxisChanged;
            MouseInvertChanged = mouseInvertChanged;
            KeyMappingStarted  = keyMappingStarted;

            //setup mouseaxis dropdown
            var           allAxis = Enum.GetValues(typeof(ExplicitKBMInput.MouseAxis));
            List <string> options = new List <string>();

            foreach (int a in allAxis)
            {
                options.Add(Sub.Replace(Enum.GetName(typeof(ExplicitKBMInput.MouseAxis), a), "EXPLICITKBMINPUT_MOUSEAXIS"));
                MouseAxisValues.Add((ExplicitKBMInput.MouseAxis)a); //we can cast it because we know it maps
            }
            IgnoreMouseAxisValueChanged = true;
            MouseAxis.ClearOptions();
            MouseAxis.AddOptions(options);
            IgnoreMouseAxisValueChanged = false;

            //set values of all the things
            TitleText.text = Sub.Replace(Axis, "CFG_MAPPINGS");
            PrimaryPositive.GetComponentInChildren <Text>().text   = InputModule.GetNameForKeyCode((KeyCode)mapping.PrimaryPositive);
            PrimaryNegative.GetComponentInChildren <Text>().text   = InputModule.GetNameForKeyCode((KeyCode)mapping.PrimaryNegative);
            SecondaryPositive.GetComponentInChildren <Text>().text = InputModule.GetNameForKeyCode((KeyCode)mapping.SecondaryPositive);
            SecondaryNegative.GetComponentInChildren <Text>().text = InputModule.GetNameForKeyCode((KeyCode)mapping.SecondaryNegative);
            SetMouseAxis(MouseAxisValues.IndexOf(mapping.MouseAxis));
            SetMouseInvert(mapping.InvertMouse);
        }
示例#2
0
        public void SetupItem(string button, KBMInputMap.ButtonMapping mapping, ButtonKeyRemapStartedDelegate keyMappingStarted)
        {
            Button            = button;
            KeyMappingStarted = keyMappingStarted;

            TitleText.text = Sub.Replace(Button, "CFG_MAPPINGS");
            Primary.GetComponentInChildren <Text>().text   = InputModule.GetNameForKeyCode((KeyCode)mapping.Primary);
            Secondary.GetComponentInChildren <Text>().text = InputModule.GetNameForKeyCode((KeyCode)mapping.Secondary);
            Tertiary.GetComponentInChildren <Text>().text  = InputModule.GetNameForKeyCode((KeyCode)mapping.Tertiary);
        }
        /// <summary>
        /// Call this, passing in a callback, to get a new key mapping
        /// </summary>
        public void GetMapping(string displayName, KeyCode oldKey, KBMButtonMappingCallback callback)
        {
            Callback = callback;
            gameObject.SetActive(true); //activate our panel

            //setup text boxen
            MappingText.text        = displayName;
            CurrentMappingText.text = InputModule.GetNameForKeyCode(oldKey);

            //clear selection
            EventSystem.current.Ref()?.SetSelectedGameObject(null);
        }
示例#4
0
        //open the "change mapping" window and do all that (for button keys)
        private void HandleButtonKeyRemappingStarted(string buttonName, KBMInputButtonKeyType keyType, Button button)
        {
            string  displayName = Sub.Replace(buttonName, "CFG_MAPPINGS");
            KeyCode oldKey      = GetKeyForButton(buttonName, keyType);

            MappingModal.GetMapping(displayName, oldKey, (newKey) => {
                if (newKey.HasValue)
                {
                    // Debug.Log(newKey);

                    SetKeyOnButton(newKey.Value, buttonName, keyType);
                    button.GetComponentInChildren <Text>().text = InputModule.GetNameForKeyCode(newKey.Value);
                }
            });
        }
示例#5
0
        //open the "change mapping" window and do all that (for axis keys)
        private void HandleAxisKeyRemappingStarted(string axisName, KBMInputAxisKeyType keyType, Button button)
        {
            string  displayName = $"{Sub.Replace(axisName, "CFG_MAPPINGS")} {((keyType == KBMInputAxisKeyType.PrimaryPositive || keyType == KBMInputAxisKeyType.SecondaryPositive) ? Sub.Replace("+", "EXPLICITKBMINPUT") : Sub.Replace("-", "EXPLICITKBMINPUT"))}";
            KeyCode oldKey      = GetKeyForAxis(axisName, keyType);

            MappingModal.GetMapping(displayName, oldKey, (newKey) => {
                if (newKey.HasValue)
                {
                    //Debug.Log(newKey);

                    SetKeyOnAxis(newKey.Value, axisName, keyType);
                    button.GetComponentInChildren <Text>().text = InputModule.GetNameForKeyCode(newKey.Value);
                }
            });
        }