private void DeactivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         Controls.Remove(item);
     }
 }
 private void ActivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         Controls.Add(item);
     }
 }
 private void ActivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         item.Visible = true;
     }
 }
示例#4
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum?defaultControlMouse,
                  Keys?defaultControlKey, MyJoystickButtonsEnum?defaultControlJoy, MyJoystickAxesEnum?defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton    = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey    = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis   = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
示例#5
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl   = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text            = text;
     m_controlType     = controlType;
     m_joystickButton  = MyJoystickButtonsEnum.None;
     m_joystickAxis    = MyJoystickAxesEnum.None;
     m_mouseButton     = MyMouseButtonsEnum.None;
     m_keyboardKey     = Keys.None;
 }
        public override bool Update(bool hasFocus)
        {
            if (m_controlTypeList.GetSelectedKey() != (int)m_currentControlType)
            {
                DeactivateControls(m_currentControlType);
                m_currentControlType = (MyGuiControlTypeEnum)m_controlTypeList.GetSelectedKey();
                ActivateControls(m_currentControlType);
            }

            if (base.Update(hasFocus) == false)
            {
                return(false);
            }
            return(true);
        }
示例#7
0
 public MyControl(MyStringId controlId,
                  MyStringId name,
                  MyGuiControlTypeEnum controlType,
                  MyMouseButtonsEnum?defaultControlMouse,
                  MyKeys?defaultControlKey,
                  MyStringId?helpText       = null,
                  MyKeys?defaultControlKey2 = null,
                  MyStringId?description    = null)
 {
     m_controlId        = controlId;
     m_name             = name;
     m_controlType      = controlType;
     m_mouseButton      = defaultControlMouse ?? MyMouseButtonsEnum.None;
     m_keyboardKey      = defaultControlKey ?? MyKeys.None;
     m_KeyboardKey2     = defaultControlKey2 ?? MyKeys.None;
     m_data.Description = description;
 }
