Esempio n. 1
0
 /// <summary>
 /// Queries how much space this menu entry requires.
 /// </summary>
 public virtual int GetHeight( MenuScreen screen )
 {
     return Font.LineSpacing;
 }
Esempio n. 2
0
 /// <summary>
 /// Updates the menu entry.
 /// </summary>
 public virtual void Update( MenuScreen screen, bool isSelected, GameTime gameTime )
 {
 }
Esempio n. 3
0
        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw( MenuScreen screen, bool isSelected, GameTime gameTime )
        {
            // Draw the selected entry in yellow, otherwise white.
            Color color = isSelected ? Fonts.MenuSelectedColor : Fonts.TitleColor;

            // Draw text, centered on the middle of each line.
            ScreenManager screenManager = screen.ScreenManager;
            SpriteBatch spriteBatch = screenManager.SpriteBatch;

            if( texture != null )
            {
                spriteBatch.Draw( texture, position, Color.White );
                if( ( spriteFont != null ) && !String.IsNullOrEmpty( text ) )
                {
                    Vector2 textSize = spriteFont.MeasureString( text );
                    Vector2 textPosition = position + new Vector2(
                        (float)Math.Floor( ( texture.Width - textSize.X ) / 2 ),
                        (float)Math.Floor( ( texture.Height - textSize.Y ) / 2 ) );
                    spriteBatch.DrawString( spriteFont, text, textPosition, color );
                }
            }
            else if( ( spriteFont != null ) && !String.IsNullOrEmpty( text ) )
            {
                spriteBatch.DrawString( spriteFont, text, position, color );
            }
        }