Пример #1
0
        /*
         * void DrawScrollBar(SpriteBatch spriteBatch)
         * {
         * float sbHeight = Height / ContentHeight * Height;
         * Vector2 pos = DrawPosition;
         * float scrollSpace = Height - sbHeight;
         * float y = scrollPosition / contentHeight * scrollSpace;
         * pos.Y += y;
         * float fillHeight = sbHeight - ScrollbarTexture.Height * 2;
         * pos.X += Width - ScrollbarTexture.Width;
         * spriteBatch.Draw(ScrollbarTexture, pos, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f);
         * pos.Y += ScrollbarTexture.Height;
         * spriteBatch.Draw(ScrollbarFill, pos - Origin, null, Color.White, 0f, Vector2.Zero, new Vector2(1f, fillHeight), SpriteEffects.None, 0f);
         * pos.Y += fillHeight;
         * spriteBatch.Draw(ScrollbarTexture, pos, null, Color.White, 0f, Origin, 1f, SpriteEffects.FlipVertically, 0f);
         * }
         */

        public override void Draw(SpriteBatch spriteBatch)
        {
            Vector2 pos = DrawPosition - Origin;

            Utils.DrawInvBG(spriteBatch, pos.X, pos.Y, Width, Height, new Color(33, 15, 91, 255) * (0.685f * Opacity));

            DrawScrollbg(spriteBatch);
            //DrawScrollBar(spriteBatch);
            if (pos.X <= Main.screenWidth && pos.Y <= Main.screenHeight && pos.X + Width >= 0 && pos.Y + Height >= 0)
            {
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _rasterizerState, null, Main.UIScaleMatrix);

                Rectangle cutRect = new Rectangle((int)pos.X, (int)pos.Y, (int)Width, (int)Height);

                /*if (cutRect.X < 0)
                 * {
                 *      cutRect.Width += cutRect.X;
                 *      cutRect.X = 0;
                 * }
                 * if (cutRect.Y < 0)
                 * {
                 *      cutRect.Height += cutRect.Y;
                 *      cutRect.Y = 0;
                 * }
                 * if (cutRect.X + Width > Main.screenWidth) cutRect.Width = Main.screenWidth - cutRect.X;
                 * if (cutRect.Y + Height > Main.screenHeight) cutRect.Height = Main.screenHeight - cutRect.Y;*/
                cutRect = ModUtils.GetClippingRectangle(spriteBatch, cutRect);

                Rectangle currentRect = spriteBatch.GraphicsDevice.ScissorRectangle;
                spriteBatch.GraphicsDevice.ScissorRectangle = cutRect;

                if (OverrideDrawAndUpdate)
                {
                    scrollBar.Draw(spriteBatch);
                }
                else
                {
                    base.Draw(spriteBatch);
                }

                spriteBatch.GraphicsDevice.ScissorRectangle = currentRect;
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, Main.UIScaleMatrix);
                scrollBar.Draw(spriteBatch);
            }
        }
Пример #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (Visible)
            {
                spriteBatch.End();
                //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState);
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, this._rasterizerState, null, Main.UIScaleMatrix);
                //	Rectangle scissorRectangle = new Rectangle((int)base.X- (int)base.Width, (int)base.Y, (int)base.Width, (int)base.Height);
                //Parent.Position.Y
                //		Main.NewText((int)Parent.Position.Y + " " + (int)shownPosition);
                //	Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)base.Height);
                Rectangle scissorRectangle = new Rectangle((int)(base.X - base.Width / 2), (int)(shownPosition), (int)base.Width, (int)(HotBarParent.Position.Y - shownPosition));

                /*if (scissorRectangle.X < 0)
                 * {
                 *      scissorRectangle.Width += scissorRectangle.X;
                 *      scissorRectangle.X = 0;
                 * }
                 * if (scissorRectangle.Y < 0)
                 * {
                 *      scissorRectangle.Height += scissorRectangle.Y;
                 *      scissorRectangle.Y = 0;
                 * }
                 * if ((float)scissorRectangle.X + base.Width > (float)Main.screenWidth)
                 * {
                 *      scissorRectangle.Width = Main.screenWidth - scissorRectangle.X;
                 * }
                 * if ((float)scissorRectangle.Y + base.Height > (float)Main.screenHeight)
                 * {
                 *      scissorRectangle.Height = Main.screenHeight - scissorRectangle.Y;
                 * }*/
                scissorRectangle = ModUtils.GetClippingRectangle(spriteBatch, scissorRectangle);
                Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle;
                spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;

                base.Draw(spriteBatch);

                spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2;
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix);
            }
            //	base.Draw(spriteBatch);
        }
Пример #3
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (focused)
            {
                Terraria.GameInput.PlayerInput.WritingText = true;
                Main.instance.HandleIME();
                string oldText = Text;
                Text = Main.GetInputText(Text);
                if (oldText != Text)
                {
                    KeyPressed?.Invoke(this, ' ');
                }
                if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Tab))
                {
                    OnTabPress?.Invoke(this, new EventArgs());
                }
                if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter))
                {
                    OnEnterPress?.Invoke(this, new EventArgs());
                }
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix);
                Main.instance.DrawWindowsIMEPanel(new Vector2(98f, (float)(Main.screenHeight - 36)), 0f);
            }

            spriteBatch.Draw(textboxBackground, DrawPosition, null, Color.White, 0f, Origin, 1f, SpriteEffects.None, 0f);
            int     fillWidth = (int)Width - 2 * textboxBackground.Width;
            Vector2 pos       = DrawPosition;

            pos.X += textboxBackground.Width;
            spriteBatch.Draw(TextboxFill, pos - Origin, null, Color.White, 0f, Vector2.Zero, new Vector2(fillWidth, 1f), SpriteEffects.None, 0f);
            pos.X += fillWidth;
            spriteBatch.Draw(textboxBackground, pos, null, Color.White, 0f, Origin, 1f, SpriteEffects.FlipHorizontally, 0f);
            string drawString = Text;

            if (PasswordBox)
            {
                drawString = passwordString;
            }
            if (drawCarrot && focused)
            {
                drawString += "|";
            }
            label.Text = drawString;

            pos = DrawPosition - Origin;

            if (pos.X <= Main.screenWidth && pos.Y <= Main.screenHeight && pos.X + Width >= 0 && pos.Y + Height >= 0)
            {
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, _rasterizerState, null, Main.UIScaleMatrix);

                Rectangle cutRect = new Rectangle((int)pos.X, (int)pos.Y, (int)Width, (int)Height);

                /*if (cutRect.X < 0)
                 * {
                 *      cutRect.Width += cutRect.X;
                 *      cutRect.X = 0;
                 * }
                 * if (cutRect.Y < 0)
                 * {
                 *      cutRect.Height += cutRect.Y;
                 *      cutRect.Y = 0;
                 * }
                 * if (cutRect.X + Width > Main.screenWidth) cutRect.Width = Main.screenWidth - cutRect.X;
                 * if (cutRect.Y + Height > Main.screenHeight) cutRect.Height = Main.screenHeight - cutRect.Y;*/
                cutRect = ModUtils.GetClippingRectangle(spriteBatch, cutRect);

                Rectangle currentRect = spriteBatch.GraphicsDevice.ScissorRectangle;
                spriteBatch.GraphicsDevice.ScissorRectangle = cutRect;

                base.Draw(spriteBatch);

                spriteBatch.GraphicsDevice.ScissorRectangle = currentRect;
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, Main.UIScaleMatrix);
            }
        }