public override void Draw(SpriteBatch spriteBatch)
        {
            Vector2 vector = base.DrawPosition - base.Origin;

            Utils.DrawInvBG(spriteBatch, vector.X, vector.Y, base.Width, base.Height, new Color(33, 15, 91, 255) * 0.685f);
            this.DrawScrollbg(spriteBatch);
            if (vector.X <= (float)Main.screenWidth && vector.Y <= (float)Main.screenHeight && vector.X + base.Width >= 0f && vector.Y + base.Height >= 0f)
            {
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, this._rasterizerState, null, Main.UIScaleMatrix);
                Rectangle scissorRectangle = new Rectangle((int)vector.X, (int)vector.Y, (int)base.Width, (int)base.Height);

                /*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 = CheatSheet.GetClippingRectangle(spriteBatch, scissorRectangle);
                Rectangle scissorRectangle2 = spriteBatch.GraphicsDevice.ScissorRectangle;
                spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
                if (this.OverrideDrawAndUpdate)
                {
                    this.scrollBar.Draw(spriteBatch);
                }
                else
                {
                    base.Draw(spriteBatch);
                }
                spriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle2;
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, Main.UIScaleMatrix);
                this.scrollBar.Draw(spriteBatch);
            }
        }
Exemple #2
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 = CheatSheet.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);
            }
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (Visible)
            {
                spriteBatch.End();
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, 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)(mod.hotbar.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 = CheatSheet.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);

            if (Visible && (base.IsMouseInside() /*|| button.MouseInside*/))
            {
                Main.LocalPlayer.mouseInterface = true;
                //Main.LocalPlayer.showItemIcon = false;
            }

            if (Visible && IsMouseInside())
            {
                Main.LocalPlayer.mouseInterface = true;
            }

            float   x      = Main.fontMouseText.MeasureString(UIView.HoverText).X;
            Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f);

            if (vector.Y > (float)(Main.screenHeight - 30))
            {
                vector.Y = (float)(Main.screenHeight - 30);
            }
            if (vector.X > (float)Main.screenWidth - x)
            {
                vector.X = (float)(Main.screenWidth - 460);
            }
            Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, UIView.HoverText, vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f);
        }