Пример #1
0
        private static string GetControlAssignedName(IMyControl control)
        {
            var assign = control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse);

            if (!string.IsNullOrWhiteSpace(assign))
            {
                return(assign);
            }

            assign = control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);

            if (!string.IsNullOrWhiteSpace(assign))
            {
                return(assign);
            }

            assign = control.GetControlButtonName(MyGuiInputDeviceEnum.KeyboardSecond);

            if (!string.IsNullOrWhiteSpace(assign))
            {
                return(assign);
            }

            return("(unassigned)");
        }
Пример #2
0
        public static StringBuilder AppendInputBind(this StringBuilder sb, MyStringId controlId)
        {
            IMyControl control = MyAPIGateway.Input.GetGameControl(controlId);

            if (control == null)
            {
                return(sb.Append("<Unknown:").Append(controlId.String).Append(">"));
            }

            string mouse = control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse);

            if (!string.IsNullOrEmpty(mouse))
            {
                return(sb.Append(mouse));
            }

            string key = control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);

            if (string.IsNullOrEmpty(key))
            {
                key = control.GetControlButtonName(MyGuiInputDeviceEnum.KeyboardSecond);
            }
            if (!string.IsNullOrEmpty(key))
            {
                return(sb.Append(key));
            }

            return(sb.Append("<").Append(control.GetControlName().String).Append(">"));
        }