Example #1
0
        public override void Draw(GameTime gameTime)
        {
            if (!Visible)
            {
                return;
            }

#if SILVERLIGHT
            var color = new Color(Color, MathHelper.Clamp((float)Alpha, 0, 1));
#else
            var color = Color * (float)Alpha;
#endif

            // Top
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X, (int)Position.Y, BorderSize, BorderSize), _leftTopCorner, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + BorderSize, (int)Position.Y, Width - 2 * BorderSize, BorderSize), _topBorder, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + Width - BorderSize, (int)Position.Y, BorderSize, BorderSize), _rightTopCorner, color);

            // Middle
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X, (int)Position.Y + BorderSize, BorderSize, Height - 2 * BorderSize), _leftBorder, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + BorderSize, (int)Position.Y + BorderSize, Width - 2 * BorderSize, Height - 2 * BorderSize), _interior, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + Width - BorderSize, (int)Position.Y + BorderSize, BorderSize, Height - 2 * BorderSize), _rightBorder, color);

            //bottom
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X, (int)Position.Y + Height - BorderSize, BorderSize, BorderSize), _leftBottomCorner, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + BorderSize, (int)Position.Y + Height - BorderSize, Width - 2 * BorderSize, BorderSize), _bottomBorder, color);
            _spriteBatch.Draw(_texture, new Rectangle((int)Position.X + Width - BorderSize, (int)Position.Y + Height - BorderSize, BorderSize, BorderSize), _rightBottomCorner, color);

            if (AnimatableString != null)
            {
                AnimatableString.Draw(gameTime);
            }
        }
Example #2
0
        public SpeechBubble(Game game, Texture2D texture, Vector2 position, string text, SpriteFont font, int width, int height, int borderSize)
            : base(game)
        {
            if (font != null)
            {
                AnimatableString = new AnimatableString(game, text, font)
                {
                    Color = Color.Black
                };
            }
            Width      = width;
            Height     = height;
            BorderSize = borderSize;
            SpacingX   = borderSize;
            SpacingY   = borderSize;

            if (AnimatableString != null)
            {
                AnimatableString.MaxLineWidth  = width - 2 * SpacingX;
                AnimatableString.MaxLines      = -1;
                AnimatableString.MaxLineHeight = height - 2 * SpacingY;
            }

            _texture          = texture;
            Position          = position;
            Alpha             = 1;
            Color             = Color.White;
            ShouldReScaleText = true;
        }
Example #3
0
        public override void Draw(GameTime gameTime)
        {
            if (!Visible)
            {
                return;
            }

            base.Draw(gameTime);

            AnimatableString.Draw(gameTime);
        }
Example #4
0
 public CheckBox(Game game, Texture2D textureBack, Texture2D textureChecked, string text, SpriteFont font, Vector2 position)
     : base(game, textureBack, position)
 {
     AnimatableString = new AnimatableString(game, text, font)
     {
         Color = Color.White
     };
     TextureBack    = textureBack;
     TextureChecked = textureChecked;
     PositionString();
     Checked = false;
 }
Example #5
0
        public override void Initialize()
        {
            _spriteBatch = Game.Services.GetService(typeof(SpriteBatch)) as SpriteBatch;

            if (AnimatableString != null)
            {
                AnimatableString.Initialize();
                UpdateAnimatableStringPosition();
            }

            _bottomBorder      = new Rectangle(BorderSize, _texture.Height - BorderSize, _texture.Width - 2 * BorderSize, BorderSize);
            _interior          = new Rectangle(BorderSize, BorderSize, _texture.Width - 2 * BorderSize, _texture.Height - 2 * BorderSize);
            _leftBorder        = new Rectangle(0, BorderSize, BorderSize, _texture.Height - 2 * BorderSize);
            _leftBottomCorner  = new Rectangle(0, _texture.Height - BorderSize, BorderSize, BorderSize);
            _leftTopCorner     = new Rectangle(0, 0, BorderSize, BorderSize);
            _rightBorder       = new Rectangle(_texture.Width - BorderSize, BorderSize, BorderSize, _texture.Height - 2 * BorderSize);
            _rightBottomCorner = new Rectangle(_texture.Width - BorderSize, _texture.Height - BorderSize, BorderSize, BorderSize);
            _rightTopCorner    = new Rectangle(_texture.Width - BorderSize, 0, BorderSize, BorderSize);
            _topBorder         = new Rectangle(BorderSize, 0, _texture.Width - 2 * BorderSize, BorderSize);

            base.Initialize();
        }
Example #6
0
 public override void Initialize()
 {
     base.Initialize();
     AnimatableString.Initialize();
     Width = TextureBack.Width + Spacing + AnimatableString.Width;
 }