示例#8
0
 public MyControl(MyStringId controlId,
     MyStringId name,
     MyGuiControlTypeEnum controlType,
     MyMouseButtonsEnum? defaultControlMouse,
     MyKeys? defaultControlKey,
     MyStringId? helpText = null,
     MyKeys? defaultControlKey2 = null,
     MyStringId? description = null)
 {
     m_controlId = controlId;
     m_name = name;
     m_controlType = controlType;
     m_mouseButton = defaultControlMouse ?? MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey ?? MyKeys.None;
     m_KeyboardKey2 = defaultControlKey2 ?? MyKeys.None;
     m_data.Description = description;
 }
 protected static void AddDefaultGameControl(
     Dictionary<MyStringId, MyControl> self,
     MyGuiControlTypeEnum controlTypeEnum,
     MyStringId controlId,
     MyMouseButtonsEnum? mouse = null,
     MyKeys? key = null,
     MyKeys? key2 = null)
 {
     var helper = MyGuiGameControlsHelpers.GetGameControlHelper(controlId);
     self[controlId] = new MyControl(controlId, helper.NameEnum, controlTypeEnum, mouse, key, defaultControlKey2: key2, description: helper.DescriptionEnum);
 }
        public MyGuiScreenOptionsControls()
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
        {
            m_size = new Vector2(1110f / 1600f, 1127f / 1200f);
            m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ControlsBackground", flags: TextureFlags.IgnoreQuality);

            m_enableBackgroundFade = true;
            AddCaption(MyTextsWrapperEnum.Controls, new Vector2(0, 0.005f));

            MyGuiManager.GetInput().TakeSnapshot();

            m_controlsOriginLeft  = new Vector2(-m_size.Value.X / 2.0f + 0.06f, -m_size.Value.Y / 2.0f + 0.102f);
            m_controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.333f, -m_size.Value.Y / 2.0f + 0.102f);

            #region Add Revert, OK, Cancel and selection combobox

            /*
             * //  Buttons Revert, OK and CANCEL
             * float buttonsY = m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f;
             * Controls.Add(new MyGuiControlButton(this,
             *  new Vector2((MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X + 0.015f) * -1, buttonsY),
             *  MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
             *
             *  MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick,
             *  MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
             * Controls.Add(new MyGuiControlButton(this,
             *  new Vector2(0, buttonsY),
             *  MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
             *  MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick,
             *  MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
             * Controls.Add(new MyGuiControlButton(this,
             *  new Vector2(m_controlsOriginRight.X + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X, buttonsY),
             *  new Vector2(MyGuiConstants.BUTTON_DEFAULTS_WIDTH, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y), MyGuiConstants.BUTTON_BACKGROUND_COLOR,
             *  MyTextsWrapperEnum.Revert, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnResetDefaultsClick,
             *  MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
             */


            var okButton = new MyGuiControlButton(this, new Vector2(-0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                                                  MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                  MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Ok,
                                                  MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick,
                                                  true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            var cancelButton = new MyGuiControlButton(this, new Vector2(-0.0597f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                                                      MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                      MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel,
                                                      MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick,
                                                      true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            var resetButton = new MyGuiControlButton(this, new Vector2(0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                                                     MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                     MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Revert,
                                                     MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnResetDefaultsClick,
                                                     true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            Controls.Add(okButton);
            Controls.Add(cancelButton);
            Controls.Add(resetButton);



            //  Page selection combobox
            m_currentControlType = MyGuiControlTypeEnum.General;
            var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA +
                               new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0);
            m_controlTypeList = new MyGuiControlCombobox(this, cBoxPosition, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyTextsWrapperEnum.General);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyTextsWrapperEnum.Navigation);
            // There are no controls for this category now, so hide it completely and uncomment, when we have new comms controls
            //m_controlTypeList.AddItem((int)MyGuiInputTypeEnum.Communications, MyTextsWrapperEnum.Comms);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Weapons, MyTextsWrapperEnum.Weapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.SpecialWeapons, MyTextsWrapperEnum.SpecialWeapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyTextsWrapperEnum.Systems1);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyTextsWrapperEnum.Systems2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Editor, MyTextsWrapperEnum.Editor);
            m_controlTypeList.SelectItemByKey((int)m_currentControlType);
            Controls.Add(m_controlTypeList);

            #endregion

            AddControls();

            ActivateControls(m_currentControlType);
        }
        public override bool Update(bool hasFocus)
        {
            if (m_controlTypeList.GetSelectedKey() != (int)m_currentControlType)
            {
                DeactivateControls(m_currentControlType);
                m_currentControlType = (MyGuiControlTypeEnum)m_controlTypeList.GetSelectedKey();
                ActivateControls(m_currentControlType);
            }

            if (base.Update(hasFocus) == false) return false;
            return true;
        }
        private void AddControlsByType(MyGuiControlTypeEnum type)
        {
            //  "General" page is little bit too complex, so I need to create it separately.
            if (type == MyGuiControlTypeEnum.General)
            {
                AddGeneralControls();
                return;
            }

            var buttonStyle = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.ControlSetting);

            Vector2 controlsOriginRight = m_controlsOriginRight;
            controlsOriginRight.X -= 0.02f;
            m_allControls[type] = new List<MyGuiControlBase>();
            float i = 2;
            float buttonScale = 0.85f;

            var controls = MyInput.Static.GetGameControlsList();

            var keyboardLabel   = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard, Vector2.Zero);
            var keyboard2Label  = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard2, Vector2.Zero);
            var mouseLabel      = MakeLabel(MyCommonTexts.ScreenOptionsControls_Mouse, Vector2.Zero);
            var gamepadLabel    = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_Gamepad, Vector2.Zero) : null;
            var analogAxesLabel = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_AnalogAxes, Vector2.Zero) : null;

            float columnWidth = 1.1f * Math.Max(Math.Max(keyboardLabel.Size.X, keyboard2Label.Size.X),
                                                Math.Max(mouseLabel.Size.X, buttonStyle.SizeOverride.Value.X));

            var position = (i - 1) * MyGuiConstants.CONTROLS_DELTA + controlsOriginRight;
            position.X += columnWidth * 0.5f; // make labels centered
            keyboardLabel.Position = position; position.X += columnWidth;
            keyboard2Label.Position = position; position.X += columnWidth;
            mouseLabel.Position = position;

            m_allControls[type].Add(keyboardLabel);
            m_allControls[type].Add(keyboard2Label);
            m_allControls[type].Add(mouseLabel);

            if (MyFakes.ENABLE_JOYSTICK_SETTINGS)
            {
                //position.X += columnWidth; gamepadLabel.Position = position;
                //position.X += columnWidth; analogAxesLabel.Position = position;

                //m_allControls[type].Add(gamepadLabel);
                //m_allControls[type].Add(analogAxesLabel);
            }

            foreach (MyControl control in controls)
            {
                if (control.GetControlTypeEnum() == type)
                {
                    m_allControls[type].Add(new MyGuiControlLabel(
                        position: m_controlsOriginLeft + i * MyGuiConstants.CONTROLS_DELTA,
                        text: MyTexts.GetString(control.GetControlName())));

                    position = controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA;
                    position.X += columnWidth * 0.5f;

                    // This is column for keyboard 1
                    var key1Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.Keyboard);
                    m_allControls[type].Add(key1Button);
                    m_key1Buttons.Add(key1Button);
                    position.X += columnWidth;

                    // This is column for keyboard 2
                    var key2Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.KeyboardSecond);
                    m_allControls[type].Add(key2Button);
                    m_key2Buttons.Add(key2Button);
                    position.X += columnWidth;

                    // This is column for mouse
                    var mouseButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Mouse);
                    m_allControls[type].Add(mouseButton);
                    m_mouseButtons.Add(mouseButton);
                    position.X += columnWidth;

                    if (MyFakes.ENABLE_JOYSTICK_SETTINGS)
                    {
                        //// This is column for joystick
                        //var joyButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Joystick);
                        //m_allControls[type].Add(joyButton);
                        //m_joystickButtons.Add(joyButton);
                        //position.X += columnWidth;

                        //// This is column for joystick axes
                        //var joyAxis = MakeControlButton(control, position, MyGuiInputDeviceEnum.JoystickAxis);
                        //m_allControls[type].Add(joyAxis);
                        //m_joystickAxes.Add(joyAxis);
                        //position.X += columnWidth;
                    }

                    i += buttonScale;
                }
            }
        }
 private void ActivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         Controls.Add(item);
     }
 }
        private void AddControlsByType(MyGuiControlTypeEnum type)
        {
            Vector2 controlsOriginRight = m_controlsOriginRight;
            controlsOriginRight.X -= 0.047f;
            m_allControls[type] = new List<MyGuiControlBase>();
            float i = 2;
            float buttonScale = 0.85f;

            MyControl[] controls = MyGuiManager.GetInput().GetGameControlsList();
            if (type == MyGuiControlTypeEnum.Editor) controls = MyGuiManager.GetInput().GetEditorControlsList();

            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 0.0f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Keyboard, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 0.5f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Mouse, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 1.0f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Gamepad, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 1.5f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.AnalogAxes, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));

            controlsOriginRight.X += 0.047f;
            foreach (MyControl control in controls)
            {
                if (control.GetControlTypeEnum() == type)
                {

                    m_allControls[type].Add(new MyGuiControlLabel(this, m_controlsOriginLeft + i * MyGuiConstants.CONTROLS_DELTA, null, control.GetControlName(), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

                    // This is column for keyboard
                    MyGuiControlButtonParameters param = new MyGuiControlButtonParameters();
                    MyGuiControlButton keyButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 0 * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                        CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                        MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_keyButtonsDictionary, MyGuiInputDeviceEnum.Keyboard); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(keyButton);
                    m_keyButtons.Add(keyButton);

                    // This is column for mouse
                    MyGuiControlButton mouseButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 0.5f * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                        CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                        MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_mouseButtonsDictionary, MyGuiInputDeviceEnum.Mouse); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(mouseButton);
                    m_mouseButtons.Add(mouseButton);

                    // This is column for joystick
                    MyGuiControlButton joyButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 1 * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                        CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Joystick)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                        MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_joystickButtonsDictionary, MyGuiInputDeviceEnum.Joystick); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(joyButton);
                    m_joystickButtons.Add(joyButton);

                    // This is column for joystick axes
                    MyGuiControlButton joyAxis = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 1.5f * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                        CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.JoystickAxis)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                        MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_joystickAxesDictionary, MyGuiInputDeviceEnum.JoystickAxis); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(joyAxis);
                    m_joystickAxes.Add(joyAxis);

                    m_keyButtonsDictionary[control] = keyButton;
                    m_mouseButtonsDictionary[control] = mouseButton;
                    m_joystickButtonsDictionary[control] = joyButton;
                    m_joystickAxesDictionary[control] = joyAxis;

                    i += buttonScale;
                }
            }
        }
        private void AddControlsByType(MyGuiControlTypeEnum type)
        {
            //  "General" page is little bit too complex, so I need to create it separately.
            if (type == MyGuiControlTypeEnum.General)
            {
                AddGeneralControls();
                return;
            }

            var buttonStyle = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.ControlSetting);

            Vector2 controlsOriginRight = m_controlsOriginRight;

            controlsOriginRight.X -= 0.02f;
            m_allControls[type]    = new List <MyGuiControlBase>();
            float i           = 2;
            float buttonScale = 0.85f;

            var controls = MyInput.Static.GetGameControlsList();

            var keyboardLabel   = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard, Vector2.Zero);
            var keyboard2Label  = MakeLabel(MyCommonTexts.ScreenOptionsControls_Keyboard2, Vector2.Zero);
            var mouseLabel      = MakeLabel(MyCommonTexts.ScreenOptionsControls_Mouse, Vector2.Zero);
            var gamepadLabel    = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_Gamepad, Vector2.Zero) : null;
            var analogAxesLabel = (MyFakes.ENABLE_JOYSTICK_SETTINGS) ? MakeLabel(MyCommonTexts.ScreenOptionsControls_AnalogAxes, Vector2.Zero) : null;

            float columnWidth = 1.1f * Math.Max(Math.Max(keyboardLabel.Size.X, keyboard2Label.Size.X),
                                                Math.Max(mouseLabel.Size.X, buttonStyle.SizeOverride.Value.X));

            var position = (i - 1) * MyGuiConstants.CONTROLS_DELTA + controlsOriginRight;

            position.X             += columnWidth * 0.5f; // make labels centered
            keyboardLabel.Position  = position; position.X += columnWidth;
            keyboard2Label.Position = position; position.X += columnWidth;
            mouseLabel.Position     = position;

            m_allControls[type].Add(keyboardLabel);
            m_allControls[type].Add(keyboard2Label);
            m_allControls[type].Add(mouseLabel);

            if (MyFakes.ENABLE_JOYSTICK_SETTINGS)
            {
                //position.X += columnWidth; gamepadLabel.Position = position;
                //position.X += columnWidth; analogAxesLabel.Position = position;

                //m_allControls[type].Add(gamepadLabel);
                //m_allControls[type].Add(analogAxesLabel);
            }

            foreach (MyControl control in controls)
            {
                if (control.GetControlTypeEnum() == type)
                {
                    m_allControls[type].Add(new MyGuiControlLabel(
                                                position: m_controlsOriginLeft + i * MyGuiConstants.CONTROLS_DELTA,
                                                text: MyTexts.GetString(control.GetControlName())));

                    position    = controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA;
                    position.X += columnWidth * 0.5f;

                    // This is column for keyboard 1
                    var key1Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.Keyboard);
                    m_allControls[type].Add(key1Button);
                    m_key1Buttons.Add(key1Button);
                    position.X += columnWidth;

                    // This is column for keyboard 2
                    var key2Button = MakeControlButton(control, position, MyGuiInputDeviceEnum.KeyboardSecond);
                    m_allControls[type].Add(key2Button);
                    m_key2Buttons.Add(key2Button);
                    position.X += columnWidth;

                    // This is column for mouse
                    var mouseButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Mouse);
                    m_allControls[type].Add(mouseButton);
                    m_mouseButtons.Add(mouseButton);
                    position.X += columnWidth;

                    if (MyFakes.ENABLE_JOYSTICK_SETTINGS)
                    {
                        //// This is column for joystick
                        //var joyButton = MakeControlButton(control, position, MyGuiInputDeviceEnum.Joystick);
                        //m_allControls[type].Add(joyButton);
                        //m_joystickButtons.Add(joyButton);
                        //position.X += columnWidth;

                        //// This is column for joystick axes
                        //var joyAxis = MakeControlButton(control, position, MyGuiInputDeviceEnum.JoystickAxis);
                        //m_allControls[type].Add(joyAxis);
                        //m_joystickAxes.Add(joyAxis);
                        //position.X += columnWidth;
                    }

                    i += buttonScale;
                }
            }
        }
