public void DrawTextureRect(Texture2D texture, UIBox2 rect, Color?modulate = null)
        {
            CheckDisposed();

            DrawTextureRectRegion(texture, rect, null, modulate);
        }
        public void DrawTexture(Texture2D texture, Vector2 position, Color?modulate = null)
        {
            CheckDisposed();

            DrawTextureRect(texture, UIBox2.FromDimensions(position.X, position.Y, texture.Width, texture.Height), modulate);
        }
 public abstract void DrawTextureRectRegion(Texture2D texture, UIBox2 rect, UIBox2?subRegion = null, Color?modulate = null);
示例#4
0
 protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box)
 {
     handle.DrawRect(box, BackgroundColor);
 }
示例#5
0
        public void Draw(
            DrawingHandleScreen handle,
            SpriteFont font,
            UIBox2 drawBox,
            float verticalOffset,
            // A stack for format tags.
            // This stack contains the format tag to RETURN TO when popped off.
            // So when a new color tag gets hit this stack gets the previous color pushed on.
            Stack <FormattedMessage.Tag> formatStack, float uiScale)
        {
            // The tag currently doing color.
            var currentColorTag = TagBaseColor;

            var globalBreakCounter = 0;
            var lineBreakIndex     = 0;
            var baseLine           = drawBox.TopLeft + new Vector2(0, font.GetAscent(uiScale) + verticalOffset);

            formatStack.Clear();
            foreach (var tag in Message.Tags)
            {
                switch (tag)
                {
                case FormattedMessage.TagColor tagColor:
                    formatStack.Push(currentColorTag);
                    currentColorTag = tagColor;
                    break;

                case FormattedMessage.TagPop _:
                    var popped = formatStack.Pop();
                    switch (popped)
                    {
                    case FormattedMessage.TagColor tagColor:
                        currentColorTag = tagColor;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }

                    break;

                case FormattedMessage.TagText tagText:
                {
                    var text = tagText.Text;
                    for (var i = 0; i < text.Length; i++, globalBreakCounter++)
                    {
                        var chr = text[i];
                        if (lineBreakIndex < LineBreaks.Count &&
                            LineBreaks[lineBreakIndex] == globalBreakCounter)
                        {
                            baseLine        = new Vector2(drawBox.Left, baseLine.Y + font.GetLineHeight(uiScale));
                            lineBreakIndex += 1;
                        }

                        var advance = font.DrawChar(handle, chr, baseLine, uiScale, currentColorTag.Color);
                        baseLine += new Vector2(advance, 0);
                    }

                    break;
                }
                }
            }
        }
 public override void DrawTextureRectRegion(Texture2D texture, UIBox2 rect, UIBox2?subRegion = null, Color?modulate = null)
 {
     _spriteBatch.Draw(texture, rect, subRegion, modulate ?? Color.White);
 }