示例#1
0
        public void DrawToSpriteBatch(SpriteBatch spriteBatch)
        {
            if (!ShowBubble)
            {
                return;
            }

            var TL  = GetTexture(ChatBubbleTexture.TopLeft);
            var TM  = GetTexture(ChatBubbleTexture.TopMiddle);
            var TR  = GetTexture(ChatBubbleTexture.TopRight);
            var ML  = GetTexture(ChatBubbleTexture.MiddleLeft);
            var MM  = GetTexture(ChatBubbleTexture.MiddleMiddle);
            var MR  = GetTexture(ChatBubbleTexture.MiddleRight);
            var BL  = GetTexture(ChatBubbleTexture.BottomLeft);
            var BM  = GetTexture(ChatBubbleTexture.BottomMiddle);
            var BR  = GetTexture(ChatBubbleTexture.BottomRight);
            var NUB = GetTexture(ChatBubbleTexture.Nubbin);

            var xCov = TL.Width;
            var yCov = TL.Height;

            var color = _isGroupChat ? Color.Tan : Color.FromNonPremultiplied(255, 255, 255, 232);

            //top row
            spriteBatch.Draw(TL, _drawLocation, color);
            int xCur;

            for (xCur = xCov; xCur < _textLabel.ActualWidth + 6; xCur += TM.Width)
            {
                spriteBatch.Draw(TM, _drawLocation + new Vector2(xCur, 0), color);
            }
            spriteBatch.Draw(TR, _drawLocation + new Vector2(xCur, 0), color);

            //middle area
            int y;

            for (y = yCov; y < _textLabel.ActualHeight; y += ML.Height)
            {
                spriteBatch.Draw(ML, _drawLocation + new Vector2(0, y), color);
                int x;
                for (x = xCov; x < xCur; x += MM.Width)
                {
                    spriteBatch.Draw(MM, _drawLocation + new Vector2(x, y), color);
                }
                spriteBatch.Draw(MR, _drawLocation + new Vector2(xCur, y), color);
            }

            //bottom row
            spriteBatch.Draw(BL, _drawLocation + new Vector2(0, y), color);
            int x2;

            for (x2 = xCov; x2 < xCur; x2 += BM.Width)
            {
                spriteBatch.Draw(BM, _drawLocation + new Vector2(x2, y), color);
            }
            spriteBatch.Draw(BR, _drawLocation + new Vector2(x2, y), color);

            y += BM.Height;
            spriteBatch.Draw(NUB, _drawLocation + new Vector2((x2 + BR.Width - NUB.Width) / 2f, y - 1), color);

            spriteBatch.End();
            _textLabel.Draw(new GameTime());
            spriteBatch.Begin();
        }