/// <summary> /// Queries how much space this menu entry requires. /// </summary> public virtual int GetHeight(Menu screen) { return Font.LineSpacing; }
/// <summary> /// Updates the menu entry. /// </summary> public virtual void Update(Menu screen, bool isSelected, GameTime gameTime) { }
/// <summary> /// Draws the menu entry. This can be overridden to customize the appearance. /// </summary> public virtual void Draw(Menu screen, bool isSelected, GameTime gameTime) { // Draw the selected entry in yellow, otherwise white. Color color = isSelected ? Fonts.MenuSelectedColor : Fonts.TitleColor; color *= screen.TransitionAlpha; // Draw text, centered on the middle of each line. ScreenManager screenManager = screen.ScreenManager; SpriteBatch spriteBatch = screenManager.SpriteBatch; spriteFont = screenManager.Font; 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); } }