public override void Draw() { /* * int count = m_allToolTips.Keys.Count; * for (int c = 0; c < count; c++) * { * MyGuiManager.DrawSpriteBatch(m_selectedTexture, m_parentScreen.GetPosition() + m_position, m_size.Value, * GetColorAfterTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); * } */ //base.Draw(); //draw buttons on head with texts int count = m_tabs.Keys.Count; int pos = 0; foreach (int i in m_tabs.Keys) { MyTexture2D buttonTexture = MyGuiManager.GetButtonTexture(); Vector2 parentPos = m_parent.GetPositionAbsolute(); Vector2? parentSize = m_parent.GetSize(); parentPos -= parentSize.Value / 2; Vector2 offsetPos = parentPos + pos * new Vector2(m_headSize.X * parentSize.Value.X / count, 0); Vector2 tabHeadSize = new Vector2((m_headSize.X / (count)) * parentSize.Value.X, (m_headSize.Y) * parentSize.Value.Y); bool isHighlight = GetMouseOverTab() == i || GetSelectedTab() == i; bool isNotImplementedForbidenOrDisabled = /*!m_implementedFeature || m_accessForbiddenReason != null ||*/ !Enabled; /* * bool isHighlighted = IsMouseOverOrKeyboardActive() && * (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver())); */ Vector4 backgroundColor = isNotImplementedForbidenOrDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : (isHighlight ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value); backgroundColor.W = 1.0f; // Draw background texture MyGuiManager.DrawSpriteBatch(buttonTexture, offsetPos, tabHeadSize * m_scale, new Color(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); Vector4 textColor = isNotImplementedForbidenOrDisabled ? textColor = MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : ((isHighlight) ? m_color * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_color); StringBuilder text = new StringBuilder(GetTabSubControl(i).GetCaption()); if (text != null) { Vector2 textPosition; MyGuiDrawAlignEnum textDrawAlign; textPosition = offsetPos + tabHeadSize / 2; textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; /* * if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED) * { * textPosition = m_parentScreen.GetPosition() + 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_parentScreen.GetPosition() + 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(); * } */ MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), text, textPosition, 1.2f /*m_textScale*/, GetColorAfterTransitionAlpha(textColor), textDrawAlign); } pos++; } //base.Draw(); GetTabSubControl(m_selectedTab).Draw(); }
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(); }