예제 #1
0
 public Control(MyKeys seKey, bool Analog = false)
 {
     Name        = seKey.ToString();
     IsPressed   = () => MyAPIGateway.Input.IsKeyPress(seKey);
     this.Analog = Analog;
     usedCount   = 0;
     usedIndex   = -1;
 }
예제 #2
0
            internal void UpdateKey(MyKeys key, string value, UiInput uiInput)
            {
                var keyString = key.ToString();

                switch (value)
                {
                case "kinetic":
                    Energy          = keyString;
                    uiInput.Kinetic = key;
                    break;

                case "energy":
                    Energy         = keyString;
                    uiInput.Energy = key;
                    break;

                case "action":
                    ActionKey         = keyString;
                    uiInput.ActionKey = key;
                    break;

                case "noshunt":
                    NoShunting       = keyString;
                    uiInput.Shunting = key;
                    break;

                case "left":
                    Left         = keyString;
                    uiInput.Left = key;
                    break;

                case "right":
                    Right         = keyString;
                    uiInput.Right = key;
                    break;

                case "front":
                    Front         = keyString;
                    uiInput.Front = key;
                    break;

                case "back":
                    Back         = keyString;
                    uiInput.Back = key;
                    break;

                case "up":
                    Up         = keyString;
                    uiInput.Up = key;
                    break;

                case "down":
                    Down         = keyString;
                    uiInput.Down = key;
                    break;
                }
            }
예제 #3
0
                public Control(MyKeys seKey, int index, bool analog = false)
                {
                    Name        = seKey.ToString();
                    DisplayName = MyAPIGateway.Input.GetKeyName(seKey);

                    if (DisplayName == null || DisplayName.Length == 0 || DisplayName[0] <= ' ')
                    {
                        DisplayName = Name;
                    }

                    Index         = index;
                    IsPressedFunc = () => MyAPIGateway.Input.IsKeyPress(seKey);
                    Analog        = analog;
                }
예제 #4
0
        private static bool TryGetCombination(MyKeys key, bool alt, bool ctrl, bool shift, out ControlCombination combination)
        {
            combination = null;
            if (key == MyKeys.None) // unbind
            {
                return(true);
            }

            string input = InputHandler.inputNames.GetValueOrDefault(key, null);

            if (input == null)
            {
                MyAPIGateway.Utilities.ShowNotification($"Unknown key: {key.ToString()}", 5000, MyFontEnum.Red);
                return(false);
            }

            string combinationString = (alt ? "alt " : "") + (ctrl ? "ctrl " : "") + (shift ? "shift " : "") + input;

            combination = ControlCombination.CreateFrom(combinationString);

            MyAPIGateway.Utilities.ShowNotification($"Bound succesfully to: {combination.GetFriendlyString()}", 3000, MyFontEnum.Green);
            return(true);
        }