private void OnControlClick(MyGuiControlButtonParameters param, Dictionary <MyControl, MyGuiControlButton> buttonsDictionary, MyGuiInputDeviceEnum deviceType) { MyTextsWrapperEnum messageText = MyTextsWrapperEnum.AssignControlKeyboard; if (deviceType == MyGuiInputDeviceEnum.Mouse) { messageText = MyTextsWrapperEnum.AssignControlMouse; } else if (deviceType == MyGuiInputDeviceEnum.Joystick) { messageText = MyTextsWrapperEnum.AssignControlJoystick; } else if (deviceType == MyGuiInputDeviceEnum.JoystickAxis) { messageText = MyTextsWrapperEnum.AssignControlJoystickAxis; } MyGuiManager.AddScreen(new MyGuiControlAssignKeyMessageBox(buttonsDictionary, deviceType, param.Control, messageText)); }
private void OnControlClick(MyGuiControlButtonParameters param, Dictionary<MyControl, MyGuiControlButton> buttonsDictionary, MyGuiInputDeviceEnum deviceType) { MyTextsWrapperEnum messageText = MyTextsWrapperEnum.AssignControlKeyboard; if (deviceType == MyGuiInputDeviceEnum.Mouse) { messageText = MyTextsWrapperEnum.AssignControlMouse; } else if (deviceType == MyGuiInputDeviceEnum.Joystick) { messageText = MyTextsWrapperEnum.AssignControlJoystick; } else if (deviceType == MyGuiInputDeviceEnum.JoystickAxis) { messageText = MyTextsWrapperEnum.AssignControlJoystickAxis; } MyGuiManager.AddScreen(new MyGuiControlAssignKeyMessageBox(buttonsDictionary, deviceType, param.Control, messageText)); }
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) { 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; } } }