public void Draw() { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(m_body.GetPosition(), m_body.GetSize()), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); m_body.Draw(); // End stencil-mask batch, and restart the standard sprite batch //MyGuiManager.EndSpriteBatch(); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); Color borderColor = m_control.GetColorAfterTransitionAlpha(MyGuiConstants.TREEVIEW_VERTICAL_LINE_COLOR); MyGUIHelper.OutsideBorder(m_position, m_size, 2, borderColor); m_vScrollbar.Draw(); m_hScrollbar.Draw(); }
public override void Draw() { base.Draw(); MyGuiManager.EndSpriteBatch(); Vector2 normalizeSize = new Vector2(483 / 1600f, 112 / 1200f); //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(483, 112); 559? Vector2 stencilPos = GetParent().GetPositionAbsolute() - m_size.Value / 2f; Vector2 senctilSize = new Vector2(normalizeSize.X * m_value, normalizeSize.Y) + new Vector2(38 / 1600f, 0); //MyGuiManager.GetNormalizedCoordsAndPreserveOriginalSize(38, 0); Utils.MyRectangle2D stencilRect = new Utils.MyRectangle2D(stencilPos, senctilSize); MyGuiManager.DrawStencilMaskRectangle(stencilRect, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); MyGuiManager.BeginSpriteBatch_StencilMask(); // draw progress bar MyGuiManager.DrawSpriteBatch(MyGuiManager.GetProgressBarTexture(), GetParent().GetPositionAbsolute(), m_size.Value, new Color(m_progressColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); // draw progress value m_progressValueText.Clear(); float percentage = m_value * 100f; if (m_decimals > 0) { m_progressValueText.AppendDecimal(percentage, m_decimals); } else { m_progressValueText.AppendInt32((int)percentage); } m_progressValueText.Append(PERCENTAGE); MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsWhite(), m_progressValueText, GetParent().GetPositionAbsolute() - new Vector2(0f, m_size.Value.Y / 2f), m_textScale, new Color(m_textColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); }
public override void Draw() { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item if (m_controlsPadding.Y > 0) { MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(GetPositionAbsolute(), m_size.Value), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } else { MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(GetPositionAbsolute(), m_size.Value - 2 * m_controlsPadding), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); base.Draw(); // End stencil-mask batch, and restart the standard sprite batch MyGuiManager.EndSpriteBatch_StencilMask(); //MyGuiManager.EndSpriteBatch(); MyGuiManager.BeginSpriteBatch(); m_verticalScrollbar.Draw(); }
public override void Draw() { if (!Visible) { return; } base.Draw(); Vector2 textAreaSize = GetTextAreaSize(); Vector2 textAreaPosition = GetTextAreaPosition(); Vector4 tempTextColor = (IsMouseOverOrKeyboardActive() == false) ? m_textColor : m_textColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER; Vector2 carriagePosition = GetCarriagePosition(m_carriagePositionIndex); // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle to stencil buffer, so later when we draw, only pixels with stencil=1 will be rendered // Textbox interior must be increased by 1 pixel in all four directions (thus adding 2.0 to its height and width - because it's centered). // Otherwise stencil would cut out something from textbox interior. MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(textAreaPosition + new Vector2(textAreaSize.X / 2.0f, 0), textAreaSize + MyGuiManager.GetNormalizedSizeFromScreenSize(new Vector2(2.0f, 2.0f))), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); UpdateSlidingWindowPosition(); float slidingWindowPositionDeltaX = m_slidingWindowPosition.X - textAreaPosition.X; // Show "sliding window" rectangle - only for debugging //MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), m_slidingWindowPosition, textAreaSize, // GetColorAfterTransitionAlpha(new Vector4(0, 1, 0, 0.3f)), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); // Draw text in textbox MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), new StringBuilder(GetTextByType()), new Vector2(textAreaPosition.X - slidingWindowPositionDeltaX, textAreaPosition.Y), m_textScale, GetColorAfterTransitionAlpha(tempTextColor), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); // Draw carriage line // Carriage blinker time is solved here in Draw because I want to be sure it will be drawn even in low FPS if (m_hasKeyboardActiveControl == true) { // This condition controls "blinking", so most often is carrier visible and blinks very fast // It also depends on FPS, but as we have max FPS set to 60, it won't go faster, nor will it omit a "blink". int carriageInterval = m_carriageBlinkerTimer % 20; if ((carriageInterval >= 0) && (carriageInterval <= 15)) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), new Vector2(carriagePosition.X - slidingWindowPositionDeltaX, carriagePosition.Y), 1, m_size.Value.Y * 0.5f, GetColorAfterTransitionAlpha(tempTextColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } } m_carriageBlinkerTimer++; // End stencil-mask batch, and restart the standard sprite batch //MyGuiManager.EndSpriteBatch(); MyGuiManager.EndSpriteBatch_StencilMask(); //MyGuiManager.BeginSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); }
public override void Draw() { //base.Draw(); if (IsActive()) { // draw item's background if (m_backgroundColor != null && DrawBackgroundTexture) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetBlankTexture(), MyGuiManager.MouseCursorPosition, m_size.Value, /*new Color(m_backgroundColor.Value)*/ GetColorAfterTransitionAlpha(m_backgroundColor.Value * (new Color(50, 66, 70, 255).ToVector4())), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } Vector2 itemPosition = MyGuiManager.MouseCursorPosition - m_size.Value / 2.0f; Vector2 textPosition = itemPosition + m_textOffset; textPosition.Y += (m_size.Value.Y / 2.0f); // draw item's icon if (m_supportIcon == true && m_draggingListboxItem.Icon != null) { MyGuiManager.DrawSpriteBatch(m_draggingListboxItem.Icon, itemPosition, m_size.Value, GetColorAfterTransitionAlpha(m_backgroundColor.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } // draw item's text else if (m_draggingListboxItem.Value != null) { // End our standard sprite batch MyGuiManager.EndSpriteBatch(); // Draw the rectangle(basically the opened area) to stencil buffer to be used for clipping partial item MyGuiManager.DrawStencilMaskRectangle(new MyRectangle2D(itemPosition, m_size.Value), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); // Set up the stencil operation and parameters MyGuiManager.BeginSpriteBatch_StencilMask(); m_draggingListboxItem.ColoredText.Draw(textPosition, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, m_parent.GetTransitionAlpha(), true); // End stencil-mask batch, and restart the standard sprite batch //MyGuiManager.EndSpriteBatch(); MyGuiManager.EndSpriteBatch_StencilMask(); MyGuiManager.BeginSpriteBatch(); } ShowToolTip(); } }