Ejemplo n.º 1
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (user != null)
            {
                CalculatedStyle dimensions = GetDimensions();

                spriteBatch.EnableScissor();

                Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, user.Username, dimensions.X + dimensions.Height + 8, dimensions.Y + dimensions.Height / 2 - 10, color, Color.Black, Vector2.Zero);

                spriteBatch.SetupForShader(DTT.circleShader);

                spriteBatch.Draw(texture, new Rectangle((int)dimensions.X, (int)dimensions.Y, (int)dimensions.Height, (int)dimensions.Height), Color.White);

                RasterizerState state = new RasterizerState {
                    ScissorTestEnable = true
                };

                spriteBatch.End();

                Vector4 activity = user.Presence.PresenceColor().ToVector4();
                DTT.activityShader.Parameters["drawColor"].SetValue(activity);
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, state, DTT.activityShader, Main.UIScaleMatrix);

                int size = (int)(dimensions.Height / 4f);
                spriteBatch.Draw(Main.magicPixel, new Rectangle((int)(dimensions.X + dimensions.Height - size), (int)(dimensions.Y + dimensions.Height - size), size, size), Color.White);

                spriteBatch.DisableScissor();
            }
        }
Ejemplo n.º 2
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            CalculatedStyle dimensions = GetDimensions();

            RasterizerState state = new RasterizerState {
                ScissorTestEnable = true
            };

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, state, null, Main.UIScaleMatrix);
            Rectangle prevRect = spriteBatch.GraphicsDevice.ScissorRectangle;

            spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle((int)DTT.Instance.MainUI.gridGuilds.GetDimensions().X, (int)DTT.Instance.MainUI.gridGuilds.GetDimensions().Y - 6, Main.screenWidth - (int)DTT.Instance.MainUI.gridGuilds.GetDimensions().X, (int)DTT.Instance.MainUI.gridGuilds.GetDimensions().Height + 12);

            if (IsMouseHovering)
            {
                Rectangle rect = new Rectangle((int)(dimensions.X + dimensions.Width + 8), (int)(dimensions.Y + dimensions.Height / 2f - 16), (int)(guild.Name.Measure().X + 16), 32);

                spriteBatch.DrawPanel(rect, BaseLib.Utility.Utility.backgroundTexture, BaseUI.panelColor);
                spriteBatch.DrawPanel(rect, BaseLib.Utility.Utility.borderTexture, Color.Black);

                Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, guild.Name, rect.X + 8, rect.Y + 6, color, Color.Black, Vector2.Zero);
            }

            spriteBatch.SetupForShader(DTT.circleShader);

            spriteBatch.Draw(texture, new Rectangle((int)dimensions.X, (int)dimensions.Y, (int)dimensions.Height, (int)dimensions.Height), Color.White);

            spriteBatch.GraphicsDevice.ScissorRectangle = prevRect;
            spriteBatch.DisableScissor();
        }
Ejemplo n.º 3
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            CalculatedStyle dimensions = GetDimensions();

            spriteBatch.EnableScissor();

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].OnDraw != null)
                {
                    lines[i].OnDraw.Invoke(spriteBatch, new CalculatedStyle(dimensions.X + lines[i].X + 48, dimensions.Y + lines[i].Y, dimensions.Width, dimensions.Height));
                }
                else
                {
                    Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, lines[i].Text, dimensions.X + 48 + lines[i].X, dimensions.Y + lines[i].Y, lines[i].Color, Color.Black, Vector2.Zero, lines[i].Scale);
                }

                if (lines[i].OnHover != null)
                {
                    Rectangle rect = new Rectangle((int)(dimensions.X + 48 + lines[i].X), (int)(dimensions.Y + lines[i].Y), (int)lines[i].Width, (int)lines[i].Height);
                    if (rect.Intersects(dimensions.ToRectangle()) && rect.Contains(Main.MouseScreen))
                    {
                        lines[i].OnHover.Invoke(spriteBatch, dimensions);
                    }
                }
            }

            spriteBatch.SetupForShader(DTT.circleShader);

            spriteBatch.Draw(avatar, new Rectangle((int)dimensions.X, (int)dimensions.Y, 40, 40), Color.White);

            spriteBatch.DisableScissor();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="position"></param>
        protected override void OnDraw(SpriteBatch batch, Vector2 position)
        {
            if (this.Visible)
            {
                // Background
                batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color);

                // Borders
                batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black, 2);
                batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black, 2);
                batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black, 2);
                batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black, 2);

                batch.EnableScissor(new Rectangle((int)position.X + 2, (int)position.Y + 2, (int)this.Size.X - 2, (int)this.Size.Y - 2));
                {
                    batch.Draw(this.texture, new Rectangle(0, 0, 1, 1), Color.White * 0.0f);

                    var lastPosition = position + new Vector2(2, this.Size.Y - 2);
                    for (int i = this.messages.Count - 1; i >= 0; i--)
                    {
                        var text = this.messages[i];
                        var size = this.font.Content.MeasureText(text);
                        lastPosition.Y -= size.Y;
                        batch.DrawString(this.font.Content, text, lastPosition, Color.Black);
                    }
                }
                batch.DisableScissor();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when drawing the HUD component.
        /// </summary>
        /// <param name="batch">The sprite batch instance.</param>
        /// <param name="position"></param>
        protected override void OnDraw(SpriteBatch batch, Vector2 position)
        {
            if (this.Visible)
            {
                // Background

                batch.Draw(this.texture, new Rectangle((int)position.X, (int)position.Y, (int)this.Size.X, (int)this.Size.Y), this.color);

                // Borders
                batch.DrawLine(position, position + new Vector2(this.Size.X, 0), Color.Black, 2);
                batch.DrawLine(position + new Vector2(this.Size.X, 0), position + new Vector2(this.Size.X, this.Size.Y), Color.Black, 2);
                batch.DrawLine(position + new Vector2(this.Size.X, this.Size.Y), position + new Vector2(0, this.Size.Y), Color.Black, 2);
                batch.DrawLine(position + new Vector2(0, this.Size.Y), position, Color.Black, 2);

                batch.EnableScissor(new Rectangle((int)position.X + 2, (int)position.Y + 2, (int)this.Size.X - 4, (int)this.Size.Y - 4));
                {
                    var text = this.Password ? (this.Text.Length > 0 ? Enumerable.Repeat("*", this.Text.Length).Aggregate((s, n) => s + n) : "") : this.Text;
                    var size = this.font.Content.MeasureString(this.Text);
                    var pos  = position + new Vector2(5, (this.Size.Y - size.Y) / 2);
                    if (size.X > this.Size.X - 10)
                    {
                        pos.X = (pos.X + this.Size.X - 10) - size.X;
                    }
                    batch.DrawString(this.font.Content, text, pos, Color.Black);
                }
                batch.DisableScissor();
            }
        }