示例#16
0
 public MyControl(MyGameControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyJoystickButtonsEnum defaultControl)
     : this(control, text, controlType, null, null, defaultControl, null)
 {
 }
示例#17
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum defaultControl)
     : this(control, text, controlType, defaultControl, null, null, null)
 {
 }
示例#18
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, Keys defaultControl)
     : this(control, text, controlType, null, defaultControl, null, null)
 {
 }
示例#19
0
 public MyControl(MyGameControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, Keys defaultControl, Keys defaultSecondControl)
     : this(control, text, controlType, null, defaultControl, null, null)
 {
     m_keyboardKey2 = defaultSecondControl;
 }
示例#20
0
 public MyControl(MyGameControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyJoystickButtonsEnum defaultControl)
     : this(control, text, controlType, null, null, defaultControl, null)
 {
 }
示例#21
0
 public MyControl(MyGameControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, Keys defaultControl, Keys defaultSecondControl)
     : this(control, text, controlType, null, defaultControl, null, null)
 {
     m_keyboardKey2 = defaultSecondControl;
 }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MyCommonTexts.ScreenCaptionControls);

            MyInput.Static.TakeSnapshot();

            var topCenter    = m_size.Value * new Vector2(0f, -0.5f);
            var bottomCenter = m_size.Value * new Vector2(0f, 0.5f);
            var topLeft      = m_size.Value * -0.5f;

            m_controlsOriginLeft  = topLeft + new Vector2(96f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_controlsOriginRight = topCenter + new Vector2(-60f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;

            #region Add Revert, OK, Cancel and selection combobox
            var   buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
            float buttonsY   = bottomCenter.Y - 110f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y;
            var   okButton   = new MyGuiControlButton(
                position: new Vector2(-buttonSize.X - 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Ok),
                onButtonClick: OnOkClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var cancelButton = new MyGuiControlButton(
                position: new Vector2(0f, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Cancel),
                onButtonClick: OnCancelClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var resetButton = new MyGuiControlButton(
                position: new Vector2(buttonSize.X + 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Revert),
                onButtonClick: OnResetDefaultsClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(okButton);
            Controls.Add(cancelButton);
            Controls.Add(resetButton);

            //  Page selection combobox
            m_currentControlType = MyGuiControlTypeEnum.General;
            var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA +
                               new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0);
            m_controlTypeList = new MyGuiControlCombobox(cBoxPosition);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyCommonTexts.ControlTypeGeneral);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyCommonTexts.ControlTypeNavigation);

            //by Gregory this is temporary for Medieval Engineers. Do not show Navigation2 screen if Navigation2 tag is not found
            var DoNotAddNavigation2 = true;
            foreach (var control in MyInput.Static.GetGameControlsList())
            {
                if (control.GetControlTypeEnum() == MyGuiControlTypeEnum.Navigation2)
                {
                    DoNotAddNavigation2 = false;
                    break;
                }
            }

            if (!DoNotAddNavigation2)
            {
                m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation2, MyCommonTexts.ControlTypeNavigation2);
            }

            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons, MyCommonTexts.ControlTypeToolsOrWeapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons2, MyCommonTexts.ControlTypeToolsOrWeapons2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyCommonTexts.ControlTypeSystems1);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyCommonTexts.ControlTypeSystems2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems3, MyCommonTexts.ControlTypeSystems3);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Spectator, MyCommonTexts.Spectator);
            m_controlTypeList.SelectItemByKey((int)m_currentControlType);
            Controls.Add(m_controlTypeList);

            #endregion

            AddControls();

            ActivateControls(m_currentControlType);

            CloseButtonEnabled = true;
        }
