Ejemplo n.º 1
0
 protected void DrawBackground(float transitionAlpha)
 {
     // Draw background texture if there is one and background is not completely transparent.
     if (BackgroundTexture != null && ColorMask.W > 0.0f)
     {
         BackgroundTexture.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
     }
 }
Ejemplo n.º 2
0
        private void DrawOpenedAreaScrollbar(float scrollbarInnerTexturePositionX, MyRectangle2D openedArea, float transitionAlpha)
        {
            var margin = m_styleDef.ScrollbarMargin;

            var pos = GetPositionAbsoluteBottomRight() + new Vector2(-(margin.Right + m_scrollbarTexture.MinSizeGui.X),
                                                                     margin.Top + m_scrollBarCurrentPosition);
            m_scrollbarTexture.Draw(pos, m_scrollBarHeight - m_scrollbarTexture.MinSizeGui.Y, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha));
        }
Ejemplo n.º 3
0
        public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
        {
            base.Draw(transitionAlpha, backgroundTransitionAlpha);

            m_railTexture.Draw(
                GetPositionAbsoluteTopLeft(),
                Size - new Vector2(m_labelSpaceWidth, 0f),
                ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha),
                textureScale: DebugScale);
            DrawThumb(transitionAlpha);
            m_label.Draw(transitionAlpha, backgroundTransitionAlpha);
        }
        public override void Draw(float transitionAlpha, float backgroundTransitionAlpha)
        {
            if (!Visible)
            {
                return;
            }

            m_compositeBackground.Draw(GetPositionAbsoluteTopLeft(), Size, ApplyColorMaskModifiers(ColorMask, Enabled, backgroundTransitionAlpha));

            base.Draw(transitionAlpha, backgroundTransitionAlpha);

            var textAreaRelative = m_textAreaRelative;
            var textArea         = textAreaRelative;

            textArea.LeftTop += GetPositionAbsoluteTopLeft();
            float carriageOffset = GetCarriageOffset(CarriagePositionIndex);

            var scissor = new RectangleF(textArea.LeftTop, textArea.Size);

            using (MyGuiManager.UsingScissorRectangle(ref scissor))
            {
                RefreshSlidingWindow();

                //Draws selection background, if any
                if (m_selection.Length > 0)
                {
                    float normalizedWidth = GetCarriageOffset(m_selection.End) - GetCarriageOffset(m_selection.Start);
                    MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE,
                                                 new Vector2(textArea.LeftTop.X + GetCarriageOffset(m_selection.Start), textArea.LeftTop.Y),
                                                 new Vector2(normalizedWidth, textArea.Size.Y),
                                                 ApplyColorMaskModifiers(new Vector4(1, 1, 1, 0.5f), Enabled, transitionAlpha),
                                                 MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP
                                                 );
                }

                //  Draw text in textbox
                MyGuiManager.DrawString(TextFont,
                                        new StringBuilder(GetModifiedText()),
                                        new Vector2(textArea.LeftTop.X + m_slidingWindowOffset, textArea.LeftTop.Y),
                                        TextScaleWithLanguage,
                                        ApplyColorMaskModifiers(m_textColor, Enabled, transitionAlpha),
                                        MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);

                //  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 (HasFocus)
                {
                    //  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(MyGuiConstants.BLANK_TEXTURE,
                                                     new Vector2(textArea.LeftTop.X + carriageOffset, textArea.LeftTop.Y),
                                                     1,
                                                     textArea.Size.Y,
                                                     ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha),
                                                     MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
                    }
                }
                m_carriageBlinkerTimer++;
            }

            //DebugDraw();
        }