Ejemplo n.º 6
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            if (visible && texture != null)
            {
                CalculatedStyle dimensions = GetDimensions();

                spriteBatch.SetupForShader(DTT.circleShader);

                spriteBatch.Draw(texture, new Rectangle((int)dimensions.X, (int)dimensions.Y, (int)dimensions.Width, (int)dimensions.Height), Color.White);

                spriteBatch.DisableScissor();
            }
        }
Ejemplo n.º 7
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.EnableScissor();

            RecalculateChildren();
            Recalculate();
            DrawSelf(spriteBatch);
            if (expanded)
            {
                typeof(UIInnerList).InvokeMethod <object>("DrawChildren", new object[] { spriteBatch }, list);
            }

            spriteBatch.DisableScissor();
        }
Ejemplo n.º 8
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            CalculatedStyle dimensions = GetDimensions();
            CalculatedStyle gridDim    = DTT.Instance.MainUI.gridPMs.GetDimensions();

            RasterizerState state = new RasterizerState {
                ScissorTestEnable = true
            };

            spriteBatch.End();
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, null, state, null, Main.UIScaleMatrix);
            Rectangle prevRect = spriteBatch.GraphicsDevice.ScissorRectangle;

            spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle((int)gridDim.X, (int)gridDim.Y - 6, Main.screenWidth - (int)gridDim.X, (int)gridDim.Height + 12);

            if (IsMouseHovering)
            {
                string    name = channel.Name ?? channel.Recipients[0].Username;
                Rectangle rect = new Rectangle((int)(dimensions.X + dimensions.Width + 8), (int)(dimensions.Y + dimensions.Height / 2f - 16), (int)(name.Measure().X + 16), 32);

                spriteBatch.DrawPanel(rect, BaseLib.Utility.Utility.backgroundTexture, BaseUI.panelColor);
                spriteBatch.DrawPanel(rect, BaseLib.Utility.Utility.borderTexture, Color.Black);

                Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, name, rect.X + 8, rect.Y + 6, color, Color.Black, Vector2.Zero);
            }

            spriteBatch.SetupForShader(DTT.circleShader);

            spriteBatch.Draw(texture, new Rectangle((int)dimensions.X, (int)dimensions.Y, (int)dimensions.Height, (int)dimensions.Height), Color.White);

            spriteBatch.SetupForShader(DTT.activityShader);

            Vector4 activity = channel.Recipients[0].Presence.PresenceColor().ToVector4();

            DTT.activityShader.Parameters["drawColor"].SetValue(activity);

            int size = (int)(dimensions.Height / 4f);

            spriteBatch.Draw(Main.magicPixel, new Rectangle((int)(dimensions.X + dimensions.Height - size), (int)(dimensions.Y + dimensions.Height - size), size, size), Color.White);

            spriteBatch.GraphicsDevice.ScissorRectangle = prevRect;
            spriteBatch.DisableScissor();
        }
Ejemplo n.º 9
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.EnableScissor();

            Rectangle prevRect = spriteBatch.GraphicsDevice.ScissorRectangle;

            spriteBatch.GraphicsDevice.ScissorRectangle = GetInnerDimensions().ToRectangle();

            Lerp();
            if (scrollbar != null)
            {
                innerList.Top.Set(scrollbar.GetValue(), 0f);
            }
            RecalculateChildren();
            Recalculate();

            base.DrawSelf(spriteBatch);
            typeof(UIInnerList).InvokeMethod <object>("DrawChildren", new object[] { spriteBatch }, innerList);

            spriteBatch.GraphicsDevice.ScissorRectangle = prevRect;
            spriteBatch.DisableScissor();
        }