示例#23
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, Keys defaultControl)
     : this(control, text, controlType, null, defaultControl, null, null)
 {
 }
 private void DeactivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         Controls.Remove(item);
     }
 }
示例#25
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum defaultControl)
     : this(control, text, controlType, defaultControl, null, null, null)
 {
 }
        public MyGuiScreenOptionsControls()
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null)
        {
            m_size = new Vector2(1110f / 1600f, 1127f / 1200f);
            m_backgroundTexture = MyTextureManager.GetTexture<MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ControlsBackground", flags: TextureFlags.IgnoreQuality);

            m_enableBackgroundFade = true;
            AddCaption(MyTextsWrapperEnum.Controls, new Vector2(0, 0.005f));

            MyGuiManager.GetInput().TakeSnapshot();

            m_controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.06f, -m_size.Value.Y / 2.0f + 0.102f);
            m_controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.333f, -m_size.Value.Y / 2.0f + 0.102f);

            #region Add Revert, OK, Cancel and selection combobox
            /*
            //  Buttons Revert, OK and CANCEL
            float buttonsY = m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f;
            Controls.Add(new MyGuiControlButton(this,
                new Vector2((MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X + 0.015f) * -1, buttonsY),
                MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,

                MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick,
                MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            Controls.Add(new MyGuiControlButton(this,
                new Vector2(0, buttonsY),
                MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick,
                MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            Controls.Add(new MyGuiControlButton(this,
                new Vector2(m_controlsOriginRight.X + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X, buttonsY),
                new Vector2(MyGuiConstants.BUTTON_DEFAULTS_WIDTH, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y), MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyTextsWrapperEnum.Revert, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnResetDefaultsClick,
                MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true));
            */


            var okButton = new MyGuiControlButton(this, new Vector2(-0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Ok,
                MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick,
                true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            var cancelButton = new MyGuiControlButton(this, new Vector2(-0.0597f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel,
                MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick,
                true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            var resetButton = new MyGuiControlButton(this, new Vector2(0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Revert,
                MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnResetDefaultsClick,
                true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true);
            Controls.Add(okButton);
            Controls.Add(cancelButton);
            Controls.Add(resetButton);




            //  Page selection combobox
            m_currentControlType = MyGuiControlTypeEnum.General;
            var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA +
                               new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0);
            m_controlTypeList = new MyGuiControlCombobox(this, cBoxPosition, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyTextsWrapperEnum.General);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyTextsWrapperEnum.Navigation);
            // There are no controls for this category now, so hide it completely and uncomment, when we have new comms controls
            //m_controlTypeList.AddItem((int)MyGuiInputTypeEnum.Communications, MyTextsWrapperEnum.Comms);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Weapons, MyTextsWrapperEnum.Weapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.SpecialWeapons, MyTextsWrapperEnum.SpecialWeapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyTextsWrapperEnum.Systems1);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyTextsWrapperEnum.Systems2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Editor, MyTextsWrapperEnum.Editor);
            m_controlTypeList.SelectItemByKey((int)m_currentControlType);
            Controls.Add(m_controlTypeList);

            #endregion

            AddControls();

            ActivateControls(m_currentControlType);
        }
示例#27
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType, MyMouseButtonsEnum? defaultControlMouse,
     Keys? defaultControlKey, MyJoystickButtonsEnum? defaultControlJoy, MyJoystickAxesEnum? defaultControlJoyAxis)
     : this(control, text, controlType)
 {
     m_mouseButton = defaultControlMouse.HasValue ? defaultControlMouse.Value : MyMouseButtonsEnum.None;
     m_keyboardKey = defaultControlKey.HasValue ? defaultControlKey.Value : Keys.None;
     m_joystickButton = defaultControlJoy.HasValue ? defaultControlJoy.Value : MyJoystickButtonsEnum.None;
     m_joystickAxis = defaultControlJoyAxis.HasValue ? defaultControlJoyAxis.Value : MyJoystickAxesEnum.None;
 }
 private void ActivateControls(MyGuiControlTypeEnum type)
 {
     foreach (var item in m_allControls[type])
     {
         item.Visible = true;
     }
 }
示例#29
0
 public MyControl(MyEditorControlEnums control, MyTextsWrapperEnum text, MyGuiControlTypeEnum controlType)
 {
     m_editorControl = control;
     m_gameControlType = MyGuiGameControlType.EDITOR;
     m_text = text;
     m_controlType = controlType;
     m_joystickButton = MyJoystickButtonsEnum.None;
     m_joystickAxis = MyJoystickAxesEnum.None;
     m_mouseButton = MyMouseButtonsEnum.None;
     m_keyboardKey = Keys.None;
 }
        public override void RecreateControls(bool constructor)
        {
            base.RecreateControls(constructor);

            AddCaption(MyCommonTexts.ScreenCaptionControls);

            MyInput.Static.TakeSnapshot();

            var topCenter = m_size.Value * new Vector2(0f, -0.5f);
            var bottomCenter = m_size.Value * new Vector2(0f, 0.5f);
            var topLeft = m_size.Value * -0.5f;
            m_controlsOriginLeft = topLeft + new Vector2(96f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;
            m_controlsOriginRight = topCenter + new Vector2(-60f, 122f) / MyGuiConstants.GUI_OPTIMAL_SIZE;

            #region Add Revert, OK, Cancel and selection combobox
            var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui;
            float buttonsY = bottomCenter.Y - 110f / MyGuiConstants.GUI_OPTIMAL_SIZE.Y;
            var okButton = new MyGuiControlButton(
                position: new Vector2(-buttonSize.X - 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Ok),
                onButtonClick: OnOkClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var cancelButton = new MyGuiControlButton(
                position: new Vector2(0f, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Cancel),
                onButtonClick: OnCancelClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            var resetButton = new MyGuiControlButton(
                position: new Vector2(buttonSize.X + 20f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, buttonsY),
                size: MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL,
                text: MyTexts.Get(MyCommonTexts.Revert),
                onButtonClick: OnResetDefaultsClick,
                originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(okButton);
            Controls.Add(cancelButton);
            Controls.Add(resetButton);

            //  Page selection combobox
            m_currentControlType = MyGuiControlTypeEnum.General;
            var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA +
                               new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0);
            m_controlTypeList = new MyGuiControlCombobox(cBoxPosition);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyCommonTexts.ControlTypeGeneral);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyCommonTexts.ControlTypeNavigation);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons, MyCommonTexts.ControlTypeToolsOrWeapons);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.ToolsOrWeapons2, MyCommonTexts.ControlTypeToolsOrWeapons2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyCommonTexts.ControlTypeSystems1);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyCommonTexts.ControlTypeSystems2);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems3, MyCommonTexts.ControlTypeSystems3);
            m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Spectator, MyCommonTexts.Spectator);
            m_controlTypeList.SelectItemByKey((int)m_currentControlType);
            Controls.Add(m_controlTypeList);

            #endregion

            AddControls();

            ActivateControls(m_currentControlType);

            CloseButtonEnabled = true;
        }
        private void AddControlsByType(MyGuiControlTypeEnum type)
        {
            Vector2 controlsOriginRight = m_controlsOriginRight;

            controlsOriginRight.X -= 0.047f;
            m_allControls[type]    = new List <MyGuiControlBase>();
            float i           = 2;
            float buttonScale = 0.85f;

            MyControl[] controls = MyGuiManager.GetInput().GetGameControlsList();
            if (type == MyGuiControlTypeEnum.Editor)
            {
                controls = MyGuiManager.GetInput().GetEditorControlsList();
            }

            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 0.0f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Keyboard, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 0.5f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Mouse, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 1.0f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.Gamepad, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));
            m_allControls[type].Add(new MyGuiControlLabel(this, controlsOriginRight + (i - 1) * MyGuiConstants.CONTROLS_DELTA + 1.5f * buttonScale * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) + new Vector2(CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale, null, MyTextsWrapperEnum.AnalogAxes, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP));

            controlsOriginRight.X += 0.047f;
            foreach (MyControl control in controls)
            {
                if (control.GetControlTypeEnum() == type)
                {
                    m_allControls[type].Add(new MyGuiControlLabel(this, m_controlsOriginLeft + i * MyGuiConstants.CONTROLS_DELTA, null, control.GetControlName(), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER));

                    // This is column for keyboard
                    MyGuiControlButtonParameters param     = new MyGuiControlButtonParameters();
                    MyGuiControlButton           keyButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 0 * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                                                                                    CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Keyboard)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                                                                                    MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_keyButtonsDictionary, MyGuiInputDeviceEnum.Keyboard); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(keyButton);
                    m_keyButtons.Add(keyButton);

                    // This is column for mouse
                    MyGuiControlButton mouseButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 0.5f * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                                                                            CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Mouse)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                                                                            MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_mouseButtonsDictionary, MyGuiInputDeviceEnum.Mouse); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(mouseButton);
                    m_mouseButtons.Add(mouseButton);

                    // This is column for joystick
                    MyGuiControlButton joyButton = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 1 * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                                                                          CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.Joystick)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                                                                          MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_joystickButtonsDictionary, MyGuiInputDeviceEnum.Joystick); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(joyButton);
                    m_joystickButtons.Add(joyButton);

                    // This is column for joystick axes
                    MyGuiControlButton joyAxis = new MyGuiControlButton(this, controlsOriginRight + i * MyGuiConstants.CONTROLS_DELTA + 1.5f * new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X - CONTROL_BUTTON_SIZE.X / 2.0f, 0) * buttonScale,
                                                                        CONTROL_BUTTON_SIZE * buttonScale, MyGuiConstants.BUTTON_BACKGROUND_COLOR, new StringBuilder(control.GetControlButtonName(MyGuiInputDeviceEnum.JoystickAxis)), null, MyGuiConstants.BUTTON_TEXT_COLOR,
                                                                        MyGuiConstants.BUTTON_TEXT_SCALE, delegate(MyGuiControlButton sender) { OnControlClick(param, m_joystickAxesDictionary, MyGuiInputDeviceEnum.JoystickAxis); }, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true);
                    param.Control = control;
                    m_allControls[type].Add(joyAxis);
                    m_joystickAxes.Add(joyAxis);

                    m_keyButtonsDictionary[control]      = keyButton;
                    m_mouseButtonsDictionary[control]    = mouseButton;
                    m_joystickButtonsDictionary[control] = joyButton;
                    m_joystickAxesDictionary[control]    = joyAxis;

                    i += buttonScale;
                }
            }
        }