public override void Draw() { MyTexture2D buttonTexture = null; MyTexture2D backgroundTexture = null; if (m_controlTexture == null) { if (m_size.HasValue && m_size.Value.Y < MyGuiConstants.MAIN_MENU_BUTTON_SIZE.Y) { buttonTexture = MyGuiManager.GetConfirmButton(); } else { buttonTexture = MyGuiManager.GetButtonTexture(); } } else { if (IsMouseOver() && m_mouseButtonPressed && m_pressedTexture != null) { buttonTexture = m_pressedTexture; } else if (IsMouseOver() && m_hoverTexture != null) { buttonTexture = m_hoverTexture; } else { buttonTexture = m_controlTexture; } } backgroundTexture = MyGuiManager.GetButtonTextureBg(buttonTexture); bool isNotImplementedForbidenOrDisabled = !m_implementedFeature || m_accessForbiddenReason != null || !Enabled; Vector4 backgroundColor, textColor; if (!UseSwitchMode) { bool isHighlighted = IsMouseOverOrKeyboardActive() && (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver())); backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_textColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_textColor); } else { backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_backgroundColor.Value * 0.75f); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_textColor * 0.75f); } if (backgroundTexture != null && m_useBackground) { // Draw background texture MyGuiManager.DrawSpriteBatch(backgroundTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw background texture if (buttonTexture != null) { MyGuiManager.DrawSpriteBatch(buttonTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, GetColorAfterTransitionAlpha(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw cross texture if (isNotImplementedForbidenOrDisabled && DrawCrossTextureWhenDisabled) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetLockedButtonTexture(), m_parent.GetPositionAbsolute() + m_position, m_size.Value * MyGuiConstants.LOCKBUTTON_SIZE_MODIFICATION, MyGuiConstants.DISABLED_BUTTON_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } if (Text != null) { Vector2 textPosition; MyGuiDrawAlignEnum textDrawAlign; if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED) { textPosition = m_parent.GetPositionAbsolute() + m_position; textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; } else if (m_textAlignment == MyGuiControlButtonTextAlignment.LEFT) { // This will move text few pixels from button's left border textPosition = m_parent.GetPositionAbsolute() + m_position - new Vector2(m_size.Value.X / 2.0f, 0) + new Vector2(MyGuiConstants.BUTTON_TEXT_OFFSET.X, 0); textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } textPosition += TextOffset; MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text, textPosition, m_textScale, GetColorAfterTransitionAlpha(textColor), textDrawAlign); } //ShowToolTip(); }